babylon.module.d.ts 4.9 MB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970297129722973297429752976297729782979298029812982298329842985298629872988298929902991299229932994299529962997299829993000300130023003300430053006300730083009301030113012301330143015301630173018301930203021302230233024302530263027302830293030303130323033303430353036303730383039304030413042304330443045304630473048304930503051305230533054305530563057305830593060306130623063306430653066306730683069307030713072307330743075307630773078307930803081308230833084308530863087308830893090309130923093309430953096309730983099310031013102310331043105310631073108310931103111311231133114311531163117311831193120312131223123312431253126312731283129313031313132313331343135313631373138313931403141314231433144314531463147314831493150315131523153315431553156315731583159316031613162316331643165316631673168316931703171317231733174317531763177317831793180318131823183318431853186318731883189319031913192319331943195319631973198319932003201320232033204320532063207320832093210321132123213321432153216321732183219322032213222322332243225322632273228322932303231323232333234323532363237323832393240324132423243324432453246324732483249325032513252325332543255325632573258325932603261326232633264326532663267326832693270327132723273327432753276327732783279328032813282328332843285328632873288328932903291329232933294329532963297329832993300330133023303330433053306330733083309331033113312331333143315331633173318331933203321332233233324332533263327332833293330333133323333333433353336333733383339334033413342334333443345334633473348334933503351335233533354335533563357335833593360336133623363336433653366336733683369337033713372337333743375337633773378337933803381338233833384338533863387338833893390339133923393339433953396339733983399340034013402340334043405340634073408340934103411341234133414341534163417341834193420342134223423342434253426342734283429343034313432343334343435343634373438343934403441344234433444344534463447344834493450345134523453345434553456345734583459346034613462346334643465346634673468346934703471347234733474347534763477347834793480348134823483348434853486348734883489349034913492349334943495349634973498349935003501350235033504350535063507350835093510351135123513351435153516351735183519352035213522352335243525352635273528352935303531353235333534353535363537353835393540354135423543354435453546354735483549355035513552355335543555355635573558355935603561356235633564356535663567356835693570357135723573357435753576357735783579358035813582358335843585358635873588358935903591359235933594359535963597359835993600360136023603360436053606360736083609361036113612361336143615361636173618361936203621362236233624362536263627362836293630363136323633363436353636363736383639364036413642364336443645364636473648364936503651365236533654365536563657365836593660366136623663366436653666366736683669367036713672367336743675367636773678367936803681368236833684368536863687368836893690369136923693369436953696369736983699370037013702370337043705370637073708370937103711371237133714371537163717371837193720372137223723372437253726372737283729373037313732373337343735373637373738373937403741374237433744374537463747374837493750375137523753375437553756375737583759376037613762376337643765376637673768376937703771377237733774377537763777377837793780378137823783378437853786378737883789379037913792379337943795379637973798379938003801380238033804380538063807380838093810381138123813381438153816381738183819382038213822382338243825382638273828382938303831383238333834383538363837383838393840384138423843384438453846384738483849385038513852385338543855385638573858385938603861386238633864386538663867386838693870387138723873387438753876387738783879388038813882388338843885388638873888388938903891389238933894389538963897389838993900390139023903390439053906390739083909391039113912391339143915391639173918391939203921392239233924392539263927392839293930393139323933393439353936393739383939394039413942394339443945394639473948394939503951395239533954395539563957395839593960396139623963396439653966396739683969397039713972397339743975397639773978397939803981398239833984398539863987398839893990399139923993399439953996399739983999400040014002400340044005400640074008400940104011401240134014401540164017401840194020402140224023402440254026402740284029403040314032403340344035403640374038403940404041404240434044404540464047404840494050405140524053405440554056405740584059406040614062406340644065406640674068406940704071407240734074407540764077407840794080408140824083408440854086408740884089409040914092409340944095409640974098409941004101410241034104410541064107410841094110411141124113411441154116411741184119412041214122412341244125412641274128412941304131413241334134413541364137413841394140414141424143414441454146414741484149415041514152415341544155415641574158415941604161416241634164416541664167416841694170417141724173417441754176417741784179418041814182418341844185418641874188418941904191419241934194419541964197419841994200420142024203420442054206420742084209421042114212421342144215421642174218421942204221422242234224422542264227422842294230423142324233423442354236423742384239424042414242424342444245424642474248424942504251425242534254425542564257425842594260426142624263426442654266426742684269427042714272427342744275427642774278427942804281428242834284428542864287428842894290429142924293429442954296429742984299430043014302430343044305430643074308430943104311431243134314431543164317431843194320432143224323432443254326432743284329433043314332433343344335433643374338433943404341434243434344434543464347434843494350435143524353435443554356435743584359436043614362436343644365436643674368436943704371437243734374437543764377437843794380438143824383438443854386438743884389439043914392439343944395439643974398439944004401440244034404440544064407440844094410441144124413441444154416441744184419442044214422442344244425442644274428442944304431443244334434443544364437443844394440444144424443444444454446444744484449445044514452445344544455445644574458445944604461446244634464446544664467446844694470447144724473447444754476447744784479448044814482448344844485448644874488448944904491449244934494449544964497449844994500450145024503450445054506450745084509451045114512451345144515451645174518451945204521452245234524452545264527452845294530453145324533453445354536453745384539454045414542454345444545454645474548454945504551455245534554455545564557455845594560456145624563456445654566456745684569457045714572457345744575457645774578457945804581458245834584458545864587458845894590459145924593459445954596459745984599460046014602460346044605460646074608460946104611461246134614461546164617461846194620462146224623462446254626462746284629463046314632463346344635463646374638463946404641464246434644464546464647464846494650465146524653465446554656465746584659466046614662466346644665466646674668466946704671467246734674467546764677467846794680468146824683468446854686468746884689469046914692469346944695469646974698469947004701470247034704470547064707470847094710471147124713471447154716471747184719472047214722472347244725472647274728472947304731473247334734473547364737473847394740474147424743474447454746474747484749475047514752475347544755475647574758475947604761476247634764476547664767476847694770477147724773477447754776477747784779478047814782478347844785478647874788478947904791479247934794479547964797479847994800480148024803480448054806480748084809481048114812481348144815481648174818481948204821482248234824482548264827482848294830483148324833483448354836483748384839484048414842484348444845484648474848484948504851485248534854485548564857485848594860486148624863486448654866486748684869487048714872487348744875487648774878487948804881488248834884488548864887488848894890489148924893489448954896489748984899490049014902490349044905490649074908490949104911491249134914491549164917491849194920492149224923492449254926492749284929493049314932493349344935493649374938493949404941494249434944494549464947494849494950495149524953495449554956495749584959496049614962496349644965496649674968496949704971497249734974497549764977497849794980498149824983498449854986498749884989499049914992499349944995499649974998499950005001500250035004500550065007500850095010501150125013501450155016501750185019502050215022502350245025502650275028502950305031503250335034503550365037503850395040504150425043504450455046504750485049505050515052505350545055505650575058505950605061506250635064506550665067506850695070507150725073507450755076507750785079508050815082508350845085508650875088508950905091509250935094509550965097509850995100510151025103510451055106510751085109511051115112511351145115511651175118511951205121512251235124512551265127512851295130513151325133513451355136513751385139514051415142514351445145514651475148514951505151515251535154515551565157515851595160516151625163516451655166516751685169517051715172517351745175517651775178517951805181518251835184518551865187518851895190519151925193519451955196519751985199520052015202520352045205520652075208520952105211521252135214521552165217521852195220522152225223522452255226522752285229523052315232523352345235523652375238523952405241524252435244524552465247524852495250525152525253525452555256525752585259526052615262526352645265526652675268526952705271527252735274527552765277527852795280528152825283528452855286528752885289529052915292529352945295529652975298529953005301530253035304530553065307530853095310531153125313531453155316531753185319532053215322532353245325532653275328532953305331533253335334533553365337533853395340534153425343534453455346534753485349535053515352535353545355535653575358535953605361536253635364536553665367536853695370537153725373537453755376537753785379538053815382538353845385538653875388538953905391539253935394539553965397539853995400540154025403540454055406540754085409541054115412541354145415541654175418541954205421542254235424542554265427542854295430543154325433543454355436543754385439544054415442544354445445544654475448544954505451545254535454545554565457545854595460546154625463546454655466546754685469547054715472547354745475547654775478547954805481548254835484548554865487548854895490549154925493549454955496549754985499550055015502550355045505550655075508550955105511551255135514551555165517551855195520552155225523552455255526552755285529553055315532553355345535553655375538553955405541554255435544554555465547554855495550555155525553555455555556555755585559556055615562556355645565556655675568556955705571557255735574557555765577557855795580558155825583558455855586558755885589559055915592559355945595559655975598559956005601560256035604560556065607560856095610561156125613561456155616561756185619562056215622562356245625562656275628562956305631563256335634563556365637563856395640564156425643564456455646564756485649565056515652565356545655565656575658565956605661566256635664566556665667566856695670567156725673567456755676567756785679568056815682568356845685568656875688568956905691569256935694569556965697569856995700570157025703570457055706570757085709571057115712571357145715571657175718571957205721572257235724572557265727572857295730573157325733573457355736573757385739574057415742574357445745574657475748574957505751575257535754575557565757575857595760576157625763576457655766576757685769577057715772577357745775577657775778577957805781578257835784578557865787578857895790579157925793579457955796579757985799580058015802580358045805580658075808580958105811581258135814581558165817581858195820582158225823582458255826582758285829583058315832583358345835583658375838583958405841584258435844584558465847584858495850585158525853585458555856585758585859586058615862586358645865586658675868586958705871587258735874587558765877587858795880588158825883588458855886588758885889589058915892589358945895589658975898589959005901590259035904590559065907590859095910591159125913591459155916591759185919592059215922592359245925592659275928592959305931593259335934593559365937593859395940594159425943594459455946594759485949595059515952595359545955595659575958595959605961596259635964596559665967596859695970597159725973597459755976597759785979598059815982598359845985598659875988598959905991599259935994599559965997599859996000600160026003600460056006600760086009601060116012601360146015601660176018601960206021602260236024602560266027602860296030603160326033603460356036603760386039604060416042604360446045604660476048604960506051605260536054605560566057605860596060606160626063606460656066606760686069607060716072607360746075607660776078607960806081608260836084608560866087608860896090609160926093609460956096609760986099610061016102610361046105610661076108610961106111611261136114611561166117611861196120612161226123612461256126612761286129613061316132613361346135613661376138613961406141614261436144614561466147614861496150615161526153615461556156615761586159616061616162616361646165616661676168616961706171617261736174617561766177617861796180618161826183618461856186618761886189619061916192619361946195619661976198619962006201620262036204620562066207620862096210621162126213621462156216621762186219622062216222622362246225622662276228622962306231623262336234623562366237623862396240624162426243624462456246624762486249625062516252625362546255625662576258625962606261626262636264626562666267626862696270627162726273627462756276627762786279628062816282628362846285628662876288628962906291629262936294629562966297629862996300630163026303630463056306630763086309631063116312631363146315631663176318631963206321632263236324632563266327632863296330633163326333633463356336633763386339634063416342634363446345634663476348634963506351635263536354635563566357635863596360636163626363636463656366636763686369637063716372637363746375637663776378637963806381638263836384638563866387638863896390639163926393639463956396639763986399640064016402640364046405640664076408640964106411641264136414641564166417641864196420642164226423642464256426642764286429643064316432643364346435643664376438643964406441644264436444644564466447644864496450645164526453645464556456645764586459646064616462646364646465646664676468646964706471647264736474647564766477647864796480648164826483648464856486648764886489649064916492649364946495649664976498649965006501650265036504650565066507650865096510651165126513651465156516651765186519652065216522652365246525652665276528652965306531653265336534653565366537653865396540654165426543654465456546654765486549655065516552655365546555655665576558655965606561656265636564656565666567656865696570657165726573657465756576657765786579658065816582658365846585658665876588658965906591659265936594659565966597659865996600660166026603660466056606660766086609661066116612661366146615661666176618661966206621662266236624662566266627662866296630663166326633663466356636663766386639664066416642664366446645664666476648664966506651665266536654665566566657665866596660666166626663666466656666666766686669667066716672667366746675667666776678667966806681668266836684668566866687668866896690669166926693669466956696669766986699670067016702670367046705670667076708670967106711671267136714671567166717671867196720672167226723672467256726672767286729673067316732673367346735673667376738673967406741674267436744674567466747674867496750675167526753675467556756675767586759676067616762676367646765676667676768676967706771677267736774677567766777677867796780678167826783678467856786678767886789679067916792679367946795679667976798679968006801680268036804680568066807680868096810681168126813681468156816681768186819682068216822682368246825682668276828682968306831683268336834683568366837683868396840684168426843684468456846684768486849685068516852685368546855685668576858685968606861686268636864686568666867686868696870687168726873687468756876687768786879688068816882688368846885688668876888688968906891689268936894689568966897689868996900690169026903690469056906690769086909691069116912691369146915691669176918691969206921692269236924692569266927692869296930693169326933693469356936693769386939694069416942694369446945694669476948694969506951695269536954695569566957695869596960696169626963696469656966696769686969697069716972697369746975697669776978697969806981698269836984698569866987698869896990699169926993699469956996699769986999700070017002700370047005700670077008700970107011701270137014701570167017701870197020702170227023702470257026702770287029703070317032703370347035703670377038703970407041704270437044704570467047704870497050705170527053705470557056705770587059706070617062706370647065706670677068706970707071707270737074707570767077707870797080708170827083708470857086708770887089709070917092709370947095709670977098709971007101710271037104710571067107710871097110711171127113711471157116711771187119712071217122712371247125712671277128712971307131713271337134713571367137713871397140714171427143714471457146714771487149715071517152715371547155715671577158715971607161716271637164716571667167716871697170717171727173717471757176717771787179718071817182718371847185718671877188718971907191719271937194719571967197719871997200720172027203720472057206720772087209721072117212721372147215721672177218721972207221722272237224722572267227722872297230723172327233723472357236723772387239724072417242724372447245724672477248724972507251725272537254725572567257725872597260726172627263726472657266726772687269727072717272727372747275727672777278727972807281728272837284728572867287728872897290729172927293729472957296729772987299730073017302730373047305730673077308730973107311731273137314731573167317731873197320732173227323732473257326732773287329733073317332733373347335733673377338733973407341734273437344734573467347734873497350735173527353735473557356735773587359736073617362736373647365736673677368736973707371737273737374737573767377737873797380738173827383738473857386738773887389739073917392739373947395739673977398739974007401740274037404740574067407740874097410741174127413741474157416741774187419742074217422742374247425742674277428742974307431743274337434743574367437743874397440744174427443744474457446744774487449745074517452745374547455745674577458745974607461746274637464746574667467746874697470747174727473747474757476747774787479748074817482748374847485748674877488748974907491749274937494749574967497749874997500750175027503750475057506750775087509751075117512751375147515751675177518751975207521752275237524752575267527752875297530753175327533753475357536753775387539754075417542754375447545754675477548754975507551755275537554755575567557755875597560756175627563756475657566756775687569757075717572757375747575757675777578757975807581758275837584758575867587758875897590759175927593759475957596759775987599760076017602760376047605760676077608760976107611761276137614761576167617761876197620762176227623762476257626762776287629763076317632763376347635763676377638763976407641764276437644764576467647764876497650765176527653765476557656765776587659766076617662766376647665766676677668766976707671767276737674767576767677767876797680768176827683768476857686768776887689769076917692769376947695769676977698769977007701770277037704770577067707770877097710771177127713771477157716771777187719772077217722772377247725772677277728772977307731773277337734773577367737773877397740774177427743774477457746774777487749775077517752775377547755775677577758775977607761776277637764776577667767776877697770777177727773777477757776777777787779778077817782778377847785778677877788778977907791779277937794779577967797779877997800780178027803780478057806780778087809781078117812781378147815781678177818781978207821782278237824782578267827782878297830783178327833783478357836783778387839784078417842784378447845784678477848784978507851785278537854785578567857785878597860786178627863786478657866786778687869787078717872787378747875787678777878787978807881788278837884788578867887788878897890789178927893789478957896789778987899790079017902790379047905790679077908790979107911791279137914791579167917791879197920792179227923792479257926792779287929793079317932793379347935793679377938793979407941794279437944794579467947794879497950795179527953795479557956795779587959796079617962796379647965796679677968796979707971797279737974797579767977797879797980798179827983798479857986798779887989799079917992799379947995799679977998799980008001800280038004800580068007800880098010801180128013801480158016801780188019802080218022802380248025802680278028802980308031803280338034803580368037803880398040804180428043804480458046804780488049805080518052805380548055805680578058805980608061806280638064806580668067806880698070807180728073807480758076807780788079808080818082808380848085808680878088808980908091809280938094809580968097809880998100810181028103810481058106810781088109811081118112811381148115811681178118811981208121812281238124812581268127812881298130813181328133813481358136813781388139814081418142814381448145814681478148814981508151815281538154815581568157815881598160816181628163816481658166816781688169817081718172817381748175817681778178817981808181818281838184818581868187818881898190819181928193819481958196819781988199820082018202820382048205820682078208820982108211821282138214821582168217821882198220822182228223822482258226822782288229823082318232823382348235823682378238823982408241824282438244824582468247824882498250825182528253825482558256825782588259826082618262826382648265826682678268826982708271827282738274827582768277827882798280828182828283828482858286828782888289829082918292829382948295829682978298829983008301830283038304830583068307830883098310831183128313831483158316831783188319832083218322832383248325832683278328832983308331833283338334833583368337833883398340834183428343834483458346834783488349835083518352835383548355835683578358835983608361836283638364836583668367836883698370837183728373837483758376837783788379838083818382838383848385838683878388838983908391839283938394839583968397839883998400840184028403840484058406840784088409841084118412841384148415841684178418841984208421842284238424842584268427842884298430843184328433843484358436843784388439844084418442844384448445844684478448844984508451845284538454845584568457845884598460846184628463846484658466846784688469847084718472847384748475847684778478847984808481848284838484848584868487848884898490849184928493849484958496849784988499850085018502850385048505850685078508850985108511851285138514851585168517851885198520852185228523852485258526852785288529853085318532853385348535853685378538853985408541854285438544854585468547854885498550855185528553855485558556855785588559856085618562856385648565856685678568856985708571857285738574857585768577857885798580858185828583858485858586858785888589859085918592859385948595859685978598859986008601860286038604860586068607860886098610861186128613861486158616861786188619862086218622862386248625862686278628862986308631863286338634863586368637863886398640864186428643864486458646864786488649865086518652865386548655865686578658865986608661866286638664866586668667866886698670867186728673867486758676867786788679868086818682868386848685868686878688868986908691869286938694869586968697869886998700870187028703870487058706870787088709871087118712871387148715871687178718871987208721872287238724872587268727872887298730873187328733873487358736873787388739874087418742874387448745874687478748874987508751875287538754875587568757875887598760876187628763876487658766876787688769877087718772877387748775877687778778877987808781878287838784878587868787878887898790879187928793879487958796879787988799880088018802880388048805880688078808880988108811881288138814881588168817881888198820882188228823882488258826882788288829883088318832883388348835883688378838883988408841884288438844884588468847884888498850885188528853885488558856885788588859886088618862886388648865886688678868886988708871887288738874887588768877887888798880888188828883888488858886888788888889889088918892889388948895889688978898889989008901890289038904890589068907890889098910891189128913891489158916891789188919892089218922892389248925892689278928892989308931893289338934893589368937893889398940894189428943894489458946894789488949895089518952895389548955895689578958895989608961896289638964896589668967896889698970897189728973897489758976897789788979898089818982898389848985898689878988898989908991899289938994899589968997899889999000900190029003900490059006900790089009901090119012901390149015901690179018901990209021902290239024902590269027902890299030903190329033903490359036903790389039904090419042904390449045904690479048904990509051905290539054905590569057905890599060906190629063906490659066906790689069907090719072907390749075907690779078907990809081908290839084908590869087908890899090909190929093909490959096909790989099910091019102910391049105910691079108910991109111911291139114911591169117911891199120912191229123912491259126912791289129913091319132913391349135913691379138913991409141914291439144914591469147914891499150915191529153915491559156915791589159916091619162916391649165916691679168916991709171917291739174917591769177917891799180918191829183918491859186918791889189919091919192919391949195919691979198919992009201920292039204920592069207920892099210921192129213921492159216921792189219922092219222922392249225922692279228922992309231923292339234923592369237923892399240924192429243924492459246924792489249925092519252925392549255925692579258925992609261926292639264926592669267926892699270927192729273927492759276927792789279928092819282928392849285928692879288928992909291929292939294929592969297929892999300930193029303930493059306930793089309931093119312931393149315931693179318931993209321932293239324932593269327932893299330933193329333933493359336933793389339934093419342934393449345934693479348934993509351935293539354935593569357935893599360936193629363936493659366936793689369937093719372937393749375937693779378937993809381938293839384938593869387938893899390939193929393939493959396939793989399940094019402940394049405940694079408940994109411941294139414941594169417941894199420942194229423942494259426942794289429943094319432943394349435943694379438943994409441944294439444944594469447944894499450945194529453945494559456945794589459946094619462946394649465946694679468946994709471947294739474947594769477947894799480948194829483948494859486948794889489949094919492949394949495949694979498949995009501950295039504950595069507950895099510951195129513951495159516951795189519952095219522952395249525952695279528952995309531953295339534953595369537953895399540954195429543954495459546954795489549955095519552955395549555955695579558955995609561956295639564956595669567956895699570957195729573957495759576957795789579958095819582958395849585958695879588958995909591959295939594959595969597959895999600960196029603960496059606960796089609961096119612961396149615961696179618961996209621962296239624962596269627962896299630963196329633963496359636963796389639964096419642964396449645964696479648964996509651965296539654965596569657965896599660966196629663966496659666966796689669967096719672967396749675967696779678967996809681968296839684968596869687968896899690969196929693969496959696969796989699970097019702970397049705970697079708970997109711971297139714971597169717971897199720972197229723972497259726972797289729973097319732973397349735973697379738973997409741974297439744974597469747974897499750975197529753975497559756975797589759976097619762976397649765976697679768976997709771977297739774977597769777977897799780978197829783978497859786978797889789979097919792979397949795979697979798979998009801980298039804980598069807980898099810981198129813981498159816981798189819982098219822982398249825982698279828982998309831983298339834983598369837983898399840984198429843984498459846984798489849985098519852985398549855985698579858985998609861986298639864986598669867986898699870987198729873987498759876987798789879988098819882988398849885988698879888988998909891989298939894989598969897989898999900990199029903990499059906990799089909991099119912991399149915991699179918991999209921992299239924992599269927992899299930993199329933993499359936993799389939994099419942994399449945994699479948994999509951995299539954995599569957995899599960996199629963996499659966996799689969997099719972997399749975997699779978997999809981998299839984998599869987998899899990999199929993999499959996999799989999100001000110002100031000410005100061000710008100091001010011100121001310014100151001610017100181001910020100211002210023100241002510026100271002810029100301003110032100331003410035100361003710038100391004010041100421004310044100451004610047100481004910050100511005210053100541005510056100571005810059100601006110062100631006410065100661006710068100691007010071100721007310074100751007610077100781007910080100811008210083100841008510086100871008810089100901009110092100931009410095100961009710098100991010010101101021010310104101051010610107101081010910110101111011210113101141011510116101171011810119101201012110122101231012410125101261012710128101291013010131101321013310134101351013610137101381013910140101411014210143101441014510146101471014810149101501015110152101531015410155101561015710158101591016010161101621016310164101651016610167101681016910170101711017210173101741017510176101771017810179101801018110182101831018410185101861018710188101891019010191101921019310194101951019610197101981019910200102011020210203102041020510206102071020810209102101021110212102131021410215102161021710218102191022010221102221022310224102251022610227102281022910230102311023210233102341023510236102371023810239102401024110242102431024410245102461024710248102491025010251102521025310254102551025610257102581025910260102611026210263102641026510266102671026810269102701027110272102731027410275102761027710278102791028010281102821028310284102851028610287102881028910290102911029210293102941029510296102971029810299103001030110302103031030410305103061030710308103091031010311103121031310314103151031610317103181031910320103211032210323103241032510326103271032810329103301033110332103331033410335103361033710338103391034010341103421034310344103451034610347103481034910350103511035210353103541035510356103571035810359103601036110362103631036410365103661036710368103691037010371103721037310374103751037610377103781037910380103811038210383103841038510386103871038810389103901039110392103931039410395103961039710398103991040010401104021040310404104051040610407104081040910410104111041210413104141041510416104171041810419104201042110422104231042410425104261042710428104291043010431104321043310434104351043610437104381043910440104411044210443104441044510446104471044810449104501045110452104531045410455104561045710458104591046010461104621046310464104651046610467104681046910470104711047210473104741047510476104771047810479104801048110482104831048410485104861048710488104891049010491104921049310494104951049610497104981049910500105011050210503105041050510506105071050810509105101051110512105131051410515105161051710518105191052010521105221052310524105251052610527105281052910530105311053210533105341053510536105371053810539105401054110542105431054410545105461054710548105491055010551105521055310554105551055610557105581055910560105611056210563105641056510566105671056810569105701057110572105731057410575105761057710578105791058010581105821058310584105851058610587105881058910590105911059210593105941059510596105971059810599106001060110602106031060410605106061060710608106091061010611106121061310614106151061610617106181061910620106211062210623106241062510626106271062810629106301063110632106331063410635106361063710638106391064010641106421064310644106451064610647106481064910650106511065210653106541065510656106571065810659106601066110662106631066410665106661066710668106691067010671106721067310674106751067610677106781067910680106811068210683106841068510686106871068810689106901069110692106931069410695106961069710698106991070010701107021070310704107051070610707107081070910710107111071210713107141071510716107171071810719107201072110722107231072410725107261072710728107291073010731107321073310734107351073610737107381073910740107411074210743107441074510746107471074810749107501075110752107531075410755107561075710758107591076010761107621076310764107651076610767107681076910770107711077210773107741077510776107771077810779107801078110782107831078410785107861078710788107891079010791107921079310794107951079610797107981079910800108011080210803108041080510806108071080810809108101081110812108131081410815108161081710818108191082010821108221082310824108251082610827108281082910830108311083210833108341083510836108371083810839108401084110842108431084410845108461084710848108491085010851108521085310854108551085610857108581085910860108611086210863108641086510866108671086810869108701087110872108731087410875108761087710878108791088010881108821088310884108851088610887108881088910890108911089210893108941089510896108971089810899109001090110902109031090410905109061090710908109091091010911109121091310914109151091610917109181091910920109211092210923109241092510926109271092810929109301093110932109331093410935109361093710938109391094010941109421094310944109451094610947109481094910950109511095210953109541095510956109571095810959109601096110962109631096410965109661096710968109691097010971109721097310974109751097610977109781097910980109811098210983109841098510986109871098810989109901099110992109931099410995109961099710998109991100011001110021100311004110051100611007110081100911010110111101211013110141101511016110171101811019110201102111022110231102411025110261102711028110291103011031110321103311034110351103611037110381103911040110411104211043110441104511046110471104811049110501105111052110531105411055110561105711058110591106011061110621106311064110651106611067110681106911070110711107211073110741107511076110771107811079110801108111082110831108411085110861108711088110891109011091110921109311094110951109611097110981109911100111011110211103111041110511106111071110811109111101111111112111131111411115111161111711118111191112011121111221112311124111251112611127111281112911130111311113211133111341113511136111371113811139111401114111142111431114411145111461114711148111491115011151111521115311154111551115611157111581115911160111611116211163111641116511166111671116811169111701117111172111731117411175111761117711178111791118011181111821118311184111851118611187111881118911190111911119211193111941119511196111971119811199112001120111202112031120411205112061120711208112091121011211112121121311214112151121611217112181121911220112211122211223112241122511226112271122811229112301123111232112331123411235112361123711238112391124011241112421124311244112451124611247112481124911250112511125211253112541125511256112571125811259112601126111262112631126411265112661126711268112691127011271112721127311274112751127611277112781127911280112811128211283112841128511286112871128811289112901129111292112931129411295112961129711298112991130011301113021130311304113051130611307113081130911310113111131211313113141131511316113171131811319113201132111322113231132411325113261132711328113291133011331113321133311334113351133611337113381133911340113411134211343113441134511346113471134811349113501135111352113531135411355113561135711358113591136011361113621136311364113651136611367113681136911370113711137211373113741137511376113771137811379113801138111382113831138411385113861138711388113891139011391113921139311394113951139611397113981139911400114011140211403114041140511406114071140811409114101141111412114131141411415114161141711418114191142011421114221142311424114251142611427114281142911430114311143211433114341143511436114371143811439114401144111442114431144411445114461144711448114491145011451114521145311454114551145611457114581145911460114611146211463114641146511466114671146811469114701147111472114731147411475114761147711478114791148011481114821148311484114851148611487114881148911490114911149211493114941149511496114971149811499115001150111502115031150411505115061150711508115091151011511115121151311514115151151611517115181151911520115211152211523115241152511526115271152811529115301153111532115331153411535115361153711538115391154011541115421154311544115451154611547115481154911550115511155211553115541155511556115571155811559115601156111562115631156411565115661156711568115691157011571115721157311574115751157611577115781157911580115811158211583115841158511586115871158811589115901159111592115931159411595115961159711598115991160011601116021160311604116051160611607116081160911610116111161211613116141161511616116171161811619116201162111622116231162411625116261162711628116291163011631116321163311634116351163611637116381163911640116411164211643116441164511646116471164811649116501165111652116531165411655116561165711658116591166011661116621166311664116651166611667116681166911670116711167211673116741167511676116771167811679116801168111682116831168411685116861168711688116891169011691116921169311694116951169611697116981169911700117011170211703117041170511706117071170811709117101171111712117131171411715117161171711718117191172011721117221172311724117251172611727117281172911730117311173211733117341173511736117371173811739117401174111742117431174411745117461174711748117491175011751117521175311754117551175611757117581175911760117611176211763117641176511766117671176811769117701177111772117731177411775117761177711778117791178011781117821178311784117851178611787117881178911790117911179211793117941179511796117971179811799118001180111802118031180411805118061180711808118091181011811118121181311814118151181611817118181181911820118211182211823118241182511826118271182811829118301183111832118331183411835118361183711838118391184011841118421184311844118451184611847118481184911850118511185211853118541185511856118571185811859118601186111862118631186411865118661186711868118691187011871118721187311874118751187611877118781187911880118811188211883118841188511886118871188811889118901189111892118931189411895118961189711898118991190011901119021190311904119051190611907119081190911910119111191211913119141191511916119171191811919119201192111922119231192411925119261192711928119291193011931119321193311934119351193611937119381193911940119411194211943119441194511946119471194811949119501195111952119531195411955119561195711958119591196011961119621196311964119651196611967119681196911970119711197211973119741197511976119771197811979119801198111982119831198411985119861198711988119891199011991119921199311994119951199611997119981199912000120011200212003120041200512006120071200812009120101201112012120131201412015120161201712018120191202012021120221202312024120251202612027120281202912030120311203212033120341203512036120371203812039120401204112042120431204412045120461204712048120491205012051120521205312054120551205612057120581205912060120611206212063120641206512066120671206812069120701207112072120731207412075120761207712078120791208012081120821208312084120851208612087120881208912090120911209212093120941209512096120971209812099121001210112102121031210412105121061210712108121091211012111121121211312114121151211612117121181211912120121211212212123121241212512126121271212812129121301213112132121331213412135121361213712138121391214012141121421214312144121451214612147121481214912150121511215212153121541215512156121571215812159121601216112162121631216412165121661216712168121691217012171121721217312174121751217612177121781217912180121811218212183121841218512186121871218812189121901219112192121931219412195121961219712198121991220012201122021220312204122051220612207122081220912210122111221212213122141221512216122171221812219122201222112222122231222412225122261222712228122291223012231122321223312234122351223612237122381223912240122411224212243122441224512246122471224812249122501225112252122531225412255122561225712258122591226012261122621226312264122651226612267122681226912270122711227212273122741227512276122771227812279122801228112282122831228412285122861228712288122891229012291122921229312294122951229612297122981229912300123011230212303123041230512306123071230812309123101231112312123131231412315123161231712318123191232012321123221232312324123251232612327123281232912330123311233212333123341233512336123371233812339123401234112342123431234412345123461234712348123491235012351123521235312354123551235612357123581235912360123611236212363123641236512366123671236812369123701237112372123731237412375123761237712378123791238012381123821238312384123851238612387123881238912390123911239212393123941239512396123971239812399124001240112402124031240412405124061240712408124091241012411124121241312414124151241612417124181241912420124211242212423124241242512426124271242812429124301243112432124331243412435124361243712438124391244012441124421244312444124451244612447124481244912450124511245212453124541245512456124571245812459124601246112462124631246412465124661246712468124691247012471124721247312474124751247612477124781247912480124811248212483124841248512486124871248812489124901249112492124931249412495124961249712498124991250012501125021250312504125051250612507125081250912510125111251212513125141251512516125171251812519125201252112522125231252412525125261252712528125291253012531125321253312534125351253612537125381253912540125411254212543125441254512546125471254812549125501255112552125531255412555125561255712558125591256012561125621256312564125651256612567125681256912570125711257212573125741257512576125771257812579125801258112582125831258412585125861258712588125891259012591125921259312594125951259612597125981259912600126011260212603126041260512606126071260812609126101261112612126131261412615126161261712618126191262012621126221262312624126251262612627126281262912630126311263212633126341263512636126371263812639126401264112642126431264412645126461264712648126491265012651126521265312654126551265612657126581265912660126611266212663126641266512666126671266812669126701267112672126731267412675126761267712678126791268012681126821268312684126851268612687126881268912690126911269212693126941269512696126971269812699127001270112702127031270412705127061270712708127091271012711127121271312714127151271612717127181271912720127211272212723127241272512726127271272812729127301273112732127331273412735127361273712738127391274012741127421274312744127451274612747127481274912750127511275212753127541275512756127571275812759127601276112762127631276412765127661276712768127691277012771127721277312774127751277612777127781277912780127811278212783127841278512786127871278812789127901279112792127931279412795127961279712798127991280012801128021280312804128051280612807128081280912810128111281212813128141281512816128171281812819128201282112822128231282412825128261282712828128291283012831128321283312834128351283612837128381283912840128411284212843128441284512846128471284812849128501285112852128531285412855128561285712858128591286012861128621286312864128651286612867128681286912870128711287212873128741287512876128771287812879128801288112882128831288412885128861288712888128891289012891128921289312894128951289612897128981289912900129011290212903129041290512906129071290812909129101291112912129131291412915129161291712918129191292012921129221292312924129251292612927129281292912930129311293212933129341293512936129371293812939129401294112942129431294412945129461294712948129491295012951129521295312954129551295612957129581295912960129611296212963129641296512966129671296812969129701297112972129731297412975129761297712978129791298012981129821298312984129851298612987129881298912990129911299212993129941299512996129971299812999130001300113002130031300413005130061300713008130091301013011130121301313014130151301613017130181301913020130211302213023130241302513026130271302813029130301303113032130331303413035130361303713038130391304013041130421304313044130451304613047130481304913050130511305213053130541305513056130571305813059130601306113062130631306413065130661306713068130691307013071130721307313074130751307613077130781307913080130811308213083130841308513086130871308813089130901309113092130931309413095130961309713098130991310013101131021310313104131051310613107131081310913110131111311213113131141311513116131171311813119131201312113122131231312413125131261312713128131291313013131131321313313134131351313613137131381313913140131411314213143131441314513146131471314813149131501315113152131531315413155131561315713158131591316013161131621316313164131651316613167131681316913170131711317213173131741317513176131771317813179131801318113182131831318413185131861318713188131891319013191131921319313194131951319613197131981319913200132011320213203132041320513206132071320813209132101321113212132131321413215132161321713218132191322013221132221322313224132251322613227132281322913230132311323213233132341323513236132371323813239132401324113242132431324413245132461324713248132491325013251132521325313254132551325613257132581325913260132611326213263132641326513266132671326813269132701327113272132731327413275132761327713278132791328013281132821328313284132851328613287132881328913290132911329213293132941329513296132971329813299133001330113302133031330413305133061330713308133091331013311133121331313314133151331613317133181331913320133211332213323133241332513326133271332813329133301333113332133331333413335133361333713338133391334013341133421334313344133451334613347133481334913350133511335213353133541335513356133571335813359133601336113362133631336413365133661336713368133691337013371133721337313374133751337613377133781337913380133811338213383133841338513386133871338813389133901339113392133931339413395133961339713398133991340013401134021340313404134051340613407134081340913410134111341213413134141341513416134171341813419134201342113422134231342413425134261342713428134291343013431134321343313434134351343613437134381343913440134411344213443134441344513446134471344813449134501345113452134531345413455134561345713458134591346013461134621346313464134651346613467134681346913470134711347213473134741347513476134771347813479134801348113482134831348413485134861348713488134891349013491134921349313494134951349613497134981349913500135011350213503135041350513506135071350813509135101351113512135131351413515135161351713518135191352013521135221352313524135251352613527135281352913530135311353213533135341353513536135371353813539135401354113542135431354413545135461354713548135491355013551135521355313554135551355613557135581355913560135611356213563135641356513566135671356813569135701357113572135731357413575135761357713578135791358013581135821358313584135851358613587135881358913590135911359213593135941359513596135971359813599136001360113602136031360413605136061360713608136091361013611136121361313614136151361613617136181361913620136211362213623136241362513626136271362813629136301363113632136331363413635136361363713638136391364013641136421364313644136451364613647136481364913650136511365213653136541365513656136571365813659136601366113662136631366413665136661366713668136691367013671136721367313674136751367613677136781367913680136811368213683136841368513686136871368813689136901369113692136931369413695136961369713698136991370013701137021370313704137051370613707137081370913710137111371213713137141371513716137171371813719137201372113722137231372413725137261372713728137291373013731137321373313734137351373613737137381373913740137411374213743137441374513746137471374813749137501375113752137531375413755137561375713758137591376013761137621376313764137651376613767137681376913770137711377213773137741377513776137771377813779137801378113782137831378413785137861378713788137891379013791137921379313794137951379613797137981379913800138011380213803138041380513806138071380813809138101381113812138131381413815138161381713818138191382013821138221382313824138251382613827138281382913830138311383213833138341383513836138371383813839138401384113842138431384413845138461384713848138491385013851138521385313854138551385613857138581385913860138611386213863138641386513866138671386813869138701387113872138731387413875138761387713878138791388013881138821388313884138851388613887138881388913890138911389213893138941389513896138971389813899139001390113902139031390413905139061390713908139091391013911139121391313914139151391613917139181391913920139211392213923139241392513926139271392813929139301393113932139331393413935139361393713938139391394013941139421394313944139451394613947139481394913950139511395213953139541395513956139571395813959139601396113962139631396413965139661396713968139691397013971139721397313974139751397613977139781397913980139811398213983139841398513986139871398813989139901399113992139931399413995139961399713998139991400014001140021400314004140051400614007140081400914010140111401214013140141401514016140171401814019140201402114022140231402414025140261402714028140291403014031140321403314034140351403614037140381403914040140411404214043140441404514046140471404814049140501405114052140531405414055140561405714058140591406014061140621406314064140651406614067140681406914070140711407214073140741407514076140771407814079140801408114082140831408414085140861408714088140891409014091140921409314094140951409614097140981409914100141011410214103141041410514106141071410814109141101411114112141131411414115141161411714118141191412014121141221412314124141251412614127141281412914130141311413214133141341413514136141371413814139141401414114142141431414414145141461414714148141491415014151141521415314154141551415614157141581415914160141611416214163141641416514166141671416814169141701417114172141731417414175141761417714178141791418014181141821418314184141851418614187141881418914190141911419214193141941419514196141971419814199142001420114202142031420414205142061420714208142091421014211142121421314214142151421614217142181421914220142211422214223142241422514226142271422814229142301423114232142331423414235142361423714238142391424014241142421424314244142451424614247142481424914250142511425214253142541425514256142571425814259142601426114262142631426414265142661426714268142691427014271142721427314274142751427614277142781427914280142811428214283142841428514286142871428814289142901429114292142931429414295142961429714298142991430014301143021430314304143051430614307143081430914310143111431214313143141431514316143171431814319143201432114322143231432414325143261432714328143291433014331143321433314334143351433614337143381433914340143411434214343143441434514346143471434814349143501435114352143531435414355143561435714358143591436014361143621436314364143651436614367143681436914370143711437214373143741437514376143771437814379143801438114382143831438414385143861438714388143891439014391143921439314394143951439614397143981439914400144011440214403144041440514406144071440814409144101441114412144131441414415144161441714418144191442014421144221442314424144251442614427144281442914430144311443214433144341443514436144371443814439144401444114442144431444414445144461444714448144491445014451144521445314454144551445614457144581445914460144611446214463144641446514466144671446814469144701447114472144731447414475144761447714478144791448014481144821448314484144851448614487144881448914490144911449214493144941449514496144971449814499145001450114502145031450414505145061450714508145091451014511145121451314514145151451614517145181451914520145211452214523145241452514526145271452814529145301453114532145331453414535145361453714538145391454014541145421454314544145451454614547145481454914550145511455214553145541455514556145571455814559145601456114562145631456414565145661456714568145691457014571145721457314574145751457614577145781457914580145811458214583145841458514586145871458814589145901459114592145931459414595145961459714598145991460014601146021460314604146051460614607146081460914610146111461214613146141461514616146171461814619146201462114622146231462414625146261462714628146291463014631146321463314634146351463614637146381463914640146411464214643146441464514646146471464814649146501465114652146531465414655146561465714658146591466014661146621466314664146651466614667146681466914670146711467214673146741467514676146771467814679146801468114682146831468414685146861468714688146891469014691146921469314694146951469614697146981469914700147011470214703147041470514706147071470814709147101471114712147131471414715147161471714718147191472014721147221472314724147251472614727147281472914730147311473214733147341473514736147371473814739147401474114742147431474414745147461474714748147491475014751147521475314754147551475614757147581475914760147611476214763147641476514766147671476814769147701477114772147731477414775147761477714778147791478014781147821478314784147851478614787147881478914790147911479214793147941479514796147971479814799148001480114802148031480414805148061480714808148091481014811148121481314814148151481614817148181481914820148211482214823148241482514826148271482814829148301483114832148331483414835148361483714838148391484014841148421484314844148451484614847148481484914850148511485214853148541485514856148571485814859148601486114862148631486414865148661486714868148691487014871148721487314874148751487614877148781487914880148811488214883148841488514886148871488814889148901489114892148931489414895148961489714898148991490014901149021490314904149051490614907149081490914910149111491214913149141491514916149171491814919149201492114922149231492414925149261492714928149291493014931149321493314934149351493614937149381493914940149411494214943149441494514946149471494814949149501495114952149531495414955149561495714958149591496014961149621496314964149651496614967149681496914970149711497214973149741497514976149771497814979149801498114982149831498414985149861498714988149891499014991149921499314994149951499614997149981499915000150011500215003150041500515006150071500815009150101501115012150131501415015150161501715018150191502015021150221502315024150251502615027150281502915030150311503215033150341503515036150371503815039150401504115042150431504415045150461504715048150491505015051150521505315054150551505615057150581505915060150611506215063150641506515066150671506815069150701507115072150731507415075150761507715078150791508015081150821508315084150851508615087150881508915090150911509215093150941509515096150971509815099151001510115102151031510415105151061510715108151091511015111151121511315114151151511615117151181511915120151211512215123151241512515126151271512815129151301513115132151331513415135151361513715138151391514015141151421514315144151451514615147151481514915150151511515215153151541515515156151571515815159151601516115162151631516415165151661516715168151691517015171151721517315174151751517615177151781517915180151811518215183151841518515186151871518815189151901519115192151931519415195151961519715198151991520015201152021520315204152051520615207152081520915210152111521215213152141521515216152171521815219152201522115222152231522415225152261522715228152291523015231152321523315234152351523615237152381523915240152411524215243152441524515246152471524815249152501525115252152531525415255152561525715258152591526015261152621526315264152651526615267152681526915270152711527215273152741527515276152771527815279152801528115282152831528415285152861528715288152891529015291152921529315294152951529615297152981529915300153011530215303153041530515306153071530815309153101531115312153131531415315153161531715318153191532015321153221532315324153251532615327153281532915330153311533215333153341533515336153371533815339153401534115342153431534415345153461534715348153491535015351153521535315354153551535615357153581535915360153611536215363153641536515366153671536815369153701537115372153731537415375153761537715378153791538015381153821538315384153851538615387153881538915390153911539215393153941539515396153971539815399154001540115402154031540415405154061540715408154091541015411154121541315414154151541615417154181541915420154211542215423154241542515426154271542815429154301543115432154331543415435154361543715438154391544015441154421544315444154451544615447154481544915450154511545215453154541545515456154571545815459154601546115462154631546415465154661546715468154691547015471154721547315474154751547615477154781547915480154811548215483154841548515486154871548815489154901549115492154931549415495154961549715498154991550015501155021550315504155051550615507155081550915510155111551215513155141551515516155171551815519155201552115522155231552415525155261552715528155291553015531155321553315534155351553615537155381553915540155411554215543155441554515546155471554815549155501555115552155531555415555155561555715558155591556015561155621556315564155651556615567155681556915570155711557215573155741557515576155771557815579155801558115582155831558415585155861558715588155891559015591155921559315594155951559615597155981559915600156011560215603156041560515606156071560815609156101561115612156131561415615156161561715618156191562015621156221562315624156251562615627156281562915630156311563215633156341563515636156371563815639156401564115642156431564415645156461564715648156491565015651156521565315654156551565615657156581565915660156611566215663156641566515666156671566815669156701567115672156731567415675156761567715678156791568015681156821568315684156851568615687156881568915690156911569215693156941569515696156971569815699157001570115702157031570415705157061570715708157091571015711157121571315714157151571615717157181571915720157211572215723157241572515726157271572815729157301573115732157331573415735157361573715738157391574015741157421574315744157451574615747157481574915750157511575215753157541575515756157571575815759157601576115762157631576415765157661576715768157691577015771157721577315774157751577615777157781577915780157811578215783157841578515786157871578815789157901579115792157931579415795157961579715798157991580015801158021580315804158051580615807158081580915810158111581215813158141581515816158171581815819158201582115822158231582415825158261582715828158291583015831158321583315834158351583615837158381583915840158411584215843158441584515846158471584815849158501585115852158531585415855158561585715858158591586015861158621586315864158651586615867158681586915870158711587215873158741587515876158771587815879158801588115882158831588415885158861588715888158891589015891158921589315894158951589615897158981589915900159011590215903159041590515906159071590815909159101591115912159131591415915159161591715918159191592015921159221592315924159251592615927159281592915930159311593215933159341593515936159371593815939159401594115942159431594415945159461594715948159491595015951159521595315954159551595615957159581595915960159611596215963159641596515966159671596815969159701597115972159731597415975159761597715978159791598015981159821598315984159851598615987159881598915990159911599215993159941599515996159971599815999160001600116002160031600416005160061600716008160091601016011160121601316014160151601616017160181601916020160211602216023160241602516026160271602816029160301603116032160331603416035160361603716038160391604016041160421604316044160451604616047160481604916050160511605216053160541605516056160571605816059160601606116062160631606416065160661606716068160691607016071160721607316074160751607616077160781607916080160811608216083160841608516086160871608816089160901609116092160931609416095160961609716098160991610016101161021610316104161051610616107161081610916110161111611216113161141611516116161171611816119161201612116122161231612416125161261612716128161291613016131161321613316134161351613616137161381613916140161411614216143161441614516146161471614816149161501615116152161531615416155161561615716158161591616016161161621616316164161651616616167161681616916170161711617216173161741617516176161771617816179161801618116182161831618416185161861618716188161891619016191161921619316194161951619616197161981619916200162011620216203162041620516206162071620816209162101621116212162131621416215162161621716218162191622016221162221622316224162251622616227162281622916230162311623216233162341623516236162371623816239162401624116242162431624416245162461624716248162491625016251162521625316254162551625616257162581625916260162611626216263162641626516266162671626816269162701627116272162731627416275162761627716278162791628016281162821628316284162851628616287162881628916290162911629216293162941629516296162971629816299163001630116302163031630416305163061630716308163091631016311163121631316314163151631616317163181631916320163211632216323163241632516326163271632816329163301633116332163331633416335163361633716338163391634016341163421634316344163451634616347163481634916350163511635216353163541635516356163571635816359163601636116362163631636416365163661636716368163691637016371163721637316374163751637616377163781637916380163811638216383163841638516386163871638816389163901639116392163931639416395163961639716398163991640016401164021640316404164051640616407164081640916410164111641216413164141641516416164171641816419164201642116422164231642416425164261642716428164291643016431164321643316434164351643616437164381643916440164411644216443164441644516446164471644816449164501645116452164531645416455164561645716458164591646016461164621646316464164651646616467164681646916470164711647216473164741647516476164771647816479164801648116482164831648416485164861648716488164891649016491164921649316494164951649616497164981649916500165011650216503165041650516506165071650816509165101651116512165131651416515165161651716518165191652016521165221652316524165251652616527165281652916530165311653216533165341653516536165371653816539165401654116542165431654416545165461654716548165491655016551165521655316554165551655616557165581655916560165611656216563165641656516566165671656816569165701657116572165731657416575165761657716578165791658016581165821658316584165851658616587165881658916590165911659216593165941659516596165971659816599166001660116602166031660416605166061660716608166091661016611166121661316614166151661616617166181661916620166211662216623166241662516626166271662816629166301663116632166331663416635166361663716638166391664016641166421664316644166451664616647166481664916650166511665216653166541665516656166571665816659166601666116662166631666416665166661666716668166691667016671166721667316674166751667616677166781667916680166811668216683166841668516686166871668816689166901669116692166931669416695166961669716698166991670016701167021670316704167051670616707167081670916710167111671216713167141671516716167171671816719167201672116722167231672416725167261672716728167291673016731167321673316734167351673616737167381673916740167411674216743167441674516746167471674816749167501675116752167531675416755167561675716758167591676016761167621676316764167651676616767167681676916770167711677216773167741677516776167771677816779167801678116782167831678416785167861678716788167891679016791167921679316794167951679616797167981679916800168011680216803168041680516806168071680816809168101681116812168131681416815168161681716818168191682016821168221682316824168251682616827168281682916830168311683216833168341683516836168371683816839168401684116842168431684416845168461684716848168491685016851168521685316854168551685616857168581685916860168611686216863168641686516866168671686816869168701687116872168731687416875168761687716878168791688016881168821688316884168851688616887168881688916890168911689216893168941689516896168971689816899169001690116902169031690416905169061690716908169091691016911169121691316914169151691616917169181691916920169211692216923169241692516926169271692816929169301693116932169331693416935169361693716938169391694016941169421694316944169451694616947169481694916950169511695216953169541695516956169571695816959169601696116962169631696416965169661696716968169691697016971169721697316974169751697616977169781697916980169811698216983169841698516986169871698816989169901699116992169931699416995169961699716998169991700017001170021700317004170051700617007170081700917010170111701217013170141701517016170171701817019170201702117022170231702417025170261702717028170291703017031170321703317034170351703617037170381703917040170411704217043170441704517046170471704817049170501705117052170531705417055170561705717058170591706017061170621706317064170651706617067170681706917070170711707217073170741707517076170771707817079170801708117082170831708417085170861708717088170891709017091170921709317094170951709617097170981709917100171011710217103171041710517106171071710817109171101711117112171131711417115171161711717118171191712017121171221712317124171251712617127171281712917130171311713217133171341713517136171371713817139171401714117142171431714417145171461714717148171491715017151171521715317154171551715617157171581715917160171611716217163171641716517166171671716817169171701717117172171731717417175171761717717178171791718017181171821718317184171851718617187171881718917190171911719217193171941719517196171971719817199172001720117202172031720417205172061720717208172091721017211172121721317214172151721617217172181721917220172211722217223172241722517226172271722817229172301723117232172331723417235172361723717238172391724017241172421724317244172451724617247172481724917250172511725217253172541725517256172571725817259172601726117262172631726417265172661726717268172691727017271172721727317274172751727617277172781727917280172811728217283172841728517286172871728817289172901729117292172931729417295172961729717298172991730017301173021730317304173051730617307173081730917310173111731217313173141731517316173171731817319173201732117322173231732417325173261732717328173291733017331173321733317334173351733617337173381733917340173411734217343173441734517346173471734817349173501735117352173531735417355173561735717358173591736017361173621736317364173651736617367173681736917370173711737217373173741737517376173771737817379173801738117382173831738417385173861738717388173891739017391173921739317394173951739617397173981739917400174011740217403174041740517406174071740817409174101741117412174131741417415174161741717418174191742017421174221742317424174251742617427174281742917430174311743217433174341743517436174371743817439174401744117442174431744417445174461744717448174491745017451174521745317454174551745617457174581745917460174611746217463174641746517466174671746817469174701747117472174731747417475174761747717478174791748017481174821748317484174851748617487174881748917490174911749217493174941749517496174971749817499175001750117502175031750417505175061750717508175091751017511175121751317514175151751617517175181751917520175211752217523175241752517526175271752817529175301753117532175331753417535175361753717538175391754017541175421754317544175451754617547175481754917550175511755217553175541755517556175571755817559175601756117562175631756417565175661756717568175691757017571175721757317574175751757617577175781757917580175811758217583175841758517586175871758817589175901759117592175931759417595175961759717598175991760017601176021760317604176051760617607176081760917610176111761217613176141761517616176171761817619176201762117622176231762417625176261762717628176291763017631176321763317634176351763617637176381763917640176411764217643176441764517646176471764817649176501765117652176531765417655176561765717658176591766017661176621766317664176651766617667176681766917670176711767217673176741767517676176771767817679176801768117682176831768417685176861768717688176891769017691176921769317694176951769617697176981769917700177011770217703177041770517706177071770817709177101771117712177131771417715177161771717718177191772017721177221772317724177251772617727177281772917730177311773217733177341773517736177371773817739177401774117742177431774417745177461774717748177491775017751177521775317754177551775617757177581775917760177611776217763177641776517766177671776817769177701777117772177731777417775177761777717778177791778017781177821778317784177851778617787177881778917790177911779217793177941779517796177971779817799178001780117802178031780417805178061780717808178091781017811178121781317814178151781617817178181781917820178211782217823178241782517826178271782817829178301783117832178331783417835178361783717838178391784017841178421784317844178451784617847178481784917850178511785217853178541785517856178571785817859178601786117862178631786417865178661786717868178691787017871178721787317874178751787617877178781787917880178811788217883178841788517886178871788817889178901789117892178931789417895178961789717898178991790017901179021790317904179051790617907179081790917910179111791217913179141791517916179171791817919179201792117922179231792417925179261792717928179291793017931179321793317934179351793617937179381793917940179411794217943179441794517946179471794817949179501795117952179531795417955179561795717958179591796017961179621796317964179651796617967179681796917970179711797217973179741797517976179771797817979179801798117982179831798417985179861798717988179891799017991179921799317994179951799617997179981799918000180011800218003180041800518006180071800818009180101801118012180131801418015180161801718018180191802018021180221802318024180251802618027180281802918030180311803218033180341803518036180371803818039180401804118042180431804418045180461804718048180491805018051180521805318054180551805618057180581805918060180611806218063180641806518066180671806818069180701807118072180731807418075180761807718078180791808018081180821808318084180851808618087180881808918090180911809218093180941809518096180971809818099181001810118102181031810418105181061810718108181091811018111181121811318114181151811618117181181811918120181211812218123181241812518126181271812818129181301813118132181331813418135181361813718138181391814018141181421814318144181451814618147181481814918150181511815218153181541815518156181571815818159181601816118162181631816418165181661816718168181691817018171181721817318174181751817618177181781817918180181811818218183181841818518186181871818818189181901819118192181931819418195181961819718198181991820018201182021820318204182051820618207182081820918210182111821218213182141821518216182171821818219182201822118222182231822418225182261822718228182291823018231182321823318234182351823618237182381823918240182411824218243182441824518246182471824818249182501825118252182531825418255182561825718258182591826018261182621826318264182651826618267182681826918270182711827218273182741827518276182771827818279182801828118282182831828418285182861828718288182891829018291182921829318294182951829618297182981829918300183011830218303183041830518306183071830818309183101831118312183131831418315183161831718318183191832018321183221832318324183251832618327183281832918330183311833218333183341833518336183371833818339183401834118342183431834418345183461834718348183491835018351183521835318354183551835618357183581835918360183611836218363183641836518366183671836818369183701837118372183731837418375183761837718378183791838018381183821838318384183851838618387183881838918390183911839218393183941839518396183971839818399184001840118402184031840418405184061840718408184091841018411184121841318414184151841618417184181841918420184211842218423184241842518426184271842818429184301843118432184331843418435184361843718438184391844018441184421844318444184451844618447184481844918450184511845218453184541845518456184571845818459184601846118462184631846418465184661846718468184691847018471184721847318474184751847618477184781847918480184811848218483184841848518486184871848818489184901849118492184931849418495184961849718498184991850018501185021850318504185051850618507185081850918510185111851218513185141851518516185171851818519185201852118522185231852418525185261852718528185291853018531185321853318534185351853618537185381853918540185411854218543185441854518546185471854818549185501855118552185531855418555185561855718558185591856018561185621856318564185651856618567185681856918570185711857218573185741857518576185771857818579185801858118582185831858418585185861858718588185891859018591185921859318594185951859618597185981859918600186011860218603186041860518606186071860818609186101861118612186131861418615186161861718618186191862018621186221862318624186251862618627186281862918630186311863218633186341863518636186371863818639186401864118642186431864418645186461864718648186491865018651186521865318654186551865618657186581865918660186611866218663186641866518666186671866818669186701867118672186731867418675186761867718678186791868018681186821868318684186851868618687186881868918690186911869218693186941869518696186971869818699187001870118702187031870418705187061870718708187091871018711187121871318714187151871618717187181871918720187211872218723187241872518726187271872818729187301873118732187331873418735187361873718738187391874018741187421874318744187451874618747187481874918750187511875218753187541875518756187571875818759187601876118762187631876418765187661876718768187691877018771187721877318774187751877618777187781877918780187811878218783187841878518786187871878818789187901879118792187931879418795187961879718798187991880018801188021880318804188051880618807188081880918810188111881218813188141881518816188171881818819188201882118822188231882418825188261882718828188291883018831188321883318834188351883618837188381883918840188411884218843188441884518846188471884818849188501885118852188531885418855188561885718858188591886018861188621886318864188651886618867188681886918870188711887218873188741887518876188771887818879188801888118882188831888418885188861888718888188891889018891188921889318894188951889618897188981889918900189011890218903189041890518906189071890818909189101891118912189131891418915189161891718918189191892018921189221892318924189251892618927189281892918930189311893218933189341893518936189371893818939189401894118942189431894418945189461894718948189491895018951189521895318954189551895618957189581895918960189611896218963189641896518966189671896818969189701897118972189731897418975189761897718978189791898018981189821898318984189851898618987189881898918990189911899218993189941899518996189971899818999190001900119002190031900419005190061900719008190091901019011190121901319014190151901619017190181901919020190211902219023190241902519026190271902819029190301903119032190331903419035190361903719038190391904019041190421904319044190451904619047190481904919050190511905219053190541905519056190571905819059190601906119062190631906419065190661906719068190691907019071190721907319074190751907619077190781907919080190811908219083190841908519086190871908819089190901909119092190931909419095190961909719098190991910019101191021910319104191051910619107191081910919110191111911219113191141911519116191171911819119191201912119122191231912419125191261912719128191291913019131191321913319134191351913619137191381913919140191411914219143191441914519146191471914819149191501915119152191531915419155191561915719158191591916019161191621916319164191651916619167191681916919170191711917219173191741917519176191771917819179191801918119182191831918419185191861918719188191891919019191191921919319194191951919619197191981919919200192011920219203192041920519206192071920819209192101921119212192131921419215192161921719218192191922019221192221922319224192251922619227192281922919230192311923219233192341923519236192371923819239192401924119242192431924419245192461924719248192491925019251192521925319254192551925619257192581925919260192611926219263192641926519266192671926819269192701927119272192731927419275192761927719278192791928019281192821928319284192851928619287192881928919290192911929219293192941929519296192971929819299193001930119302193031930419305193061930719308193091931019311193121931319314193151931619317193181931919320193211932219323193241932519326193271932819329193301933119332193331933419335193361933719338193391934019341193421934319344193451934619347193481934919350193511935219353193541935519356193571935819359193601936119362193631936419365193661936719368193691937019371193721937319374193751937619377193781937919380193811938219383193841938519386193871938819389193901939119392193931939419395193961939719398193991940019401194021940319404194051940619407194081940919410194111941219413194141941519416194171941819419194201942119422194231942419425194261942719428194291943019431194321943319434194351943619437194381943919440194411944219443194441944519446194471944819449194501945119452194531945419455194561945719458194591946019461194621946319464194651946619467194681946919470194711947219473194741947519476194771947819479194801948119482194831948419485194861948719488194891949019491194921949319494194951949619497194981949919500195011950219503195041950519506195071950819509195101951119512195131951419515195161951719518195191952019521195221952319524195251952619527195281952919530195311953219533195341953519536195371953819539195401954119542195431954419545195461954719548195491955019551195521955319554195551955619557195581955919560195611956219563195641956519566195671956819569195701957119572195731957419575195761957719578195791958019581195821958319584195851958619587195881958919590195911959219593195941959519596195971959819599196001960119602196031960419605196061960719608196091961019611196121961319614196151961619617196181961919620196211962219623196241962519626196271962819629196301963119632196331963419635196361963719638196391964019641196421964319644196451964619647196481964919650196511965219653196541965519656196571965819659196601966119662196631966419665196661966719668196691967019671196721967319674196751967619677196781967919680196811968219683196841968519686196871968819689196901969119692196931969419695196961969719698196991970019701197021970319704197051970619707197081970919710197111971219713197141971519716197171971819719197201972119722197231972419725197261972719728197291973019731197321973319734197351973619737197381973919740197411974219743197441974519746197471974819749197501975119752197531975419755197561975719758197591976019761197621976319764197651976619767197681976919770197711977219773197741977519776197771977819779197801978119782197831978419785197861978719788197891979019791197921979319794197951979619797197981979919800198011980219803198041980519806198071980819809198101981119812198131981419815198161981719818198191982019821198221982319824198251982619827198281982919830198311983219833198341983519836198371983819839198401984119842198431984419845198461984719848198491985019851198521985319854198551985619857198581985919860198611986219863198641986519866198671986819869198701987119872198731987419875198761987719878198791988019881198821988319884198851988619887198881988919890198911989219893198941989519896198971989819899199001990119902199031990419905199061990719908199091991019911199121991319914199151991619917199181991919920199211992219923199241992519926199271992819929199301993119932199331993419935199361993719938199391994019941199421994319944199451994619947199481994919950199511995219953199541995519956199571995819959199601996119962199631996419965199661996719968199691997019971199721997319974199751997619977199781997919980199811998219983199841998519986199871998819989199901999119992199931999419995199961999719998199992000020001200022000320004200052000620007200082000920010200112001220013200142001520016200172001820019200202002120022200232002420025200262002720028200292003020031200322003320034200352003620037200382003920040200412004220043200442004520046200472004820049200502005120052200532005420055200562005720058200592006020061200622006320064200652006620067200682006920070200712007220073200742007520076200772007820079200802008120082200832008420085200862008720088200892009020091200922009320094200952009620097200982009920100201012010220103201042010520106201072010820109201102011120112201132011420115201162011720118201192012020121201222012320124201252012620127201282012920130201312013220133201342013520136201372013820139201402014120142201432014420145201462014720148201492015020151201522015320154201552015620157201582015920160201612016220163201642016520166201672016820169201702017120172201732017420175201762017720178201792018020181201822018320184201852018620187201882018920190201912019220193201942019520196201972019820199202002020120202202032020420205202062020720208202092021020211202122021320214202152021620217202182021920220202212022220223202242022520226202272022820229202302023120232202332023420235202362023720238202392024020241202422024320244202452024620247202482024920250202512025220253202542025520256202572025820259202602026120262202632026420265202662026720268202692027020271202722027320274202752027620277202782027920280202812028220283202842028520286202872028820289202902029120292202932029420295202962029720298202992030020301203022030320304203052030620307203082030920310203112031220313203142031520316203172031820319203202032120322203232032420325203262032720328203292033020331203322033320334203352033620337203382033920340203412034220343203442034520346203472034820349203502035120352203532035420355203562035720358203592036020361203622036320364203652036620367203682036920370203712037220373203742037520376203772037820379203802038120382203832038420385203862038720388203892039020391203922039320394203952039620397203982039920400204012040220403204042040520406204072040820409204102041120412204132041420415204162041720418204192042020421204222042320424204252042620427204282042920430204312043220433204342043520436204372043820439204402044120442204432044420445204462044720448204492045020451204522045320454204552045620457204582045920460204612046220463204642046520466204672046820469204702047120472204732047420475204762047720478204792048020481204822048320484204852048620487204882048920490204912049220493204942049520496204972049820499205002050120502205032050420505205062050720508205092051020511205122051320514205152051620517205182051920520205212052220523205242052520526205272052820529205302053120532205332053420535205362053720538205392054020541205422054320544205452054620547205482054920550205512055220553205542055520556205572055820559205602056120562205632056420565205662056720568205692057020571205722057320574205752057620577205782057920580205812058220583205842058520586205872058820589205902059120592205932059420595205962059720598205992060020601206022060320604206052060620607206082060920610206112061220613206142061520616206172061820619206202062120622206232062420625206262062720628206292063020631206322063320634206352063620637206382063920640206412064220643206442064520646206472064820649206502065120652206532065420655206562065720658206592066020661206622066320664206652066620667206682066920670206712067220673206742067520676206772067820679206802068120682206832068420685206862068720688206892069020691206922069320694206952069620697206982069920700207012070220703207042070520706207072070820709207102071120712207132071420715207162071720718207192072020721207222072320724207252072620727207282072920730207312073220733207342073520736207372073820739207402074120742207432074420745207462074720748207492075020751207522075320754207552075620757207582075920760207612076220763207642076520766207672076820769207702077120772207732077420775207762077720778207792078020781207822078320784207852078620787207882078920790207912079220793207942079520796207972079820799208002080120802208032080420805208062080720808208092081020811208122081320814208152081620817208182081920820208212082220823208242082520826208272082820829208302083120832208332083420835208362083720838208392084020841208422084320844208452084620847208482084920850208512085220853208542085520856208572085820859208602086120862208632086420865208662086720868208692087020871208722087320874208752087620877208782087920880208812088220883208842088520886208872088820889208902089120892208932089420895208962089720898208992090020901209022090320904209052090620907209082090920910209112091220913209142091520916209172091820919209202092120922209232092420925209262092720928209292093020931209322093320934209352093620937209382093920940209412094220943209442094520946209472094820949209502095120952209532095420955209562095720958209592096020961209622096320964209652096620967209682096920970209712097220973209742097520976209772097820979209802098120982209832098420985209862098720988209892099020991209922099320994209952099620997209982099921000210012100221003210042100521006210072100821009210102101121012210132101421015210162101721018210192102021021210222102321024210252102621027210282102921030210312103221033210342103521036210372103821039210402104121042210432104421045210462104721048210492105021051210522105321054210552105621057210582105921060210612106221063210642106521066210672106821069210702107121072210732107421075210762107721078210792108021081210822108321084210852108621087210882108921090210912109221093210942109521096210972109821099211002110121102211032110421105211062110721108211092111021111211122111321114211152111621117211182111921120211212112221123211242112521126211272112821129211302113121132211332113421135211362113721138211392114021141211422114321144211452114621147211482114921150211512115221153211542115521156211572115821159211602116121162211632116421165211662116721168211692117021171211722117321174211752117621177211782117921180211812118221183211842118521186211872118821189211902119121192211932119421195211962119721198211992120021201212022120321204212052120621207212082120921210212112121221213212142121521216212172121821219212202122121222212232122421225212262122721228212292123021231212322123321234212352123621237212382123921240212412124221243212442124521246212472124821249212502125121252212532125421255212562125721258212592126021261212622126321264212652126621267212682126921270212712127221273212742127521276212772127821279212802128121282212832128421285212862128721288212892129021291212922129321294212952129621297212982129921300213012130221303213042130521306213072130821309213102131121312213132131421315213162131721318213192132021321213222132321324213252132621327213282132921330213312133221333213342133521336213372133821339213402134121342213432134421345213462134721348213492135021351213522135321354213552135621357213582135921360213612136221363213642136521366213672136821369213702137121372213732137421375213762137721378213792138021381213822138321384213852138621387213882138921390213912139221393213942139521396213972139821399214002140121402214032140421405214062140721408214092141021411214122141321414214152141621417214182141921420214212142221423214242142521426214272142821429214302143121432214332143421435214362143721438214392144021441214422144321444214452144621447214482144921450214512145221453214542145521456214572145821459214602146121462214632146421465214662146721468214692147021471214722147321474214752147621477214782147921480214812148221483214842148521486214872148821489214902149121492214932149421495214962149721498214992150021501215022150321504215052150621507215082150921510215112151221513215142151521516215172151821519215202152121522215232152421525215262152721528215292153021531215322153321534215352153621537215382153921540215412154221543215442154521546215472154821549215502155121552215532155421555215562155721558215592156021561215622156321564215652156621567215682156921570215712157221573215742157521576215772157821579215802158121582215832158421585215862158721588215892159021591215922159321594215952159621597215982159921600216012160221603216042160521606216072160821609216102161121612216132161421615216162161721618216192162021621216222162321624216252162621627216282162921630216312163221633216342163521636216372163821639216402164121642216432164421645216462164721648216492165021651216522165321654216552165621657216582165921660216612166221663216642166521666216672166821669216702167121672216732167421675216762167721678216792168021681216822168321684216852168621687216882168921690216912169221693216942169521696216972169821699217002170121702217032170421705217062170721708217092171021711217122171321714217152171621717217182171921720217212172221723217242172521726217272172821729217302173121732217332173421735217362173721738217392174021741217422174321744217452174621747217482174921750217512175221753217542175521756217572175821759217602176121762217632176421765217662176721768217692177021771217722177321774217752177621777217782177921780217812178221783217842178521786217872178821789217902179121792217932179421795217962179721798217992180021801218022180321804218052180621807218082180921810218112181221813218142181521816218172181821819218202182121822218232182421825218262182721828218292183021831218322183321834218352183621837218382183921840218412184221843218442184521846218472184821849218502185121852218532185421855218562185721858218592186021861218622186321864218652186621867218682186921870218712187221873218742187521876218772187821879218802188121882218832188421885218862188721888218892189021891218922189321894218952189621897218982189921900219012190221903219042190521906219072190821909219102191121912219132191421915219162191721918219192192021921219222192321924219252192621927219282192921930219312193221933219342193521936219372193821939219402194121942219432194421945219462194721948219492195021951219522195321954219552195621957219582195921960219612196221963219642196521966219672196821969219702197121972219732197421975219762197721978219792198021981219822198321984219852198621987219882198921990219912199221993219942199521996219972199821999220002200122002220032200422005220062200722008220092201022011220122201322014220152201622017220182201922020220212202222023220242202522026220272202822029220302203122032220332203422035220362203722038220392204022041220422204322044220452204622047220482204922050220512205222053220542205522056220572205822059220602206122062220632206422065220662206722068220692207022071220722207322074220752207622077220782207922080220812208222083220842208522086220872208822089220902209122092220932209422095220962209722098220992210022101221022210322104221052210622107221082210922110221112211222113221142211522116221172211822119221202212122122221232212422125221262212722128221292213022131221322213322134221352213622137221382213922140221412214222143221442214522146221472214822149221502215122152221532215422155221562215722158221592216022161221622216322164221652216622167221682216922170221712217222173221742217522176221772217822179221802218122182221832218422185221862218722188221892219022191221922219322194221952219622197221982219922200222012220222203222042220522206222072220822209222102221122212222132221422215222162221722218222192222022221222222222322224222252222622227222282222922230222312223222233222342223522236222372223822239222402224122242222432224422245222462224722248222492225022251222522225322254222552225622257222582225922260222612226222263222642226522266222672226822269222702227122272222732227422275222762227722278222792228022281222822228322284222852228622287222882228922290222912229222293222942229522296222972229822299223002230122302223032230422305223062230722308223092231022311223122231322314223152231622317223182231922320223212232222323223242232522326223272232822329223302233122332223332233422335223362233722338223392234022341223422234322344223452234622347223482234922350223512235222353223542235522356223572235822359223602236122362223632236422365223662236722368223692237022371223722237322374223752237622377223782237922380223812238222383223842238522386223872238822389223902239122392223932239422395223962239722398223992240022401224022240322404224052240622407224082240922410224112241222413224142241522416224172241822419224202242122422224232242422425224262242722428224292243022431224322243322434224352243622437224382243922440224412244222443224442244522446224472244822449224502245122452224532245422455224562245722458224592246022461224622246322464224652246622467224682246922470224712247222473224742247522476224772247822479224802248122482224832248422485224862248722488224892249022491224922249322494224952249622497224982249922500225012250222503225042250522506225072250822509225102251122512225132251422515225162251722518225192252022521225222252322524225252252622527225282252922530225312253222533225342253522536225372253822539225402254122542225432254422545225462254722548225492255022551225522255322554225552255622557225582255922560225612256222563225642256522566225672256822569225702257122572225732257422575225762257722578225792258022581225822258322584225852258622587225882258922590225912259222593225942259522596225972259822599226002260122602226032260422605226062260722608226092261022611226122261322614226152261622617226182261922620226212262222623226242262522626226272262822629226302263122632226332263422635226362263722638226392264022641226422264322644226452264622647226482264922650226512265222653226542265522656226572265822659226602266122662226632266422665226662266722668226692267022671226722267322674226752267622677226782267922680226812268222683226842268522686226872268822689226902269122692226932269422695226962269722698226992270022701227022270322704227052270622707227082270922710227112271222713227142271522716227172271822719227202272122722227232272422725227262272722728227292273022731227322273322734227352273622737227382273922740227412274222743227442274522746227472274822749227502275122752227532275422755227562275722758227592276022761227622276322764227652276622767227682276922770227712277222773227742277522776227772277822779227802278122782227832278422785227862278722788227892279022791227922279322794227952279622797227982279922800228012280222803228042280522806228072280822809228102281122812228132281422815228162281722818228192282022821228222282322824228252282622827228282282922830228312283222833228342283522836228372283822839228402284122842228432284422845228462284722848228492285022851228522285322854228552285622857228582285922860228612286222863228642286522866228672286822869228702287122872228732287422875228762287722878228792288022881228822288322884228852288622887228882288922890228912289222893228942289522896228972289822899229002290122902229032290422905229062290722908229092291022911229122291322914229152291622917229182291922920229212292222923229242292522926229272292822929229302293122932229332293422935229362293722938229392294022941229422294322944229452294622947229482294922950229512295222953229542295522956229572295822959229602296122962229632296422965229662296722968229692297022971229722297322974229752297622977229782297922980229812298222983229842298522986229872298822989229902299122992229932299422995229962299722998229992300023001230022300323004230052300623007230082300923010230112301223013230142301523016230172301823019230202302123022230232302423025230262302723028230292303023031230322303323034230352303623037230382303923040230412304223043230442304523046230472304823049230502305123052230532305423055230562305723058230592306023061230622306323064230652306623067230682306923070230712307223073230742307523076230772307823079230802308123082230832308423085230862308723088230892309023091230922309323094230952309623097230982309923100231012310223103231042310523106231072310823109231102311123112231132311423115231162311723118231192312023121231222312323124231252312623127231282312923130231312313223133231342313523136231372313823139231402314123142231432314423145231462314723148231492315023151231522315323154231552315623157231582315923160231612316223163231642316523166231672316823169231702317123172231732317423175231762317723178231792318023181231822318323184231852318623187231882318923190231912319223193231942319523196231972319823199232002320123202232032320423205232062320723208232092321023211232122321323214232152321623217232182321923220232212322223223232242322523226232272322823229232302323123232232332323423235232362323723238232392324023241232422324323244232452324623247232482324923250232512325223253232542325523256232572325823259232602326123262232632326423265232662326723268232692327023271232722327323274232752327623277232782327923280232812328223283232842328523286232872328823289232902329123292232932329423295232962329723298232992330023301233022330323304233052330623307233082330923310233112331223313233142331523316233172331823319233202332123322233232332423325233262332723328233292333023331233322333323334233352333623337233382333923340233412334223343233442334523346233472334823349233502335123352233532335423355233562335723358233592336023361233622336323364233652336623367233682336923370233712337223373233742337523376233772337823379233802338123382233832338423385233862338723388233892339023391233922339323394233952339623397233982339923400234012340223403234042340523406234072340823409234102341123412234132341423415234162341723418234192342023421234222342323424234252342623427234282342923430234312343223433234342343523436234372343823439234402344123442234432344423445234462344723448234492345023451234522345323454234552345623457234582345923460234612346223463234642346523466234672346823469234702347123472234732347423475234762347723478234792348023481234822348323484234852348623487234882348923490234912349223493234942349523496234972349823499235002350123502235032350423505235062350723508235092351023511235122351323514235152351623517235182351923520235212352223523235242352523526235272352823529235302353123532235332353423535235362353723538235392354023541235422354323544235452354623547235482354923550235512355223553235542355523556235572355823559235602356123562235632356423565235662356723568235692357023571235722357323574235752357623577235782357923580235812358223583235842358523586235872358823589235902359123592235932359423595235962359723598235992360023601236022360323604236052360623607236082360923610236112361223613236142361523616236172361823619236202362123622236232362423625236262362723628236292363023631236322363323634236352363623637236382363923640236412364223643236442364523646236472364823649236502365123652236532365423655236562365723658236592366023661236622366323664236652366623667236682366923670236712367223673236742367523676236772367823679236802368123682236832368423685236862368723688236892369023691236922369323694236952369623697236982369923700237012370223703237042370523706237072370823709237102371123712237132371423715237162371723718237192372023721237222372323724237252372623727237282372923730237312373223733237342373523736237372373823739237402374123742237432374423745237462374723748237492375023751237522375323754237552375623757237582375923760237612376223763237642376523766237672376823769237702377123772237732377423775237762377723778237792378023781237822378323784237852378623787237882378923790237912379223793237942379523796237972379823799238002380123802238032380423805238062380723808238092381023811238122381323814238152381623817238182381923820238212382223823238242382523826238272382823829238302383123832238332383423835238362383723838238392384023841238422384323844238452384623847238482384923850238512385223853238542385523856238572385823859238602386123862238632386423865238662386723868238692387023871238722387323874238752387623877238782387923880238812388223883238842388523886238872388823889238902389123892238932389423895238962389723898238992390023901239022390323904239052390623907239082390923910239112391223913239142391523916239172391823919239202392123922239232392423925239262392723928239292393023931239322393323934239352393623937239382393923940239412394223943239442394523946239472394823949239502395123952239532395423955239562395723958239592396023961239622396323964239652396623967239682396923970239712397223973239742397523976239772397823979239802398123982239832398423985239862398723988239892399023991239922399323994239952399623997239982399924000240012400224003240042400524006240072400824009240102401124012240132401424015240162401724018240192402024021240222402324024240252402624027240282402924030240312403224033240342403524036240372403824039240402404124042240432404424045240462404724048240492405024051240522405324054240552405624057240582405924060240612406224063240642406524066240672406824069240702407124072240732407424075240762407724078240792408024081240822408324084240852408624087240882408924090240912409224093240942409524096240972409824099241002410124102241032410424105241062410724108241092411024111241122411324114241152411624117241182411924120241212412224123241242412524126241272412824129241302413124132241332413424135241362413724138241392414024141241422414324144241452414624147241482414924150241512415224153241542415524156241572415824159241602416124162241632416424165241662416724168241692417024171241722417324174241752417624177241782417924180241812418224183241842418524186241872418824189241902419124192241932419424195241962419724198241992420024201242022420324204242052420624207242082420924210242112421224213242142421524216242172421824219242202422124222242232422424225242262422724228242292423024231242322423324234242352423624237242382423924240242412424224243242442424524246242472424824249242502425124252242532425424255242562425724258242592426024261242622426324264242652426624267242682426924270242712427224273242742427524276242772427824279242802428124282242832428424285242862428724288242892429024291242922429324294242952429624297242982429924300243012430224303243042430524306243072430824309243102431124312243132431424315243162431724318243192432024321243222432324324243252432624327243282432924330243312433224333243342433524336243372433824339243402434124342243432434424345243462434724348243492435024351243522435324354243552435624357243582435924360243612436224363243642436524366243672436824369243702437124372243732437424375243762437724378243792438024381243822438324384243852438624387243882438924390243912439224393243942439524396243972439824399244002440124402244032440424405244062440724408244092441024411244122441324414244152441624417244182441924420244212442224423244242442524426244272442824429244302443124432244332443424435244362443724438244392444024441244422444324444244452444624447244482444924450244512445224453244542445524456244572445824459244602446124462244632446424465244662446724468244692447024471244722447324474244752447624477244782447924480244812448224483244842448524486244872448824489244902449124492244932449424495244962449724498244992450024501245022450324504245052450624507245082450924510245112451224513245142451524516245172451824519245202452124522245232452424525245262452724528245292453024531245322453324534245352453624537245382453924540245412454224543245442454524546245472454824549245502455124552245532455424555245562455724558245592456024561245622456324564245652456624567245682456924570245712457224573245742457524576245772457824579245802458124582245832458424585245862458724588245892459024591245922459324594245952459624597245982459924600246012460224603246042460524606246072460824609246102461124612246132461424615246162461724618246192462024621246222462324624246252462624627246282462924630246312463224633246342463524636246372463824639246402464124642246432464424645246462464724648246492465024651246522465324654246552465624657246582465924660246612466224663246642466524666246672466824669246702467124672246732467424675246762467724678246792468024681246822468324684246852468624687246882468924690246912469224693246942469524696246972469824699247002470124702247032470424705247062470724708247092471024711247122471324714247152471624717247182471924720247212472224723247242472524726247272472824729247302473124732247332473424735247362473724738247392474024741247422474324744247452474624747247482474924750247512475224753247542475524756247572475824759247602476124762247632476424765247662476724768247692477024771247722477324774247752477624777247782477924780247812478224783247842478524786247872478824789247902479124792247932479424795247962479724798247992480024801248022480324804248052480624807248082480924810248112481224813248142481524816248172481824819248202482124822248232482424825248262482724828248292483024831248322483324834248352483624837248382483924840248412484224843248442484524846248472484824849248502485124852248532485424855248562485724858248592486024861248622486324864248652486624867248682486924870248712487224873248742487524876248772487824879248802488124882248832488424885248862488724888248892489024891248922489324894248952489624897248982489924900249012490224903249042490524906249072490824909249102491124912249132491424915249162491724918249192492024921249222492324924249252492624927249282492924930249312493224933249342493524936249372493824939249402494124942249432494424945249462494724948249492495024951249522495324954249552495624957249582495924960249612496224963249642496524966249672496824969249702497124972249732497424975249762497724978249792498024981249822498324984249852498624987249882498924990249912499224993249942499524996249972499824999250002500125002250032500425005250062500725008250092501025011250122501325014250152501625017250182501925020250212502225023250242502525026250272502825029250302503125032250332503425035250362503725038250392504025041250422504325044250452504625047250482504925050250512505225053250542505525056250572505825059250602506125062250632506425065250662506725068250692507025071250722507325074250752507625077250782507925080250812508225083250842508525086250872508825089250902509125092250932509425095250962509725098250992510025101251022510325104251052510625107251082510925110251112511225113251142511525116251172511825119251202512125122251232512425125251262512725128251292513025131251322513325134251352513625137251382513925140251412514225143251442514525146251472514825149251502515125152251532515425155251562515725158251592516025161251622516325164251652516625167251682516925170251712517225173251742517525176251772517825179251802518125182251832518425185251862518725188251892519025191251922519325194251952519625197251982519925200252012520225203252042520525206252072520825209252102521125212252132521425215252162521725218252192522025221252222522325224252252522625227252282522925230252312523225233252342523525236252372523825239252402524125242252432524425245252462524725248252492525025251252522525325254252552525625257252582525925260252612526225263252642526525266252672526825269252702527125272252732527425275252762527725278252792528025281252822528325284252852528625287252882528925290252912529225293252942529525296252972529825299253002530125302253032530425305253062530725308253092531025311253122531325314253152531625317253182531925320253212532225323253242532525326253272532825329253302533125332253332533425335253362533725338253392534025341253422534325344253452534625347253482534925350253512535225353253542535525356253572535825359253602536125362253632536425365253662536725368253692537025371253722537325374253752537625377253782537925380253812538225383253842538525386253872538825389253902539125392253932539425395253962539725398253992540025401254022540325404254052540625407254082540925410254112541225413254142541525416254172541825419254202542125422254232542425425254262542725428254292543025431254322543325434254352543625437254382543925440254412544225443254442544525446254472544825449254502545125452254532545425455254562545725458254592546025461254622546325464254652546625467254682546925470254712547225473254742547525476254772547825479254802548125482254832548425485254862548725488254892549025491254922549325494254952549625497254982549925500255012550225503255042550525506255072550825509255102551125512255132551425515255162551725518255192552025521255222552325524255252552625527255282552925530255312553225533255342553525536255372553825539255402554125542255432554425545255462554725548255492555025551255522555325554255552555625557255582555925560255612556225563255642556525566255672556825569255702557125572255732557425575255762557725578255792558025581255822558325584255852558625587255882558925590255912559225593255942559525596255972559825599256002560125602256032560425605256062560725608256092561025611256122561325614256152561625617256182561925620256212562225623256242562525626256272562825629256302563125632256332563425635256362563725638256392564025641256422564325644256452564625647256482564925650256512565225653256542565525656256572565825659256602566125662256632566425665256662566725668256692567025671256722567325674256752567625677256782567925680256812568225683256842568525686256872568825689256902569125692256932569425695256962569725698256992570025701257022570325704257052570625707257082570925710257112571225713257142571525716257172571825719257202572125722257232572425725257262572725728257292573025731257322573325734257352573625737257382573925740257412574225743257442574525746257472574825749257502575125752257532575425755257562575725758257592576025761257622576325764257652576625767257682576925770257712577225773257742577525776257772577825779257802578125782257832578425785257862578725788257892579025791257922579325794257952579625797257982579925800258012580225803258042580525806258072580825809258102581125812258132581425815258162581725818258192582025821258222582325824258252582625827258282582925830258312583225833258342583525836258372583825839258402584125842258432584425845258462584725848258492585025851258522585325854258552585625857258582585925860258612586225863258642586525866258672586825869258702587125872258732587425875258762587725878258792588025881258822588325884258852588625887258882588925890258912589225893258942589525896258972589825899259002590125902259032590425905259062590725908259092591025911259122591325914259152591625917259182591925920259212592225923259242592525926259272592825929259302593125932259332593425935259362593725938259392594025941259422594325944259452594625947259482594925950259512595225953259542595525956259572595825959259602596125962259632596425965259662596725968259692597025971259722597325974259752597625977259782597925980259812598225983259842598525986259872598825989259902599125992259932599425995259962599725998259992600026001260022600326004260052600626007260082600926010260112601226013260142601526016260172601826019260202602126022260232602426025260262602726028260292603026031260322603326034260352603626037260382603926040260412604226043260442604526046260472604826049260502605126052260532605426055260562605726058260592606026061260622606326064260652606626067260682606926070260712607226073260742607526076260772607826079260802608126082260832608426085260862608726088260892609026091260922609326094260952609626097260982609926100261012610226103261042610526106261072610826109261102611126112261132611426115261162611726118261192612026121261222612326124261252612626127261282612926130261312613226133261342613526136261372613826139261402614126142261432614426145261462614726148261492615026151261522615326154261552615626157261582615926160261612616226163261642616526166261672616826169261702617126172261732617426175261762617726178261792618026181261822618326184261852618626187261882618926190261912619226193261942619526196261972619826199262002620126202262032620426205262062620726208262092621026211262122621326214262152621626217262182621926220262212622226223262242622526226262272622826229262302623126232262332623426235262362623726238262392624026241262422624326244262452624626247262482624926250262512625226253262542625526256262572625826259262602626126262262632626426265262662626726268262692627026271262722627326274262752627626277262782627926280262812628226283262842628526286262872628826289262902629126292262932629426295262962629726298262992630026301263022630326304263052630626307263082630926310263112631226313263142631526316263172631826319263202632126322263232632426325263262632726328263292633026331263322633326334263352633626337263382633926340263412634226343263442634526346263472634826349263502635126352263532635426355263562635726358263592636026361263622636326364263652636626367263682636926370263712637226373263742637526376263772637826379263802638126382263832638426385263862638726388263892639026391263922639326394263952639626397263982639926400264012640226403264042640526406264072640826409264102641126412264132641426415264162641726418264192642026421264222642326424264252642626427264282642926430264312643226433264342643526436264372643826439264402644126442264432644426445264462644726448264492645026451264522645326454264552645626457264582645926460264612646226463264642646526466264672646826469264702647126472264732647426475264762647726478264792648026481264822648326484264852648626487264882648926490264912649226493264942649526496264972649826499265002650126502265032650426505265062650726508265092651026511265122651326514265152651626517265182651926520265212652226523265242652526526265272652826529265302653126532265332653426535265362653726538265392654026541265422654326544265452654626547265482654926550265512655226553265542655526556265572655826559265602656126562265632656426565265662656726568265692657026571265722657326574265752657626577265782657926580265812658226583265842658526586265872658826589265902659126592265932659426595265962659726598265992660026601266022660326604266052660626607266082660926610266112661226613266142661526616266172661826619266202662126622266232662426625266262662726628266292663026631266322663326634266352663626637266382663926640266412664226643266442664526646266472664826649266502665126652266532665426655266562665726658266592666026661266622666326664266652666626667266682666926670266712667226673266742667526676266772667826679266802668126682266832668426685266862668726688266892669026691266922669326694266952669626697266982669926700267012670226703267042670526706267072670826709267102671126712267132671426715267162671726718267192672026721267222672326724267252672626727267282672926730267312673226733267342673526736267372673826739267402674126742267432674426745267462674726748267492675026751267522675326754267552675626757267582675926760267612676226763267642676526766267672676826769267702677126772267732677426775267762677726778267792678026781267822678326784267852678626787267882678926790267912679226793267942679526796267972679826799268002680126802268032680426805268062680726808268092681026811268122681326814268152681626817268182681926820268212682226823268242682526826268272682826829268302683126832268332683426835268362683726838268392684026841268422684326844268452684626847268482684926850268512685226853268542685526856268572685826859268602686126862268632686426865268662686726868268692687026871268722687326874268752687626877268782687926880268812688226883268842688526886268872688826889268902689126892268932689426895268962689726898268992690026901269022690326904269052690626907269082690926910269112691226913269142691526916269172691826919269202692126922269232692426925269262692726928269292693026931269322693326934269352693626937269382693926940269412694226943269442694526946269472694826949269502695126952269532695426955269562695726958269592696026961269622696326964269652696626967269682696926970269712697226973269742697526976269772697826979269802698126982269832698426985269862698726988269892699026991269922699326994269952699626997269982699927000270012700227003270042700527006270072700827009270102701127012270132701427015270162701727018270192702027021270222702327024270252702627027270282702927030270312703227033270342703527036270372703827039270402704127042270432704427045270462704727048270492705027051270522705327054270552705627057270582705927060270612706227063270642706527066270672706827069270702707127072270732707427075270762707727078270792708027081270822708327084270852708627087270882708927090270912709227093270942709527096270972709827099271002710127102271032710427105271062710727108271092711027111271122711327114271152711627117271182711927120271212712227123271242712527126271272712827129271302713127132271332713427135271362713727138271392714027141271422714327144271452714627147271482714927150271512715227153271542715527156271572715827159271602716127162271632716427165271662716727168271692717027171271722717327174271752717627177271782717927180271812718227183271842718527186271872718827189271902719127192271932719427195271962719727198271992720027201272022720327204272052720627207272082720927210272112721227213272142721527216272172721827219272202722127222272232722427225272262722727228272292723027231272322723327234272352723627237272382723927240272412724227243272442724527246272472724827249272502725127252272532725427255272562725727258272592726027261272622726327264272652726627267272682726927270272712727227273272742727527276272772727827279272802728127282272832728427285272862728727288272892729027291272922729327294272952729627297272982729927300273012730227303273042730527306273072730827309273102731127312273132731427315273162731727318273192732027321273222732327324273252732627327273282732927330273312733227333273342733527336273372733827339273402734127342273432734427345273462734727348273492735027351273522735327354273552735627357273582735927360273612736227363273642736527366273672736827369273702737127372273732737427375273762737727378273792738027381273822738327384273852738627387273882738927390273912739227393273942739527396273972739827399274002740127402274032740427405274062740727408274092741027411274122741327414274152741627417274182741927420274212742227423274242742527426274272742827429274302743127432274332743427435274362743727438274392744027441274422744327444274452744627447274482744927450274512745227453274542745527456274572745827459274602746127462274632746427465274662746727468274692747027471274722747327474274752747627477274782747927480274812748227483274842748527486274872748827489274902749127492274932749427495274962749727498274992750027501275022750327504275052750627507275082750927510275112751227513275142751527516275172751827519275202752127522275232752427525275262752727528275292753027531275322753327534275352753627537275382753927540275412754227543275442754527546275472754827549275502755127552275532755427555275562755727558275592756027561275622756327564275652756627567275682756927570275712757227573275742757527576275772757827579275802758127582275832758427585275862758727588275892759027591275922759327594275952759627597275982759927600276012760227603276042760527606276072760827609276102761127612276132761427615276162761727618276192762027621276222762327624276252762627627276282762927630276312763227633276342763527636276372763827639276402764127642276432764427645276462764727648276492765027651276522765327654276552765627657276582765927660276612766227663276642766527666276672766827669276702767127672276732767427675276762767727678276792768027681276822768327684276852768627687276882768927690276912769227693276942769527696276972769827699277002770127702277032770427705277062770727708277092771027711277122771327714277152771627717277182771927720277212772227723277242772527726277272772827729277302773127732277332773427735277362773727738277392774027741277422774327744277452774627747277482774927750277512775227753277542775527756277572775827759277602776127762277632776427765277662776727768277692777027771277722777327774277752777627777277782777927780277812778227783277842778527786277872778827789277902779127792277932779427795277962779727798277992780027801278022780327804278052780627807278082780927810278112781227813278142781527816278172781827819278202782127822278232782427825278262782727828278292783027831278322783327834278352783627837278382783927840278412784227843278442784527846278472784827849278502785127852278532785427855278562785727858278592786027861278622786327864278652786627867278682786927870278712787227873278742787527876278772787827879278802788127882278832788427885278862788727888278892789027891278922789327894278952789627897278982789927900279012790227903279042790527906279072790827909279102791127912279132791427915279162791727918279192792027921279222792327924279252792627927279282792927930279312793227933279342793527936279372793827939279402794127942279432794427945279462794727948279492795027951279522795327954279552795627957279582795927960279612796227963279642796527966279672796827969279702797127972279732797427975279762797727978279792798027981279822798327984279852798627987279882798927990279912799227993279942799527996279972799827999280002800128002280032800428005280062800728008280092801028011280122801328014280152801628017280182801928020280212802228023280242802528026280272802828029280302803128032280332803428035280362803728038280392804028041280422804328044280452804628047280482804928050280512805228053280542805528056280572805828059280602806128062280632806428065280662806728068280692807028071280722807328074280752807628077280782807928080280812808228083280842808528086280872808828089280902809128092280932809428095280962809728098280992810028101281022810328104281052810628107281082810928110281112811228113281142811528116281172811828119281202812128122281232812428125281262812728128281292813028131281322813328134281352813628137281382813928140281412814228143281442814528146281472814828149281502815128152281532815428155281562815728158281592816028161281622816328164281652816628167281682816928170281712817228173281742817528176281772817828179281802818128182281832818428185281862818728188281892819028191281922819328194281952819628197281982819928200282012820228203282042820528206282072820828209282102821128212282132821428215282162821728218282192822028221282222822328224282252822628227282282822928230282312823228233282342823528236282372823828239282402824128242282432824428245282462824728248282492825028251282522825328254282552825628257282582825928260282612826228263282642826528266282672826828269282702827128272282732827428275282762827728278282792828028281282822828328284282852828628287282882828928290282912829228293282942829528296282972829828299283002830128302283032830428305283062830728308283092831028311283122831328314283152831628317283182831928320283212832228323283242832528326283272832828329283302833128332283332833428335283362833728338283392834028341283422834328344283452834628347283482834928350283512835228353283542835528356283572835828359283602836128362283632836428365283662836728368283692837028371283722837328374283752837628377283782837928380283812838228383283842838528386283872838828389283902839128392283932839428395283962839728398283992840028401284022840328404284052840628407284082840928410284112841228413284142841528416284172841828419284202842128422284232842428425284262842728428284292843028431284322843328434284352843628437284382843928440284412844228443284442844528446284472844828449284502845128452284532845428455284562845728458284592846028461284622846328464284652846628467284682846928470284712847228473284742847528476284772847828479284802848128482284832848428485284862848728488284892849028491284922849328494284952849628497284982849928500285012850228503285042850528506285072850828509285102851128512285132851428515285162851728518285192852028521285222852328524285252852628527285282852928530285312853228533285342853528536285372853828539285402854128542285432854428545285462854728548285492855028551285522855328554285552855628557285582855928560285612856228563285642856528566285672856828569285702857128572285732857428575285762857728578285792858028581285822858328584285852858628587285882858928590285912859228593285942859528596285972859828599286002860128602286032860428605286062860728608286092861028611286122861328614286152861628617286182861928620286212862228623286242862528626286272862828629286302863128632286332863428635286362863728638286392864028641286422864328644286452864628647286482864928650286512865228653286542865528656286572865828659286602866128662286632866428665286662866728668286692867028671286722867328674286752867628677286782867928680286812868228683286842868528686286872868828689286902869128692286932869428695286962869728698286992870028701287022870328704287052870628707287082870928710287112871228713287142871528716287172871828719287202872128722287232872428725287262872728728287292873028731287322873328734287352873628737287382873928740287412874228743287442874528746287472874828749287502875128752287532875428755287562875728758287592876028761287622876328764287652876628767287682876928770287712877228773287742877528776287772877828779287802878128782287832878428785287862878728788287892879028791287922879328794287952879628797287982879928800288012880228803288042880528806288072880828809288102881128812288132881428815288162881728818288192882028821288222882328824288252882628827288282882928830288312883228833288342883528836288372883828839288402884128842288432884428845288462884728848288492885028851288522885328854288552885628857288582885928860288612886228863288642886528866288672886828869288702887128872288732887428875288762887728878288792888028881288822888328884288852888628887288882888928890288912889228893288942889528896288972889828899289002890128902289032890428905289062890728908289092891028911289122891328914289152891628917289182891928920289212892228923289242892528926289272892828929289302893128932289332893428935289362893728938289392894028941289422894328944289452894628947289482894928950289512895228953289542895528956289572895828959289602896128962289632896428965289662896728968289692897028971289722897328974289752897628977289782897928980289812898228983289842898528986289872898828989289902899128992289932899428995289962899728998289992900029001290022900329004290052900629007290082900929010290112901229013290142901529016290172901829019290202902129022290232902429025290262902729028290292903029031290322903329034290352903629037290382903929040290412904229043290442904529046290472904829049290502905129052290532905429055290562905729058290592906029061290622906329064290652906629067290682906929070290712907229073290742907529076290772907829079290802908129082290832908429085290862908729088290892909029091290922909329094290952909629097290982909929100291012910229103291042910529106291072910829109291102911129112291132911429115291162911729118291192912029121291222912329124291252912629127291282912929130291312913229133291342913529136291372913829139291402914129142291432914429145291462914729148291492915029151291522915329154291552915629157291582915929160291612916229163291642916529166291672916829169291702917129172291732917429175291762917729178291792918029181291822918329184291852918629187291882918929190291912919229193291942919529196291972919829199292002920129202292032920429205292062920729208292092921029211292122921329214292152921629217292182921929220292212922229223292242922529226292272922829229292302923129232292332923429235292362923729238292392924029241292422924329244292452924629247292482924929250292512925229253292542925529256292572925829259292602926129262292632926429265292662926729268292692927029271292722927329274292752927629277292782927929280292812928229283292842928529286292872928829289292902929129292292932929429295292962929729298292992930029301293022930329304293052930629307293082930929310293112931229313293142931529316293172931829319293202932129322293232932429325293262932729328293292933029331293322933329334293352933629337293382933929340293412934229343293442934529346293472934829349293502935129352293532935429355293562935729358293592936029361293622936329364293652936629367293682936929370293712937229373293742937529376293772937829379293802938129382293832938429385293862938729388293892939029391293922939329394293952939629397293982939929400294012940229403294042940529406294072940829409294102941129412294132941429415294162941729418294192942029421294222942329424294252942629427294282942929430294312943229433294342943529436294372943829439294402944129442294432944429445294462944729448294492945029451294522945329454294552945629457294582945929460294612946229463294642946529466294672946829469294702947129472294732947429475294762947729478294792948029481294822948329484294852948629487294882948929490294912949229493294942949529496294972949829499295002950129502295032950429505295062950729508295092951029511295122951329514295152951629517295182951929520295212952229523295242952529526295272952829529295302953129532295332953429535295362953729538295392954029541295422954329544295452954629547295482954929550295512955229553295542955529556295572955829559295602956129562295632956429565295662956729568295692957029571295722957329574295752957629577295782957929580295812958229583295842958529586295872958829589295902959129592295932959429595295962959729598295992960029601296022960329604296052960629607296082960929610296112961229613296142961529616296172961829619296202962129622296232962429625296262962729628296292963029631296322963329634296352963629637296382963929640296412964229643296442964529646296472964829649296502965129652296532965429655296562965729658296592966029661296622966329664296652966629667296682966929670296712967229673296742967529676296772967829679296802968129682296832968429685296862968729688296892969029691296922969329694296952969629697296982969929700297012970229703297042970529706297072970829709297102971129712297132971429715297162971729718297192972029721297222972329724297252972629727297282972929730297312973229733297342973529736297372973829739297402974129742297432974429745297462974729748297492975029751297522975329754297552975629757297582975929760297612976229763297642976529766297672976829769297702977129772297732977429775297762977729778297792978029781297822978329784297852978629787297882978929790297912979229793297942979529796297972979829799298002980129802298032980429805298062980729808298092981029811298122981329814298152981629817298182981929820298212982229823298242982529826298272982829829298302983129832298332983429835298362983729838298392984029841298422984329844298452984629847298482984929850298512985229853298542985529856298572985829859298602986129862298632986429865298662986729868298692987029871298722987329874298752987629877298782987929880298812988229883298842988529886298872988829889298902989129892298932989429895298962989729898298992990029901299022990329904299052990629907299082990929910299112991229913299142991529916299172991829919299202992129922299232992429925299262992729928299292993029931299322993329934299352993629937299382993929940299412994229943299442994529946299472994829949299502995129952299532995429955299562995729958299592996029961299622996329964299652996629967299682996929970299712997229973299742997529976299772997829979299802998129982299832998429985299862998729988299892999029991299922999329994299952999629997299982999930000300013000230003300043000530006300073000830009300103001130012300133001430015300163001730018300193002030021300223002330024300253002630027300283002930030300313003230033300343003530036300373003830039300403004130042300433004430045300463004730048300493005030051300523005330054300553005630057300583005930060300613006230063300643006530066300673006830069300703007130072300733007430075300763007730078300793008030081300823008330084300853008630087300883008930090300913009230093300943009530096300973009830099301003010130102301033010430105301063010730108301093011030111301123011330114301153011630117301183011930120301213012230123301243012530126301273012830129301303013130132301333013430135301363013730138301393014030141301423014330144301453014630147301483014930150301513015230153301543015530156301573015830159301603016130162301633016430165301663016730168301693017030171301723017330174301753017630177301783017930180301813018230183301843018530186301873018830189301903019130192301933019430195301963019730198301993020030201302023020330204302053020630207302083020930210302113021230213302143021530216302173021830219302203022130222302233022430225302263022730228302293023030231302323023330234302353023630237302383023930240302413024230243302443024530246302473024830249302503025130252302533025430255302563025730258302593026030261302623026330264302653026630267302683026930270302713027230273302743027530276302773027830279302803028130282302833028430285302863028730288302893029030291302923029330294302953029630297302983029930300303013030230303303043030530306303073030830309303103031130312303133031430315303163031730318303193032030321303223032330324303253032630327303283032930330303313033230333303343033530336303373033830339303403034130342303433034430345303463034730348303493035030351303523035330354303553035630357303583035930360303613036230363303643036530366303673036830369303703037130372303733037430375303763037730378303793038030381303823038330384303853038630387303883038930390303913039230393303943039530396303973039830399304003040130402304033040430405304063040730408304093041030411304123041330414304153041630417304183041930420304213042230423304243042530426304273042830429304303043130432304333043430435304363043730438304393044030441304423044330444304453044630447304483044930450304513045230453304543045530456304573045830459304603046130462304633046430465304663046730468304693047030471304723047330474304753047630477304783047930480304813048230483304843048530486304873048830489304903049130492304933049430495304963049730498304993050030501305023050330504305053050630507305083050930510305113051230513305143051530516305173051830519305203052130522305233052430525305263052730528305293053030531305323053330534305353053630537305383053930540305413054230543305443054530546305473054830549305503055130552305533055430555305563055730558305593056030561305623056330564305653056630567305683056930570305713057230573305743057530576305773057830579305803058130582305833058430585305863058730588305893059030591305923059330594305953059630597305983059930600306013060230603306043060530606306073060830609306103061130612306133061430615306163061730618306193062030621306223062330624306253062630627306283062930630306313063230633306343063530636306373063830639306403064130642306433064430645306463064730648306493065030651306523065330654306553065630657306583065930660306613066230663306643066530666306673066830669306703067130672306733067430675306763067730678306793068030681306823068330684306853068630687306883068930690306913069230693306943069530696306973069830699307003070130702307033070430705307063070730708307093071030711307123071330714307153071630717307183071930720307213072230723307243072530726307273072830729307303073130732307333073430735307363073730738307393074030741307423074330744307453074630747307483074930750307513075230753307543075530756307573075830759307603076130762307633076430765307663076730768307693077030771307723077330774307753077630777307783077930780307813078230783307843078530786307873078830789307903079130792307933079430795307963079730798307993080030801308023080330804308053080630807308083080930810308113081230813308143081530816308173081830819308203082130822308233082430825308263082730828308293083030831308323083330834308353083630837308383083930840308413084230843308443084530846308473084830849308503085130852308533085430855308563085730858308593086030861308623086330864308653086630867308683086930870308713087230873308743087530876308773087830879308803088130882308833088430885308863088730888308893089030891308923089330894308953089630897308983089930900309013090230903309043090530906309073090830909309103091130912309133091430915309163091730918309193092030921309223092330924309253092630927309283092930930309313093230933309343093530936309373093830939309403094130942309433094430945309463094730948309493095030951309523095330954309553095630957309583095930960309613096230963309643096530966309673096830969309703097130972309733097430975309763097730978309793098030981309823098330984309853098630987309883098930990309913099230993309943099530996309973099830999310003100131002310033100431005310063100731008310093101031011310123101331014310153101631017310183101931020310213102231023310243102531026310273102831029310303103131032310333103431035310363103731038310393104031041310423104331044310453104631047310483104931050310513105231053310543105531056310573105831059310603106131062310633106431065310663106731068310693107031071310723107331074310753107631077310783107931080310813108231083310843108531086310873108831089310903109131092310933109431095310963109731098310993110031101311023110331104311053110631107311083110931110311113111231113311143111531116311173111831119311203112131122311233112431125311263112731128311293113031131311323113331134311353113631137311383113931140311413114231143311443114531146311473114831149311503115131152311533115431155311563115731158311593116031161311623116331164311653116631167311683116931170311713117231173311743117531176311773117831179311803118131182311833118431185311863118731188311893119031191311923119331194311953119631197311983119931200312013120231203312043120531206312073120831209312103121131212312133121431215312163121731218312193122031221312223122331224312253122631227312283122931230312313123231233312343123531236312373123831239312403124131242312433124431245312463124731248312493125031251312523125331254312553125631257312583125931260312613126231263312643126531266312673126831269312703127131272312733127431275312763127731278312793128031281312823128331284312853128631287312883128931290312913129231293312943129531296312973129831299313003130131302313033130431305313063130731308313093131031311313123131331314313153131631317313183131931320313213132231323313243132531326313273132831329313303133131332313333133431335313363133731338313393134031341313423134331344313453134631347313483134931350313513135231353313543135531356313573135831359313603136131362313633136431365313663136731368313693137031371313723137331374313753137631377313783137931380313813138231383313843138531386313873138831389313903139131392313933139431395313963139731398313993140031401314023140331404314053140631407314083140931410314113141231413314143141531416314173141831419314203142131422314233142431425314263142731428314293143031431314323143331434314353143631437314383143931440314413144231443314443144531446314473144831449314503145131452314533145431455314563145731458314593146031461314623146331464314653146631467314683146931470314713147231473314743147531476314773147831479314803148131482314833148431485314863148731488314893149031491314923149331494314953149631497314983149931500315013150231503315043150531506315073150831509315103151131512315133151431515315163151731518315193152031521315223152331524315253152631527315283152931530315313153231533315343153531536315373153831539315403154131542315433154431545315463154731548315493155031551315523155331554315553155631557315583155931560315613156231563315643156531566315673156831569315703157131572315733157431575315763157731578315793158031581315823158331584315853158631587315883158931590315913159231593315943159531596315973159831599316003160131602316033160431605316063160731608316093161031611316123161331614316153161631617316183161931620316213162231623316243162531626316273162831629316303163131632316333163431635316363163731638316393164031641316423164331644316453164631647316483164931650316513165231653316543165531656316573165831659316603166131662316633166431665316663166731668316693167031671316723167331674316753167631677316783167931680316813168231683316843168531686316873168831689316903169131692316933169431695316963169731698316993170031701317023170331704317053170631707317083170931710317113171231713317143171531716317173171831719317203172131722317233172431725317263172731728317293173031731317323173331734317353173631737317383173931740317413174231743317443174531746317473174831749317503175131752317533175431755317563175731758317593176031761317623176331764317653176631767317683176931770317713177231773317743177531776317773177831779317803178131782317833178431785317863178731788317893179031791317923179331794317953179631797317983179931800318013180231803318043180531806318073180831809318103181131812318133181431815318163181731818318193182031821318223182331824318253182631827318283182931830318313183231833318343183531836318373183831839318403184131842318433184431845318463184731848318493185031851318523185331854318553185631857318583185931860318613186231863318643186531866318673186831869318703187131872318733187431875318763187731878318793188031881318823188331884318853188631887318883188931890318913189231893318943189531896318973189831899319003190131902319033190431905319063190731908319093191031911319123191331914319153191631917319183191931920319213192231923319243192531926319273192831929319303193131932319333193431935319363193731938319393194031941319423194331944319453194631947319483194931950319513195231953319543195531956319573195831959319603196131962319633196431965319663196731968319693197031971319723197331974319753197631977319783197931980319813198231983319843198531986319873198831989319903199131992319933199431995319963199731998319993200032001320023200332004320053200632007320083200932010320113201232013320143201532016320173201832019320203202132022320233202432025320263202732028320293203032031320323203332034320353203632037320383203932040320413204232043320443204532046320473204832049320503205132052320533205432055320563205732058320593206032061320623206332064320653206632067320683206932070320713207232073320743207532076320773207832079320803208132082320833208432085320863208732088320893209032091320923209332094320953209632097320983209932100321013210232103321043210532106321073210832109321103211132112321133211432115321163211732118321193212032121321223212332124321253212632127321283212932130321313213232133321343213532136321373213832139321403214132142321433214432145321463214732148321493215032151321523215332154321553215632157321583215932160321613216232163321643216532166321673216832169321703217132172321733217432175321763217732178321793218032181321823218332184321853218632187321883218932190321913219232193321943219532196321973219832199322003220132202322033220432205322063220732208322093221032211322123221332214322153221632217322183221932220322213222232223322243222532226322273222832229322303223132232322333223432235322363223732238322393224032241322423224332244322453224632247322483224932250322513225232253322543225532256322573225832259322603226132262322633226432265322663226732268322693227032271322723227332274322753227632277322783227932280322813228232283322843228532286322873228832289322903229132292322933229432295322963229732298322993230032301323023230332304323053230632307323083230932310323113231232313323143231532316323173231832319323203232132322323233232432325323263232732328323293233032331323323233332334323353233632337323383233932340323413234232343323443234532346323473234832349323503235132352323533235432355323563235732358323593236032361323623236332364323653236632367323683236932370323713237232373323743237532376323773237832379323803238132382323833238432385323863238732388323893239032391323923239332394323953239632397323983239932400324013240232403324043240532406324073240832409324103241132412324133241432415324163241732418324193242032421324223242332424324253242632427324283242932430324313243232433324343243532436324373243832439324403244132442324433244432445324463244732448324493245032451324523245332454324553245632457324583245932460324613246232463324643246532466324673246832469324703247132472324733247432475324763247732478324793248032481324823248332484324853248632487324883248932490324913249232493324943249532496324973249832499325003250132502325033250432505325063250732508325093251032511325123251332514325153251632517325183251932520325213252232523325243252532526325273252832529325303253132532325333253432535325363253732538325393254032541325423254332544325453254632547325483254932550325513255232553325543255532556325573255832559325603256132562325633256432565325663256732568325693257032571325723257332574325753257632577325783257932580325813258232583325843258532586325873258832589325903259132592325933259432595325963259732598325993260032601326023260332604326053260632607326083260932610326113261232613326143261532616326173261832619326203262132622326233262432625326263262732628326293263032631326323263332634326353263632637326383263932640326413264232643326443264532646326473264832649326503265132652326533265432655326563265732658326593266032661326623266332664326653266632667326683266932670326713267232673326743267532676326773267832679326803268132682326833268432685326863268732688326893269032691326923269332694326953269632697326983269932700327013270232703327043270532706327073270832709327103271132712327133271432715327163271732718327193272032721327223272332724327253272632727327283272932730327313273232733327343273532736327373273832739327403274132742327433274432745327463274732748327493275032751327523275332754327553275632757327583275932760327613276232763327643276532766327673276832769327703277132772327733277432775327763277732778327793278032781327823278332784327853278632787327883278932790327913279232793327943279532796327973279832799328003280132802328033280432805328063280732808328093281032811328123281332814328153281632817328183281932820328213282232823328243282532826328273282832829328303283132832328333283432835328363283732838328393284032841328423284332844328453284632847328483284932850328513285232853328543285532856328573285832859328603286132862328633286432865328663286732868328693287032871328723287332874328753287632877328783287932880328813288232883328843288532886328873288832889328903289132892328933289432895328963289732898328993290032901329023290332904329053290632907329083290932910329113291232913329143291532916329173291832919329203292132922329233292432925329263292732928329293293032931329323293332934329353293632937329383293932940329413294232943329443294532946329473294832949329503295132952329533295432955329563295732958329593296032961329623296332964329653296632967329683296932970329713297232973329743297532976329773297832979329803298132982329833298432985329863298732988329893299032991329923299332994329953299632997329983299933000330013300233003330043300533006330073300833009330103301133012330133301433015330163301733018330193302033021330223302333024330253302633027330283302933030330313303233033330343303533036330373303833039330403304133042330433304433045330463304733048330493305033051330523305333054330553305633057330583305933060330613306233063330643306533066330673306833069330703307133072330733307433075330763307733078330793308033081330823308333084330853308633087330883308933090330913309233093330943309533096330973309833099331003310133102331033310433105331063310733108331093311033111331123311333114331153311633117331183311933120331213312233123331243312533126331273312833129331303313133132331333313433135331363313733138331393314033141331423314333144331453314633147331483314933150331513315233153331543315533156331573315833159331603316133162331633316433165331663316733168331693317033171331723317333174331753317633177331783317933180331813318233183331843318533186331873318833189331903319133192331933319433195331963319733198331993320033201332023320333204332053320633207332083320933210332113321233213332143321533216332173321833219332203322133222332233322433225332263322733228332293323033231332323323333234332353323633237332383323933240332413324233243332443324533246332473324833249332503325133252332533325433255332563325733258332593326033261332623326333264332653326633267332683326933270332713327233273332743327533276332773327833279332803328133282332833328433285332863328733288332893329033291332923329333294332953329633297332983329933300333013330233303333043330533306333073330833309333103331133312333133331433315333163331733318333193332033321333223332333324333253332633327333283332933330333313333233333333343333533336333373333833339333403334133342333433334433345333463334733348333493335033351333523335333354333553335633357333583335933360333613336233363333643336533366333673336833369333703337133372333733337433375333763337733378333793338033381333823338333384333853338633387333883338933390333913339233393333943339533396333973339833399334003340133402334033340433405334063340733408334093341033411334123341333414334153341633417334183341933420334213342233423334243342533426334273342833429334303343133432334333343433435334363343733438334393344033441334423344333444334453344633447334483344933450334513345233453334543345533456334573345833459334603346133462334633346433465334663346733468334693347033471334723347333474334753347633477334783347933480334813348233483334843348533486334873348833489334903349133492334933349433495334963349733498334993350033501335023350333504335053350633507335083350933510335113351233513335143351533516335173351833519335203352133522335233352433525335263352733528335293353033531335323353333534335353353633537335383353933540335413354233543335443354533546335473354833549335503355133552335533355433555335563355733558335593356033561335623356333564335653356633567335683356933570335713357233573335743357533576335773357833579335803358133582335833358433585335863358733588335893359033591335923359333594335953359633597335983359933600336013360233603336043360533606336073360833609336103361133612336133361433615336163361733618336193362033621336223362333624336253362633627336283362933630336313363233633336343363533636336373363833639336403364133642336433364433645336463364733648336493365033651336523365333654336553365633657336583365933660336613366233663336643366533666336673366833669336703367133672336733367433675336763367733678336793368033681336823368333684336853368633687336883368933690336913369233693336943369533696336973369833699337003370133702337033370433705337063370733708337093371033711337123371333714337153371633717337183371933720337213372233723337243372533726337273372833729337303373133732337333373433735337363373733738337393374033741337423374333744337453374633747337483374933750337513375233753337543375533756337573375833759337603376133762337633376433765337663376733768337693377033771337723377333774337753377633777337783377933780337813378233783337843378533786337873378833789337903379133792337933379433795337963379733798337993380033801338023380333804338053380633807338083380933810338113381233813338143381533816338173381833819338203382133822338233382433825338263382733828338293383033831338323383333834338353383633837338383383933840338413384233843338443384533846338473384833849338503385133852338533385433855338563385733858338593386033861338623386333864338653386633867338683386933870338713387233873338743387533876338773387833879338803388133882338833388433885338863388733888338893389033891338923389333894338953389633897338983389933900339013390233903339043390533906339073390833909339103391133912339133391433915339163391733918339193392033921339223392333924339253392633927339283392933930339313393233933339343393533936339373393833939339403394133942339433394433945339463394733948339493395033951339523395333954339553395633957339583395933960339613396233963339643396533966339673396833969339703397133972339733397433975339763397733978339793398033981339823398333984339853398633987339883398933990339913399233993339943399533996339973399833999340003400134002340033400434005340063400734008340093401034011340123401334014340153401634017340183401934020340213402234023340243402534026340273402834029340303403134032340333403434035340363403734038340393404034041340423404334044340453404634047340483404934050340513405234053340543405534056340573405834059340603406134062340633406434065340663406734068340693407034071340723407334074340753407634077340783407934080340813408234083340843408534086340873408834089340903409134092340933409434095340963409734098340993410034101341023410334104341053410634107341083410934110341113411234113341143411534116341173411834119341203412134122341233412434125341263412734128341293413034131341323413334134341353413634137341383413934140341413414234143341443414534146341473414834149341503415134152341533415434155341563415734158341593416034161341623416334164341653416634167341683416934170341713417234173341743417534176341773417834179341803418134182341833418434185341863418734188341893419034191341923419334194341953419634197341983419934200342013420234203342043420534206342073420834209342103421134212342133421434215342163421734218342193422034221342223422334224342253422634227342283422934230342313423234233342343423534236342373423834239342403424134242342433424434245342463424734248342493425034251342523425334254342553425634257342583425934260342613426234263342643426534266342673426834269342703427134272342733427434275342763427734278342793428034281342823428334284342853428634287342883428934290342913429234293342943429534296342973429834299343003430134302343033430434305343063430734308343093431034311343123431334314343153431634317343183431934320343213432234323343243432534326343273432834329343303433134332343333433434335343363433734338343393434034341343423434334344343453434634347343483434934350343513435234353343543435534356343573435834359343603436134362343633436434365343663436734368343693437034371343723437334374343753437634377343783437934380343813438234383343843438534386343873438834389343903439134392343933439434395343963439734398343993440034401344023440334404344053440634407344083440934410344113441234413344143441534416344173441834419344203442134422344233442434425344263442734428344293443034431344323443334434344353443634437344383443934440344413444234443344443444534446344473444834449344503445134452344533445434455344563445734458344593446034461344623446334464344653446634467344683446934470344713447234473344743447534476344773447834479344803448134482344833448434485344863448734488344893449034491344923449334494344953449634497344983449934500345013450234503345043450534506345073450834509345103451134512345133451434515345163451734518345193452034521345223452334524345253452634527345283452934530345313453234533345343453534536345373453834539345403454134542345433454434545345463454734548345493455034551345523455334554345553455634557345583455934560345613456234563345643456534566345673456834569345703457134572345733457434575345763457734578345793458034581345823458334584345853458634587345883458934590345913459234593345943459534596345973459834599346003460134602346033460434605346063460734608346093461034611346123461334614346153461634617346183461934620346213462234623346243462534626346273462834629346303463134632346333463434635346363463734638346393464034641346423464334644346453464634647346483464934650346513465234653346543465534656346573465834659346603466134662346633466434665346663466734668346693467034671346723467334674346753467634677346783467934680346813468234683346843468534686346873468834689346903469134692346933469434695346963469734698346993470034701347023470334704347053470634707347083470934710347113471234713347143471534716347173471834719347203472134722347233472434725347263472734728347293473034731347323473334734347353473634737347383473934740347413474234743347443474534746347473474834749347503475134752347533475434755347563475734758347593476034761347623476334764347653476634767347683476934770347713477234773347743477534776347773477834779347803478134782347833478434785347863478734788347893479034791347923479334794347953479634797347983479934800348013480234803348043480534806348073480834809348103481134812348133481434815348163481734818348193482034821348223482334824348253482634827348283482934830348313483234833348343483534836348373483834839348403484134842348433484434845348463484734848348493485034851348523485334854348553485634857348583485934860348613486234863348643486534866348673486834869348703487134872348733487434875348763487734878348793488034881348823488334884348853488634887348883488934890348913489234893348943489534896348973489834899349003490134902349033490434905349063490734908349093491034911349123491334914349153491634917349183491934920349213492234923349243492534926349273492834929349303493134932349333493434935349363493734938349393494034941349423494334944349453494634947349483494934950349513495234953349543495534956349573495834959349603496134962349633496434965349663496734968349693497034971349723497334974349753497634977349783497934980349813498234983349843498534986349873498834989349903499134992349933499434995349963499734998349993500035001350023500335004350053500635007350083500935010350113501235013350143501535016350173501835019350203502135022350233502435025350263502735028350293503035031350323503335034350353503635037350383503935040350413504235043350443504535046350473504835049350503505135052350533505435055350563505735058350593506035061350623506335064350653506635067350683506935070350713507235073350743507535076350773507835079350803508135082350833508435085350863508735088350893509035091350923509335094350953509635097350983509935100351013510235103351043510535106351073510835109351103511135112351133511435115351163511735118351193512035121351223512335124351253512635127351283512935130351313513235133351343513535136351373513835139351403514135142351433514435145351463514735148351493515035151351523515335154351553515635157351583515935160351613516235163351643516535166351673516835169351703517135172351733517435175351763517735178351793518035181351823518335184351853518635187351883518935190351913519235193351943519535196351973519835199352003520135202352033520435205352063520735208352093521035211352123521335214352153521635217352183521935220352213522235223352243522535226352273522835229352303523135232352333523435235352363523735238352393524035241352423524335244352453524635247352483524935250352513525235253352543525535256352573525835259352603526135262352633526435265352663526735268352693527035271352723527335274352753527635277352783527935280352813528235283352843528535286352873528835289352903529135292352933529435295352963529735298352993530035301353023530335304353053530635307353083530935310353113531235313353143531535316353173531835319353203532135322353233532435325353263532735328353293533035331353323533335334353353533635337353383533935340353413534235343353443534535346353473534835349353503535135352353533535435355353563535735358353593536035361353623536335364353653536635367353683536935370353713537235373353743537535376353773537835379353803538135382353833538435385353863538735388353893539035391353923539335394353953539635397353983539935400354013540235403354043540535406354073540835409354103541135412354133541435415354163541735418354193542035421354223542335424354253542635427354283542935430354313543235433354343543535436354373543835439354403544135442354433544435445354463544735448354493545035451354523545335454354553545635457354583545935460354613546235463354643546535466354673546835469354703547135472354733547435475354763547735478354793548035481354823548335484354853548635487354883548935490354913549235493354943549535496354973549835499355003550135502355033550435505355063550735508355093551035511355123551335514355153551635517355183551935520355213552235523355243552535526355273552835529355303553135532355333553435535355363553735538355393554035541355423554335544355453554635547355483554935550355513555235553355543555535556355573555835559355603556135562355633556435565355663556735568355693557035571355723557335574355753557635577355783557935580355813558235583355843558535586355873558835589355903559135592355933559435595355963559735598355993560035601356023560335604356053560635607356083560935610356113561235613356143561535616356173561835619356203562135622356233562435625356263562735628356293563035631356323563335634356353563635637356383563935640356413564235643356443564535646356473564835649356503565135652356533565435655356563565735658356593566035661356623566335664356653566635667356683566935670356713567235673356743567535676356773567835679356803568135682356833568435685356863568735688356893569035691356923569335694356953569635697356983569935700357013570235703357043570535706357073570835709357103571135712357133571435715357163571735718357193572035721357223572335724357253572635727357283572935730357313573235733357343573535736357373573835739357403574135742357433574435745357463574735748357493575035751357523575335754357553575635757357583575935760357613576235763357643576535766357673576835769357703577135772357733577435775357763577735778357793578035781357823578335784357853578635787357883578935790357913579235793357943579535796357973579835799358003580135802358033580435805358063580735808358093581035811358123581335814358153581635817358183581935820358213582235823358243582535826358273582835829358303583135832358333583435835358363583735838358393584035841358423584335844358453584635847358483584935850358513585235853358543585535856358573585835859358603586135862358633586435865358663586735868358693587035871358723587335874358753587635877358783587935880358813588235883358843588535886358873588835889358903589135892358933589435895358963589735898358993590035901359023590335904359053590635907359083590935910359113591235913359143591535916359173591835919359203592135922359233592435925359263592735928359293593035931359323593335934359353593635937359383593935940359413594235943359443594535946359473594835949359503595135952359533595435955359563595735958359593596035961359623596335964359653596635967359683596935970359713597235973359743597535976359773597835979359803598135982359833598435985359863598735988359893599035991359923599335994359953599635997359983599936000360013600236003360043600536006360073600836009360103601136012360133601436015360163601736018360193602036021360223602336024360253602636027360283602936030360313603236033360343603536036360373603836039360403604136042360433604436045360463604736048360493605036051360523605336054360553605636057360583605936060360613606236063360643606536066360673606836069360703607136072360733607436075360763607736078360793608036081360823608336084360853608636087360883608936090360913609236093360943609536096360973609836099361003610136102361033610436105361063610736108361093611036111361123611336114361153611636117361183611936120361213612236123361243612536126361273612836129361303613136132361333613436135361363613736138361393614036141361423614336144361453614636147361483614936150361513615236153361543615536156361573615836159361603616136162361633616436165361663616736168361693617036171361723617336174361753617636177361783617936180361813618236183361843618536186361873618836189361903619136192361933619436195361963619736198361993620036201362023620336204362053620636207362083620936210362113621236213362143621536216362173621836219362203622136222362233622436225362263622736228362293623036231362323623336234362353623636237362383623936240362413624236243362443624536246362473624836249362503625136252362533625436255362563625736258362593626036261362623626336264362653626636267362683626936270362713627236273362743627536276362773627836279362803628136282362833628436285362863628736288362893629036291362923629336294362953629636297362983629936300363013630236303363043630536306363073630836309363103631136312363133631436315363163631736318363193632036321363223632336324363253632636327363283632936330363313633236333363343633536336363373633836339363403634136342363433634436345363463634736348363493635036351363523635336354363553635636357363583635936360363613636236363363643636536366363673636836369363703637136372363733637436375363763637736378363793638036381363823638336384363853638636387363883638936390363913639236393363943639536396363973639836399364003640136402364033640436405364063640736408364093641036411364123641336414364153641636417364183641936420364213642236423364243642536426364273642836429364303643136432364333643436435364363643736438364393644036441364423644336444364453644636447364483644936450364513645236453364543645536456364573645836459364603646136462364633646436465364663646736468364693647036471364723647336474364753647636477364783647936480364813648236483364843648536486364873648836489364903649136492364933649436495364963649736498364993650036501365023650336504365053650636507365083650936510365113651236513365143651536516365173651836519365203652136522365233652436525365263652736528365293653036531365323653336534365353653636537365383653936540365413654236543365443654536546365473654836549365503655136552365533655436555365563655736558365593656036561365623656336564365653656636567365683656936570365713657236573365743657536576365773657836579365803658136582365833658436585365863658736588365893659036591365923659336594365953659636597365983659936600366013660236603366043660536606366073660836609366103661136612366133661436615366163661736618366193662036621366223662336624366253662636627366283662936630366313663236633366343663536636366373663836639366403664136642366433664436645366463664736648366493665036651366523665336654366553665636657366583665936660366613666236663366643666536666366673666836669366703667136672366733667436675366763667736678366793668036681366823668336684366853668636687366883668936690366913669236693366943669536696366973669836699367003670136702367033670436705367063670736708367093671036711367123671336714367153671636717367183671936720367213672236723367243672536726367273672836729367303673136732367333673436735367363673736738367393674036741367423674336744367453674636747367483674936750367513675236753367543675536756367573675836759367603676136762367633676436765367663676736768367693677036771367723677336774367753677636777367783677936780367813678236783367843678536786367873678836789367903679136792367933679436795367963679736798367993680036801368023680336804368053680636807368083680936810368113681236813368143681536816368173681836819368203682136822368233682436825368263682736828368293683036831368323683336834368353683636837368383683936840368413684236843368443684536846368473684836849368503685136852368533685436855368563685736858368593686036861368623686336864368653686636867368683686936870368713687236873368743687536876368773687836879368803688136882368833688436885368863688736888368893689036891368923689336894368953689636897368983689936900369013690236903369043690536906369073690836909369103691136912369133691436915369163691736918369193692036921369223692336924369253692636927369283692936930369313693236933369343693536936369373693836939369403694136942369433694436945369463694736948369493695036951369523695336954369553695636957369583695936960369613696236963369643696536966369673696836969369703697136972369733697436975369763697736978369793698036981369823698336984369853698636987369883698936990369913699236993369943699536996369973699836999370003700137002370033700437005370063700737008370093701037011370123701337014370153701637017370183701937020370213702237023370243702537026370273702837029370303703137032370333703437035370363703737038370393704037041370423704337044370453704637047370483704937050370513705237053370543705537056370573705837059370603706137062370633706437065370663706737068370693707037071370723707337074370753707637077370783707937080370813708237083370843708537086370873708837089370903709137092370933709437095370963709737098370993710037101371023710337104371053710637107371083710937110371113711237113371143711537116371173711837119371203712137122371233712437125371263712737128371293713037131371323713337134371353713637137371383713937140371413714237143371443714537146371473714837149371503715137152371533715437155371563715737158371593716037161371623716337164371653716637167371683716937170371713717237173371743717537176371773717837179371803718137182371833718437185371863718737188371893719037191371923719337194371953719637197371983719937200372013720237203372043720537206372073720837209372103721137212372133721437215372163721737218372193722037221372223722337224372253722637227372283722937230372313723237233372343723537236372373723837239372403724137242372433724437245372463724737248372493725037251372523725337254372553725637257372583725937260372613726237263372643726537266372673726837269372703727137272372733727437275372763727737278372793728037281372823728337284372853728637287372883728937290372913729237293372943729537296372973729837299373003730137302373033730437305373063730737308373093731037311373123731337314373153731637317373183731937320373213732237323373243732537326373273732837329373303733137332373333733437335373363733737338373393734037341373423734337344373453734637347373483734937350373513735237353373543735537356373573735837359373603736137362373633736437365373663736737368373693737037371373723737337374373753737637377373783737937380373813738237383373843738537386373873738837389373903739137392373933739437395373963739737398373993740037401374023740337404374053740637407374083740937410374113741237413374143741537416374173741837419374203742137422374233742437425374263742737428374293743037431374323743337434374353743637437374383743937440374413744237443374443744537446374473744837449374503745137452374533745437455374563745737458374593746037461374623746337464374653746637467374683746937470374713747237473374743747537476374773747837479374803748137482374833748437485374863748737488374893749037491374923749337494374953749637497374983749937500375013750237503375043750537506375073750837509375103751137512375133751437515375163751737518375193752037521375223752337524375253752637527375283752937530375313753237533375343753537536375373753837539375403754137542375433754437545375463754737548375493755037551375523755337554375553755637557375583755937560375613756237563375643756537566375673756837569375703757137572375733757437575375763757737578375793758037581375823758337584375853758637587375883758937590375913759237593375943759537596375973759837599376003760137602376033760437605376063760737608376093761037611376123761337614376153761637617376183761937620376213762237623376243762537626376273762837629376303763137632376333763437635376363763737638376393764037641376423764337644376453764637647376483764937650376513765237653376543765537656376573765837659376603766137662376633766437665376663766737668376693767037671376723767337674376753767637677376783767937680376813768237683376843768537686376873768837689376903769137692376933769437695376963769737698376993770037701377023770337704377053770637707377083770937710377113771237713377143771537716377173771837719377203772137722377233772437725377263772737728377293773037731377323773337734377353773637737377383773937740377413774237743377443774537746377473774837749377503775137752377533775437755377563775737758377593776037761377623776337764377653776637767377683776937770377713777237773377743777537776377773777837779377803778137782377833778437785377863778737788377893779037791377923779337794377953779637797377983779937800378013780237803378043780537806378073780837809378103781137812378133781437815378163781737818378193782037821378223782337824378253782637827378283782937830378313783237833378343783537836378373783837839378403784137842378433784437845378463784737848378493785037851378523785337854378553785637857378583785937860378613786237863378643786537866378673786837869378703787137872378733787437875378763787737878378793788037881378823788337884378853788637887378883788937890378913789237893378943789537896378973789837899379003790137902379033790437905379063790737908379093791037911379123791337914379153791637917379183791937920379213792237923379243792537926379273792837929379303793137932379333793437935379363793737938379393794037941379423794337944379453794637947379483794937950379513795237953379543795537956379573795837959379603796137962379633796437965379663796737968379693797037971379723797337974379753797637977379783797937980379813798237983379843798537986379873798837989379903799137992379933799437995379963799737998379993800038001380023800338004380053800638007380083800938010380113801238013380143801538016380173801838019380203802138022380233802438025380263802738028380293803038031380323803338034380353803638037380383803938040380413804238043380443804538046380473804838049380503805138052380533805438055380563805738058380593806038061380623806338064380653806638067380683806938070380713807238073380743807538076380773807838079380803808138082380833808438085380863808738088380893809038091380923809338094380953809638097380983809938100381013810238103381043810538106381073810838109381103811138112381133811438115381163811738118381193812038121381223812338124381253812638127381283812938130381313813238133381343813538136381373813838139381403814138142381433814438145381463814738148381493815038151381523815338154381553815638157381583815938160381613816238163381643816538166381673816838169381703817138172381733817438175381763817738178381793818038181381823818338184381853818638187381883818938190381913819238193381943819538196381973819838199382003820138202382033820438205382063820738208382093821038211382123821338214382153821638217382183821938220382213822238223382243822538226382273822838229382303823138232382333823438235382363823738238382393824038241382423824338244382453824638247382483824938250382513825238253382543825538256382573825838259382603826138262382633826438265382663826738268382693827038271382723827338274382753827638277382783827938280382813828238283382843828538286382873828838289382903829138292382933829438295382963829738298382993830038301383023830338304383053830638307383083830938310383113831238313383143831538316383173831838319383203832138322383233832438325383263832738328383293833038331383323833338334383353833638337383383833938340383413834238343383443834538346383473834838349383503835138352383533835438355383563835738358383593836038361383623836338364383653836638367383683836938370383713837238373383743837538376383773837838379383803838138382383833838438385383863838738388383893839038391383923839338394383953839638397383983839938400384013840238403384043840538406384073840838409384103841138412384133841438415384163841738418384193842038421384223842338424384253842638427384283842938430384313843238433384343843538436384373843838439384403844138442384433844438445384463844738448384493845038451384523845338454384553845638457384583845938460384613846238463384643846538466384673846838469384703847138472384733847438475384763847738478384793848038481384823848338484384853848638487384883848938490384913849238493384943849538496384973849838499385003850138502385033850438505385063850738508385093851038511385123851338514385153851638517385183851938520385213852238523385243852538526385273852838529385303853138532385333853438535385363853738538385393854038541385423854338544385453854638547385483854938550385513855238553385543855538556385573855838559385603856138562385633856438565385663856738568385693857038571385723857338574385753857638577385783857938580385813858238583385843858538586385873858838589385903859138592385933859438595385963859738598385993860038601386023860338604386053860638607386083860938610386113861238613386143861538616386173861838619386203862138622386233862438625386263862738628386293863038631386323863338634386353863638637386383863938640386413864238643386443864538646386473864838649386503865138652386533865438655386563865738658386593866038661386623866338664386653866638667386683866938670386713867238673386743867538676386773867838679386803868138682386833868438685386863868738688386893869038691386923869338694386953869638697386983869938700387013870238703387043870538706387073870838709387103871138712387133871438715387163871738718387193872038721387223872338724387253872638727387283872938730387313873238733387343873538736387373873838739387403874138742387433874438745387463874738748387493875038751387523875338754387553875638757387583875938760387613876238763387643876538766387673876838769387703877138772387733877438775387763877738778387793878038781387823878338784387853878638787387883878938790387913879238793387943879538796387973879838799388003880138802388033880438805388063880738808388093881038811388123881338814388153881638817388183881938820388213882238823388243882538826388273882838829388303883138832388333883438835388363883738838388393884038841388423884338844388453884638847388483884938850388513885238853388543885538856388573885838859388603886138862388633886438865388663886738868388693887038871388723887338874388753887638877388783887938880388813888238883388843888538886388873888838889388903889138892388933889438895388963889738898388993890038901389023890338904389053890638907389083890938910389113891238913389143891538916389173891838919389203892138922389233892438925389263892738928389293893038931389323893338934389353893638937389383893938940389413894238943389443894538946389473894838949389503895138952389533895438955389563895738958389593896038961389623896338964389653896638967389683896938970389713897238973389743897538976389773897838979389803898138982389833898438985389863898738988389893899038991389923899338994389953899638997389983899939000390013900239003390043900539006390073900839009390103901139012390133901439015390163901739018390193902039021390223902339024390253902639027390283902939030390313903239033390343903539036390373903839039390403904139042390433904439045390463904739048390493905039051390523905339054390553905639057390583905939060390613906239063390643906539066390673906839069390703907139072390733907439075390763907739078390793908039081390823908339084390853908639087390883908939090390913909239093390943909539096390973909839099391003910139102391033910439105391063910739108391093911039111391123911339114391153911639117391183911939120391213912239123391243912539126391273912839129391303913139132391333913439135391363913739138391393914039141391423914339144391453914639147391483914939150391513915239153391543915539156391573915839159391603916139162391633916439165391663916739168391693917039171391723917339174391753917639177391783917939180391813918239183391843918539186391873918839189391903919139192391933919439195391963919739198391993920039201392023920339204392053920639207392083920939210392113921239213392143921539216392173921839219392203922139222392233922439225392263922739228392293923039231392323923339234392353923639237392383923939240392413924239243392443924539246392473924839249392503925139252392533925439255392563925739258392593926039261392623926339264392653926639267392683926939270392713927239273392743927539276392773927839279392803928139282392833928439285392863928739288392893929039291392923929339294392953929639297392983929939300393013930239303393043930539306393073930839309393103931139312393133931439315393163931739318393193932039321393223932339324393253932639327393283932939330393313933239333393343933539336393373933839339393403934139342393433934439345393463934739348393493935039351393523935339354393553935639357393583935939360393613936239363393643936539366393673936839369393703937139372393733937439375393763937739378393793938039381393823938339384393853938639387393883938939390393913939239393393943939539396393973939839399394003940139402394033940439405394063940739408394093941039411394123941339414394153941639417394183941939420394213942239423394243942539426394273942839429394303943139432394333943439435394363943739438394393944039441394423944339444394453944639447394483944939450394513945239453394543945539456394573945839459394603946139462394633946439465394663946739468394693947039471394723947339474394753947639477394783947939480394813948239483394843948539486394873948839489394903949139492394933949439495394963949739498394993950039501395023950339504395053950639507395083950939510395113951239513395143951539516395173951839519395203952139522395233952439525395263952739528395293953039531395323953339534395353953639537395383953939540395413954239543395443954539546395473954839549395503955139552395533955439555395563955739558395593956039561395623956339564395653956639567395683956939570395713957239573395743957539576395773957839579395803958139582395833958439585395863958739588395893959039591395923959339594395953959639597395983959939600396013960239603396043960539606396073960839609396103961139612396133961439615396163961739618396193962039621396223962339624396253962639627396283962939630396313963239633396343963539636396373963839639396403964139642396433964439645396463964739648396493965039651396523965339654396553965639657396583965939660396613966239663396643966539666396673966839669396703967139672396733967439675396763967739678396793968039681396823968339684396853968639687396883968939690396913969239693396943969539696396973969839699397003970139702397033970439705397063970739708397093971039711397123971339714397153971639717397183971939720397213972239723397243972539726397273972839729397303973139732397333973439735397363973739738397393974039741397423974339744397453974639747397483974939750397513975239753397543975539756397573975839759397603976139762397633976439765397663976739768397693977039771397723977339774397753977639777397783977939780397813978239783397843978539786397873978839789397903979139792397933979439795397963979739798397993980039801398023980339804398053980639807398083980939810398113981239813398143981539816398173981839819398203982139822398233982439825398263982739828398293983039831398323983339834398353983639837398383983939840398413984239843398443984539846398473984839849398503985139852398533985439855398563985739858398593986039861398623986339864398653986639867398683986939870398713987239873398743987539876398773987839879398803988139882398833988439885398863988739888398893989039891398923989339894398953989639897398983989939900399013990239903399043990539906399073990839909399103991139912399133991439915399163991739918399193992039921399223992339924399253992639927399283992939930399313993239933399343993539936399373993839939399403994139942399433994439945399463994739948399493995039951399523995339954399553995639957399583995939960399613996239963399643996539966399673996839969399703997139972399733997439975399763997739978399793998039981399823998339984399853998639987399883998939990399913999239993399943999539996399973999839999400004000140002400034000440005400064000740008400094001040011400124001340014400154001640017400184001940020400214002240023400244002540026400274002840029400304003140032400334003440035400364003740038400394004040041400424004340044400454004640047400484004940050400514005240053400544005540056400574005840059400604006140062400634006440065400664006740068400694007040071400724007340074400754007640077400784007940080400814008240083400844008540086400874008840089400904009140092400934009440095400964009740098400994010040101401024010340104401054010640107401084010940110401114011240113401144011540116401174011840119401204012140122401234012440125401264012740128401294013040131401324013340134401354013640137401384013940140401414014240143401444014540146401474014840149401504015140152401534015440155401564015740158401594016040161401624016340164401654016640167401684016940170401714017240173401744017540176401774017840179401804018140182401834018440185401864018740188401894019040191401924019340194401954019640197401984019940200402014020240203402044020540206402074020840209402104021140212402134021440215402164021740218402194022040221402224022340224402254022640227402284022940230402314023240233402344023540236402374023840239402404024140242402434024440245402464024740248402494025040251402524025340254402554025640257402584025940260402614026240263402644026540266402674026840269402704027140272402734027440275402764027740278402794028040281402824028340284402854028640287402884028940290402914029240293402944029540296402974029840299403004030140302403034030440305403064030740308403094031040311403124031340314403154031640317403184031940320403214032240323403244032540326403274032840329403304033140332403334033440335403364033740338403394034040341403424034340344403454034640347403484034940350403514035240353403544035540356403574035840359403604036140362403634036440365403664036740368403694037040371403724037340374403754037640377403784037940380403814038240383403844038540386403874038840389403904039140392403934039440395403964039740398403994040040401404024040340404404054040640407404084040940410404114041240413404144041540416404174041840419404204042140422404234042440425404264042740428404294043040431404324043340434404354043640437404384043940440404414044240443404444044540446404474044840449404504045140452404534045440455404564045740458404594046040461404624046340464404654046640467404684046940470404714047240473404744047540476404774047840479404804048140482404834048440485404864048740488404894049040491404924049340494404954049640497404984049940500405014050240503405044050540506405074050840509405104051140512405134051440515405164051740518405194052040521405224052340524405254052640527405284052940530405314053240533405344053540536405374053840539405404054140542405434054440545405464054740548405494055040551405524055340554405554055640557405584055940560405614056240563405644056540566405674056840569405704057140572405734057440575405764057740578405794058040581405824058340584405854058640587405884058940590405914059240593405944059540596405974059840599406004060140602406034060440605406064060740608406094061040611406124061340614406154061640617406184061940620406214062240623406244062540626406274062840629406304063140632406334063440635406364063740638406394064040641406424064340644406454064640647406484064940650406514065240653406544065540656406574065840659406604066140662406634066440665406664066740668406694067040671406724067340674406754067640677406784067940680406814068240683406844068540686406874068840689406904069140692406934069440695406964069740698406994070040701407024070340704407054070640707407084070940710407114071240713407144071540716407174071840719407204072140722407234072440725407264072740728407294073040731407324073340734407354073640737407384073940740407414074240743407444074540746407474074840749407504075140752407534075440755407564075740758407594076040761407624076340764407654076640767407684076940770407714077240773407744077540776407774077840779407804078140782407834078440785407864078740788407894079040791407924079340794407954079640797407984079940800408014080240803408044080540806408074080840809408104081140812408134081440815408164081740818408194082040821408224082340824408254082640827408284082940830408314083240833408344083540836408374083840839408404084140842408434084440845408464084740848408494085040851408524085340854408554085640857408584085940860408614086240863408644086540866408674086840869408704087140872408734087440875408764087740878408794088040881408824088340884408854088640887408884088940890408914089240893408944089540896408974089840899409004090140902409034090440905409064090740908409094091040911409124091340914409154091640917409184091940920409214092240923409244092540926409274092840929409304093140932409334093440935409364093740938409394094040941409424094340944409454094640947409484094940950409514095240953409544095540956409574095840959409604096140962409634096440965409664096740968409694097040971409724097340974409754097640977409784097940980409814098240983409844098540986409874098840989409904099140992409934099440995409964099740998409994100041001410024100341004410054100641007410084100941010410114101241013410144101541016410174101841019410204102141022410234102441025410264102741028410294103041031410324103341034410354103641037410384103941040410414104241043410444104541046410474104841049410504105141052410534105441055410564105741058410594106041061410624106341064410654106641067410684106941070410714107241073410744107541076410774107841079410804108141082410834108441085410864108741088410894109041091410924109341094410954109641097410984109941100411014110241103411044110541106411074110841109411104111141112411134111441115411164111741118411194112041121411224112341124411254112641127411284112941130411314113241133411344113541136411374113841139411404114141142411434114441145411464114741148411494115041151411524115341154411554115641157411584115941160411614116241163411644116541166411674116841169411704117141172411734117441175411764117741178411794118041181411824118341184411854118641187411884118941190411914119241193411944119541196411974119841199412004120141202412034120441205412064120741208412094121041211412124121341214412154121641217412184121941220412214122241223412244122541226412274122841229412304123141232412334123441235412364123741238412394124041241412424124341244412454124641247412484124941250412514125241253412544125541256412574125841259412604126141262412634126441265412664126741268412694127041271412724127341274412754127641277412784127941280412814128241283412844128541286412874128841289412904129141292412934129441295412964129741298412994130041301413024130341304413054130641307413084130941310413114131241313413144131541316413174131841319413204132141322413234132441325413264132741328413294133041331413324133341334413354133641337413384133941340413414134241343413444134541346413474134841349413504135141352413534135441355413564135741358413594136041361413624136341364413654136641367413684136941370413714137241373413744137541376413774137841379413804138141382413834138441385413864138741388413894139041391413924139341394413954139641397413984139941400414014140241403414044140541406414074140841409414104141141412414134141441415414164141741418414194142041421414224142341424414254142641427414284142941430414314143241433414344143541436414374143841439414404144141442414434144441445414464144741448414494145041451414524145341454414554145641457414584145941460414614146241463414644146541466414674146841469414704147141472414734147441475414764147741478414794148041481414824148341484414854148641487414884148941490414914149241493414944149541496414974149841499415004150141502415034150441505415064150741508415094151041511415124151341514415154151641517415184151941520415214152241523415244152541526415274152841529415304153141532415334153441535415364153741538415394154041541415424154341544415454154641547415484154941550415514155241553415544155541556415574155841559415604156141562415634156441565415664156741568415694157041571415724157341574415754157641577415784157941580415814158241583415844158541586415874158841589415904159141592415934159441595415964159741598415994160041601416024160341604416054160641607416084160941610416114161241613416144161541616416174161841619416204162141622416234162441625416264162741628416294163041631416324163341634416354163641637416384163941640416414164241643416444164541646416474164841649416504165141652416534165441655416564165741658416594166041661416624166341664416654166641667416684166941670416714167241673416744167541676416774167841679416804168141682416834168441685416864168741688416894169041691416924169341694416954169641697416984169941700417014170241703417044170541706417074170841709417104171141712417134171441715417164171741718417194172041721417224172341724417254172641727417284172941730417314173241733417344173541736417374173841739417404174141742417434174441745417464174741748417494175041751417524175341754417554175641757417584175941760417614176241763417644176541766417674176841769417704177141772417734177441775417764177741778417794178041781417824178341784417854178641787417884178941790417914179241793417944179541796417974179841799418004180141802418034180441805418064180741808418094181041811418124181341814418154181641817418184181941820418214182241823418244182541826418274182841829418304183141832418334183441835418364183741838418394184041841418424184341844418454184641847418484184941850418514185241853418544185541856418574185841859418604186141862418634186441865418664186741868418694187041871418724187341874418754187641877418784187941880418814188241883418844188541886418874188841889418904189141892418934189441895418964189741898418994190041901419024190341904419054190641907419084190941910419114191241913419144191541916419174191841919419204192141922419234192441925419264192741928419294193041931419324193341934419354193641937419384193941940419414194241943419444194541946419474194841949419504195141952419534195441955419564195741958419594196041961419624196341964419654196641967419684196941970419714197241973419744197541976419774197841979419804198141982419834198441985419864198741988419894199041991419924199341994419954199641997419984199942000420014200242003420044200542006420074200842009420104201142012420134201442015420164201742018420194202042021420224202342024420254202642027420284202942030420314203242033420344203542036420374203842039420404204142042420434204442045420464204742048420494205042051420524205342054420554205642057420584205942060420614206242063420644206542066420674206842069420704207142072420734207442075420764207742078420794208042081420824208342084420854208642087420884208942090420914209242093420944209542096420974209842099421004210142102421034210442105421064210742108421094211042111421124211342114421154211642117421184211942120421214212242123421244212542126421274212842129421304213142132421334213442135421364213742138421394214042141421424214342144421454214642147421484214942150421514215242153421544215542156421574215842159421604216142162421634216442165421664216742168421694217042171421724217342174421754217642177421784217942180421814218242183421844218542186421874218842189421904219142192421934219442195421964219742198421994220042201422024220342204422054220642207422084220942210422114221242213422144221542216422174221842219422204222142222422234222442225422264222742228422294223042231422324223342234422354223642237422384223942240422414224242243422444224542246422474224842249422504225142252422534225442255422564225742258422594226042261422624226342264422654226642267422684226942270422714227242273422744227542276422774227842279422804228142282422834228442285422864228742288422894229042291422924229342294422954229642297422984229942300423014230242303423044230542306423074230842309423104231142312423134231442315423164231742318423194232042321423224232342324423254232642327423284232942330423314233242333423344233542336423374233842339423404234142342423434234442345423464234742348423494235042351423524235342354423554235642357423584235942360423614236242363423644236542366423674236842369423704237142372423734237442375423764237742378423794238042381423824238342384423854238642387423884238942390423914239242393423944239542396423974239842399424004240142402424034240442405424064240742408424094241042411424124241342414424154241642417424184241942420424214242242423424244242542426424274242842429424304243142432424334243442435424364243742438424394244042441424424244342444424454244642447424484244942450424514245242453424544245542456424574245842459424604246142462424634246442465424664246742468424694247042471424724247342474424754247642477424784247942480424814248242483424844248542486424874248842489424904249142492424934249442495424964249742498424994250042501425024250342504425054250642507425084250942510425114251242513425144251542516425174251842519425204252142522425234252442525425264252742528425294253042531425324253342534425354253642537425384253942540425414254242543425444254542546425474254842549425504255142552425534255442555425564255742558425594256042561425624256342564425654256642567425684256942570425714257242573425744257542576425774257842579425804258142582425834258442585425864258742588425894259042591425924259342594425954259642597425984259942600426014260242603426044260542606426074260842609426104261142612426134261442615426164261742618426194262042621426224262342624426254262642627426284262942630426314263242633426344263542636426374263842639426404264142642426434264442645426464264742648426494265042651426524265342654426554265642657426584265942660426614266242663426644266542666426674266842669426704267142672426734267442675426764267742678426794268042681426824268342684426854268642687426884268942690426914269242693426944269542696426974269842699427004270142702427034270442705427064270742708427094271042711427124271342714427154271642717427184271942720427214272242723427244272542726427274272842729427304273142732427334273442735427364273742738427394274042741427424274342744427454274642747427484274942750427514275242753427544275542756427574275842759427604276142762427634276442765427664276742768427694277042771427724277342774427754277642777427784277942780427814278242783427844278542786427874278842789427904279142792427934279442795427964279742798427994280042801428024280342804428054280642807428084280942810428114281242813428144281542816428174281842819428204282142822428234282442825428264282742828428294283042831428324283342834428354283642837428384283942840428414284242843428444284542846428474284842849428504285142852428534285442855428564285742858428594286042861428624286342864428654286642867428684286942870428714287242873428744287542876428774287842879428804288142882428834288442885428864288742888428894289042891428924289342894428954289642897428984289942900429014290242903429044290542906429074290842909429104291142912429134291442915429164291742918429194292042921429224292342924429254292642927429284292942930429314293242933429344293542936429374293842939429404294142942429434294442945429464294742948429494295042951429524295342954429554295642957429584295942960429614296242963429644296542966429674296842969429704297142972429734297442975429764297742978429794298042981429824298342984429854298642987429884298942990429914299242993429944299542996429974299842999430004300143002430034300443005430064300743008430094301043011430124301343014430154301643017430184301943020430214302243023430244302543026430274302843029430304303143032430334303443035430364303743038430394304043041430424304343044430454304643047430484304943050430514305243053430544305543056430574305843059430604306143062430634306443065430664306743068430694307043071430724307343074430754307643077430784307943080430814308243083430844308543086430874308843089430904309143092430934309443095430964309743098430994310043101431024310343104431054310643107431084310943110431114311243113431144311543116431174311843119431204312143122431234312443125431264312743128431294313043131431324313343134431354313643137431384313943140431414314243143431444314543146431474314843149431504315143152431534315443155431564315743158431594316043161431624316343164431654316643167431684316943170431714317243173431744317543176431774317843179431804318143182431834318443185431864318743188431894319043191431924319343194431954319643197431984319943200432014320243203432044320543206432074320843209432104321143212432134321443215432164321743218432194322043221432224322343224432254322643227432284322943230432314323243233432344323543236432374323843239432404324143242432434324443245432464324743248432494325043251432524325343254432554325643257432584325943260432614326243263432644326543266432674326843269432704327143272432734327443275432764327743278432794328043281432824328343284432854328643287432884328943290432914329243293432944329543296432974329843299433004330143302433034330443305433064330743308433094331043311433124331343314433154331643317433184331943320433214332243323433244332543326433274332843329433304333143332433334333443335433364333743338433394334043341433424334343344433454334643347433484334943350433514335243353433544335543356433574335843359433604336143362433634336443365433664336743368433694337043371433724337343374433754337643377433784337943380433814338243383433844338543386433874338843389433904339143392433934339443395433964339743398433994340043401434024340343404434054340643407434084340943410434114341243413434144341543416434174341843419434204342143422434234342443425434264342743428434294343043431434324343343434434354343643437434384343943440434414344243443434444344543446434474344843449434504345143452434534345443455434564345743458434594346043461434624346343464434654346643467434684346943470434714347243473434744347543476434774347843479434804348143482434834348443485434864348743488434894349043491434924349343494434954349643497434984349943500435014350243503435044350543506435074350843509435104351143512435134351443515435164351743518435194352043521435224352343524435254352643527435284352943530435314353243533435344353543536435374353843539435404354143542435434354443545435464354743548435494355043551435524355343554435554355643557435584355943560435614356243563435644356543566435674356843569435704357143572435734357443575435764357743578435794358043581435824358343584435854358643587435884358943590435914359243593435944359543596435974359843599436004360143602436034360443605436064360743608436094361043611436124361343614436154361643617436184361943620436214362243623436244362543626436274362843629436304363143632436334363443635436364363743638436394364043641436424364343644436454364643647436484364943650436514365243653436544365543656436574365843659436604366143662436634366443665436664366743668436694367043671436724367343674436754367643677436784367943680436814368243683436844368543686436874368843689436904369143692436934369443695436964369743698436994370043701437024370343704437054370643707437084370943710437114371243713437144371543716437174371843719437204372143722437234372443725437264372743728437294373043731437324373343734437354373643737437384373943740437414374243743437444374543746437474374843749437504375143752437534375443755437564375743758437594376043761437624376343764437654376643767437684376943770437714377243773437744377543776437774377843779437804378143782437834378443785437864378743788437894379043791437924379343794437954379643797437984379943800438014380243803438044380543806438074380843809438104381143812438134381443815438164381743818438194382043821438224382343824438254382643827438284382943830438314383243833438344383543836438374383843839438404384143842438434384443845438464384743848438494385043851438524385343854438554385643857438584385943860438614386243863438644386543866438674386843869438704387143872438734387443875438764387743878438794388043881438824388343884438854388643887438884388943890438914389243893438944389543896438974389843899439004390143902439034390443905439064390743908439094391043911439124391343914439154391643917439184391943920439214392243923439244392543926439274392843929439304393143932439334393443935439364393743938439394394043941439424394343944439454394643947439484394943950439514395243953439544395543956439574395843959439604396143962439634396443965439664396743968439694397043971439724397343974439754397643977439784397943980439814398243983439844398543986439874398843989439904399143992439934399443995439964399743998439994400044001440024400344004440054400644007440084400944010440114401244013440144401544016440174401844019440204402144022440234402444025440264402744028440294403044031440324403344034440354403644037440384403944040440414404244043440444404544046440474404844049440504405144052440534405444055440564405744058440594406044061440624406344064440654406644067440684406944070440714407244073440744407544076440774407844079440804408144082440834408444085440864408744088440894409044091440924409344094440954409644097440984409944100441014410244103441044410544106441074410844109441104411144112441134411444115441164411744118441194412044121441224412344124441254412644127441284412944130441314413244133441344413544136441374413844139441404414144142441434414444145441464414744148441494415044151441524415344154441554415644157441584415944160441614416244163441644416544166441674416844169441704417144172441734417444175441764417744178441794418044181441824418344184441854418644187441884418944190441914419244193441944419544196441974419844199442004420144202442034420444205442064420744208442094421044211442124421344214442154421644217442184421944220442214422244223442244422544226442274422844229442304423144232442334423444235442364423744238442394424044241442424424344244442454424644247442484424944250442514425244253442544425544256442574425844259442604426144262442634426444265442664426744268442694427044271442724427344274442754427644277442784427944280442814428244283442844428544286442874428844289442904429144292442934429444295442964429744298442994430044301443024430344304443054430644307443084430944310443114431244313443144431544316443174431844319443204432144322443234432444325443264432744328443294433044331443324433344334443354433644337443384433944340443414434244343443444434544346443474434844349443504435144352443534435444355443564435744358443594436044361443624436344364443654436644367443684436944370443714437244373443744437544376443774437844379443804438144382443834438444385443864438744388443894439044391443924439344394443954439644397443984439944400444014440244403444044440544406444074440844409444104441144412444134441444415444164441744418444194442044421444224442344424444254442644427444284442944430444314443244433444344443544436444374443844439444404444144442444434444444445444464444744448444494445044451444524445344454444554445644457444584445944460444614446244463444644446544466444674446844469444704447144472444734447444475444764447744478444794448044481444824448344484444854448644487444884448944490444914449244493444944449544496444974449844499445004450144502445034450444505445064450744508445094451044511445124451344514445154451644517445184451944520445214452244523445244452544526445274452844529445304453144532445334453444535445364453744538445394454044541445424454344544445454454644547445484454944550445514455244553445544455544556445574455844559445604456144562445634456444565445664456744568445694457044571445724457344574445754457644577445784457944580445814458244583445844458544586445874458844589445904459144592445934459444595445964459744598445994460044601446024460344604446054460644607446084460944610446114461244613446144461544616446174461844619446204462144622446234462444625446264462744628446294463044631446324463344634446354463644637446384463944640446414464244643446444464544646446474464844649446504465144652446534465444655446564465744658446594466044661446624466344664446654466644667446684466944670446714467244673446744467544676446774467844679446804468144682446834468444685446864468744688446894469044691446924469344694446954469644697446984469944700447014470244703447044470544706447074470844709447104471144712447134471444715447164471744718447194472044721447224472344724447254472644727447284472944730447314473244733447344473544736447374473844739447404474144742447434474444745447464474744748447494475044751447524475344754447554475644757447584475944760447614476244763447644476544766447674476844769447704477144772447734477444775447764477744778447794478044781447824478344784447854478644787447884478944790447914479244793447944479544796447974479844799448004480144802448034480444805448064480744808448094481044811448124481344814448154481644817448184481944820448214482244823448244482544826448274482844829448304483144832448334483444835448364483744838448394484044841448424484344844448454484644847448484484944850448514485244853448544485544856448574485844859448604486144862448634486444865448664486744868448694487044871448724487344874448754487644877448784487944880448814488244883448844488544886448874488844889448904489144892448934489444895448964489744898448994490044901449024490344904449054490644907449084490944910449114491244913449144491544916449174491844919449204492144922449234492444925449264492744928449294493044931449324493344934449354493644937449384493944940449414494244943449444494544946449474494844949449504495144952449534495444955449564495744958449594496044961449624496344964449654496644967449684496944970449714497244973449744497544976449774497844979449804498144982449834498444985449864498744988449894499044991449924499344994449954499644997449984499945000450014500245003450044500545006450074500845009450104501145012450134501445015450164501745018450194502045021450224502345024450254502645027450284502945030450314503245033450344503545036450374503845039450404504145042450434504445045450464504745048450494505045051450524505345054450554505645057450584505945060450614506245063450644506545066450674506845069450704507145072450734507445075450764507745078450794508045081450824508345084450854508645087450884508945090450914509245093450944509545096450974509845099451004510145102451034510445105451064510745108451094511045111451124511345114451154511645117451184511945120451214512245123451244512545126451274512845129451304513145132451334513445135451364513745138451394514045141451424514345144451454514645147451484514945150451514515245153451544515545156451574515845159451604516145162451634516445165451664516745168451694517045171451724517345174451754517645177451784517945180451814518245183451844518545186451874518845189451904519145192451934519445195451964519745198451994520045201452024520345204452054520645207452084520945210452114521245213452144521545216452174521845219452204522145222452234522445225452264522745228452294523045231452324523345234452354523645237452384523945240452414524245243452444524545246452474524845249452504525145252452534525445255452564525745258452594526045261452624526345264452654526645267452684526945270452714527245273452744527545276452774527845279452804528145282452834528445285452864528745288452894529045291452924529345294452954529645297452984529945300453014530245303453044530545306453074530845309453104531145312453134531445315453164531745318453194532045321453224532345324453254532645327453284532945330453314533245333453344533545336453374533845339453404534145342453434534445345453464534745348453494535045351453524535345354453554535645357453584535945360453614536245363453644536545366453674536845369453704537145372453734537445375453764537745378453794538045381453824538345384453854538645387453884538945390453914539245393453944539545396453974539845399454004540145402454034540445405454064540745408454094541045411454124541345414454154541645417454184541945420454214542245423454244542545426454274542845429454304543145432454334543445435454364543745438454394544045441454424544345444454454544645447454484544945450454514545245453454544545545456454574545845459454604546145462454634546445465454664546745468454694547045471454724547345474454754547645477454784547945480454814548245483454844548545486454874548845489454904549145492454934549445495454964549745498454994550045501455024550345504455054550645507455084550945510455114551245513455144551545516455174551845519455204552145522455234552445525455264552745528455294553045531455324553345534455354553645537455384553945540455414554245543455444554545546455474554845549455504555145552455534555445555455564555745558455594556045561455624556345564455654556645567455684556945570455714557245573455744557545576455774557845579455804558145582455834558445585455864558745588455894559045591455924559345594455954559645597455984559945600456014560245603456044560545606456074560845609456104561145612456134561445615456164561745618456194562045621456224562345624456254562645627456284562945630456314563245633456344563545636456374563845639456404564145642456434564445645456464564745648456494565045651456524565345654456554565645657456584565945660456614566245663456644566545666456674566845669456704567145672456734567445675456764567745678456794568045681456824568345684456854568645687456884568945690456914569245693456944569545696456974569845699457004570145702457034570445705457064570745708457094571045711457124571345714457154571645717457184571945720457214572245723457244572545726457274572845729457304573145732457334573445735457364573745738457394574045741457424574345744457454574645747457484574945750457514575245753457544575545756457574575845759457604576145762457634576445765457664576745768457694577045771457724577345774457754577645777457784577945780457814578245783457844578545786457874578845789457904579145792457934579445795457964579745798457994580045801458024580345804458054580645807458084580945810458114581245813458144581545816458174581845819458204582145822458234582445825458264582745828458294583045831458324583345834458354583645837458384583945840458414584245843458444584545846458474584845849458504585145852458534585445855458564585745858458594586045861458624586345864458654586645867458684586945870458714587245873458744587545876458774587845879458804588145882458834588445885458864588745888458894589045891458924589345894458954589645897458984589945900459014590245903459044590545906459074590845909459104591145912459134591445915459164591745918459194592045921459224592345924459254592645927459284592945930459314593245933459344593545936459374593845939459404594145942459434594445945459464594745948459494595045951459524595345954459554595645957459584595945960459614596245963459644596545966459674596845969459704597145972459734597445975459764597745978459794598045981459824598345984459854598645987459884598945990459914599245993459944599545996459974599845999460004600146002460034600446005460064600746008460094601046011460124601346014460154601646017460184601946020460214602246023460244602546026460274602846029460304603146032460334603446035460364603746038460394604046041460424604346044460454604646047460484604946050460514605246053460544605546056460574605846059460604606146062460634606446065460664606746068460694607046071460724607346074460754607646077460784607946080460814608246083460844608546086460874608846089460904609146092460934609446095460964609746098460994610046101461024610346104461054610646107461084610946110461114611246113461144611546116461174611846119461204612146122461234612446125461264612746128461294613046131461324613346134461354613646137461384613946140461414614246143461444614546146461474614846149461504615146152461534615446155461564615746158461594616046161461624616346164461654616646167461684616946170461714617246173461744617546176461774617846179461804618146182461834618446185461864618746188461894619046191461924619346194461954619646197461984619946200462014620246203462044620546206462074620846209462104621146212462134621446215462164621746218462194622046221462224622346224462254622646227462284622946230462314623246233462344623546236462374623846239462404624146242462434624446245462464624746248462494625046251462524625346254462554625646257462584625946260462614626246263462644626546266462674626846269462704627146272462734627446275462764627746278462794628046281462824628346284462854628646287462884628946290462914629246293462944629546296462974629846299463004630146302463034630446305463064630746308463094631046311463124631346314463154631646317463184631946320463214632246323463244632546326463274632846329463304633146332463334633446335463364633746338463394634046341463424634346344463454634646347463484634946350463514635246353463544635546356463574635846359463604636146362463634636446365463664636746368463694637046371463724637346374463754637646377463784637946380463814638246383463844638546386463874638846389463904639146392463934639446395463964639746398463994640046401464024640346404464054640646407464084640946410464114641246413464144641546416464174641846419464204642146422464234642446425464264642746428464294643046431464324643346434464354643646437464384643946440464414644246443464444644546446464474644846449464504645146452464534645446455464564645746458464594646046461464624646346464464654646646467464684646946470464714647246473464744647546476464774647846479464804648146482464834648446485464864648746488464894649046491464924649346494464954649646497464984649946500465014650246503465044650546506465074650846509465104651146512465134651446515465164651746518465194652046521465224652346524465254652646527465284652946530465314653246533465344653546536465374653846539465404654146542465434654446545465464654746548465494655046551465524655346554465554655646557465584655946560465614656246563465644656546566465674656846569465704657146572465734657446575465764657746578465794658046581465824658346584465854658646587465884658946590465914659246593465944659546596465974659846599466004660146602466034660446605466064660746608466094661046611466124661346614466154661646617466184661946620466214662246623466244662546626466274662846629466304663146632466334663446635466364663746638466394664046641466424664346644466454664646647466484664946650466514665246653466544665546656466574665846659466604666146662466634666446665466664666746668466694667046671466724667346674466754667646677466784667946680466814668246683466844668546686466874668846689466904669146692466934669446695466964669746698466994670046701467024670346704467054670646707467084670946710467114671246713467144671546716467174671846719467204672146722467234672446725467264672746728467294673046731467324673346734467354673646737467384673946740467414674246743467444674546746467474674846749467504675146752467534675446755467564675746758467594676046761467624676346764467654676646767467684676946770467714677246773467744677546776467774677846779467804678146782467834678446785467864678746788467894679046791467924679346794467954679646797467984679946800468014680246803468044680546806468074680846809468104681146812468134681446815468164681746818468194682046821468224682346824468254682646827468284682946830468314683246833468344683546836468374683846839468404684146842468434684446845468464684746848468494685046851468524685346854468554685646857468584685946860468614686246863468644686546866468674686846869468704687146872468734687446875468764687746878468794688046881468824688346884468854688646887468884688946890468914689246893468944689546896468974689846899469004690146902469034690446905469064690746908469094691046911469124691346914469154691646917469184691946920469214692246923469244692546926469274692846929469304693146932469334693446935469364693746938469394694046941469424694346944469454694646947469484694946950469514695246953469544695546956469574695846959469604696146962469634696446965469664696746968469694697046971469724697346974469754697646977469784697946980469814698246983469844698546986469874698846989469904699146992469934699446995469964699746998469994700047001470024700347004470054700647007470084700947010470114701247013470144701547016470174701847019470204702147022470234702447025470264702747028470294703047031470324703347034470354703647037470384703947040470414704247043470444704547046470474704847049470504705147052470534705447055470564705747058470594706047061470624706347064470654706647067470684706947070470714707247073470744707547076470774707847079470804708147082470834708447085470864708747088470894709047091470924709347094470954709647097470984709947100471014710247103471044710547106471074710847109471104711147112471134711447115471164711747118471194712047121471224712347124471254712647127471284712947130471314713247133471344713547136471374713847139471404714147142471434714447145471464714747148471494715047151471524715347154471554715647157471584715947160471614716247163471644716547166471674716847169471704717147172471734717447175471764717747178471794718047181471824718347184471854718647187471884718947190471914719247193471944719547196471974719847199472004720147202472034720447205472064720747208472094721047211472124721347214472154721647217472184721947220472214722247223472244722547226472274722847229472304723147232472334723447235472364723747238472394724047241472424724347244472454724647247472484724947250472514725247253472544725547256472574725847259472604726147262472634726447265472664726747268472694727047271472724727347274472754727647277472784727947280472814728247283472844728547286472874728847289472904729147292472934729447295472964729747298472994730047301473024730347304473054730647307473084730947310473114731247313473144731547316473174731847319473204732147322473234732447325473264732747328473294733047331473324733347334473354733647337473384733947340473414734247343473444734547346473474734847349473504735147352473534735447355473564735747358473594736047361473624736347364473654736647367473684736947370473714737247373473744737547376473774737847379473804738147382473834738447385473864738747388473894739047391473924739347394473954739647397473984739947400474014740247403474044740547406474074740847409474104741147412474134741447415474164741747418474194742047421474224742347424474254742647427474284742947430474314743247433474344743547436474374743847439474404744147442474434744447445474464744747448474494745047451474524745347454474554745647457474584745947460474614746247463474644746547466474674746847469474704747147472474734747447475474764747747478474794748047481474824748347484474854748647487474884748947490474914749247493474944749547496474974749847499475004750147502475034750447505475064750747508475094751047511475124751347514475154751647517475184751947520475214752247523475244752547526475274752847529475304753147532475334753447535475364753747538475394754047541475424754347544475454754647547475484754947550475514755247553475544755547556475574755847559475604756147562475634756447565475664756747568475694757047571475724757347574475754757647577475784757947580475814758247583475844758547586475874758847589475904759147592475934759447595475964759747598475994760047601476024760347604476054760647607476084760947610476114761247613476144761547616476174761847619476204762147622476234762447625476264762747628476294763047631476324763347634476354763647637476384763947640476414764247643476444764547646476474764847649476504765147652476534765447655476564765747658476594766047661476624766347664476654766647667476684766947670476714767247673476744767547676476774767847679476804768147682476834768447685476864768747688476894769047691476924769347694476954769647697476984769947700477014770247703477044770547706477074770847709477104771147712477134771447715477164771747718477194772047721477224772347724477254772647727477284772947730477314773247733477344773547736477374773847739477404774147742477434774447745477464774747748477494775047751477524775347754477554775647757477584775947760477614776247763477644776547766477674776847769477704777147772477734777447775477764777747778477794778047781477824778347784477854778647787477884778947790477914779247793477944779547796477974779847799478004780147802478034780447805478064780747808478094781047811478124781347814478154781647817478184781947820478214782247823478244782547826478274782847829478304783147832478334783447835478364783747838478394784047841478424784347844478454784647847478484784947850478514785247853478544785547856478574785847859478604786147862478634786447865478664786747868478694787047871478724787347874478754787647877478784787947880478814788247883478844788547886478874788847889478904789147892478934789447895478964789747898478994790047901479024790347904479054790647907479084790947910479114791247913479144791547916479174791847919479204792147922479234792447925479264792747928479294793047931479324793347934479354793647937479384793947940479414794247943479444794547946479474794847949479504795147952479534795447955479564795747958479594796047961479624796347964479654796647967479684796947970479714797247973479744797547976479774797847979479804798147982479834798447985479864798747988479894799047991479924799347994479954799647997479984799948000480014800248003480044800548006480074800848009480104801148012480134801448015480164801748018480194802048021480224802348024480254802648027480284802948030480314803248033480344803548036480374803848039480404804148042480434804448045480464804748048480494805048051480524805348054480554805648057480584805948060480614806248063480644806548066480674806848069480704807148072480734807448075480764807748078480794808048081480824808348084480854808648087480884808948090480914809248093480944809548096480974809848099481004810148102481034810448105481064810748108481094811048111481124811348114481154811648117481184811948120481214812248123481244812548126481274812848129481304813148132481334813448135481364813748138481394814048141481424814348144481454814648147481484814948150481514815248153481544815548156481574815848159481604816148162481634816448165481664816748168481694817048171481724817348174481754817648177481784817948180481814818248183481844818548186481874818848189481904819148192481934819448195481964819748198481994820048201482024820348204482054820648207482084820948210482114821248213482144821548216482174821848219482204822148222482234822448225482264822748228482294823048231482324823348234482354823648237482384823948240482414824248243482444824548246482474824848249482504825148252482534825448255482564825748258482594826048261482624826348264482654826648267482684826948270482714827248273482744827548276482774827848279482804828148282482834828448285482864828748288482894829048291482924829348294482954829648297482984829948300483014830248303483044830548306483074830848309483104831148312483134831448315483164831748318483194832048321483224832348324483254832648327483284832948330483314833248333483344833548336483374833848339483404834148342483434834448345483464834748348483494835048351483524835348354483554835648357483584835948360483614836248363483644836548366483674836848369483704837148372483734837448375483764837748378483794838048381483824838348384483854838648387483884838948390483914839248393483944839548396483974839848399484004840148402484034840448405484064840748408484094841048411484124841348414484154841648417484184841948420484214842248423484244842548426484274842848429484304843148432484334843448435484364843748438484394844048441484424844348444484454844648447484484844948450484514845248453484544845548456484574845848459484604846148462484634846448465484664846748468484694847048471484724847348474484754847648477484784847948480484814848248483484844848548486484874848848489484904849148492484934849448495484964849748498484994850048501485024850348504485054850648507485084850948510485114851248513485144851548516485174851848519485204852148522485234852448525485264852748528485294853048531485324853348534485354853648537485384853948540485414854248543485444854548546485474854848549485504855148552485534855448555485564855748558485594856048561485624856348564485654856648567485684856948570485714857248573485744857548576485774857848579485804858148582485834858448585485864858748588485894859048591485924859348594485954859648597485984859948600486014860248603486044860548606486074860848609486104861148612486134861448615486164861748618486194862048621486224862348624486254862648627486284862948630486314863248633486344863548636486374863848639486404864148642486434864448645486464864748648486494865048651486524865348654486554865648657486584865948660486614866248663486644866548666486674866848669486704867148672486734867448675486764867748678486794868048681486824868348684486854868648687486884868948690486914869248693486944869548696486974869848699487004870148702487034870448705487064870748708487094871048711487124871348714487154871648717487184871948720487214872248723487244872548726487274872848729487304873148732487334873448735487364873748738487394874048741487424874348744487454874648747487484874948750487514875248753487544875548756487574875848759487604876148762487634876448765487664876748768487694877048771487724877348774487754877648777487784877948780487814878248783487844878548786487874878848789487904879148792487934879448795487964879748798487994880048801488024880348804488054880648807488084880948810488114881248813488144881548816488174881848819488204882148822488234882448825488264882748828488294883048831488324883348834488354883648837488384883948840488414884248843488444884548846488474884848849488504885148852488534885448855488564885748858488594886048861488624886348864488654886648867488684886948870488714887248873488744887548876488774887848879488804888148882488834888448885488864888748888488894889048891488924889348894488954889648897488984889948900489014890248903489044890548906489074890848909489104891148912489134891448915489164891748918489194892048921489224892348924489254892648927489284892948930489314893248933489344893548936489374893848939489404894148942489434894448945489464894748948489494895048951489524895348954489554895648957489584895948960489614896248963489644896548966489674896848969489704897148972489734897448975489764897748978489794898048981489824898348984489854898648987489884898948990489914899248993489944899548996489974899848999490004900149002490034900449005490064900749008490094901049011490124901349014490154901649017490184901949020490214902249023490244902549026490274902849029490304903149032490334903449035490364903749038490394904049041490424904349044490454904649047490484904949050490514905249053490544905549056490574905849059490604906149062490634906449065490664906749068490694907049071490724907349074490754907649077490784907949080490814908249083490844908549086490874908849089490904909149092490934909449095490964909749098490994910049101491024910349104491054910649107491084910949110491114911249113491144911549116491174911849119491204912149122491234912449125491264912749128491294913049131491324913349134491354913649137491384913949140491414914249143491444914549146491474914849149491504915149152491534915449155491564915749158491594916049161491624916349164491654916649167491684916949170491714917249173491744917549176491774917849179491804918149182491834918449185491864918749188491894919049191491924919349194491954919649197491984919949200492014920249203492044920549206492074920849209492104921149212492134921449215492164921749218492194922049221492224922349224492254922649227492284922949230492314923249233492344923549236492374923849239492404924149242492434924449245492464924749248492494925049251492524925349254492554925649257492584925949260492614926249263492644926549266492674926849269492704927149272492734927449275492764927749278492794928049281492824928349284492854928649287492884928949290492914929249293492944929549296492974929849299493004930149302493034930449305493064930749308493094931049311493124931349314493154931649317493184931949320493214932249323493244932549326493274932849329493304933149332493334933449335493364933749338493394934049341493424934349344493454934649347493484934949350493514935249353493544935549356493574935849359493604936149362493634936449365493664936749368493694937049371493724937349374493754937649377493784937949380493814938249383493844938549386493874938849389493904939149392493934939449395493964939749398493994940049401494024940349404494054940649407494084940949410494114941249413494144941549416494174941849419494204942149422494234942449425494264942749428494294943049431494324943349434494354943649437494384943949440494414944249443494444944549446494474944849449494504945149452494534945449455494564945749458494594946049461494624946349464494654946649467494684946949470494714947249473494744947549476494774947849479494804948149482494834948449485494864948749488494894949049491494924949349494494954949649497494984949949500495014950249503495044950549506495074950849509495104951149512495134951449515495164951749518495194952049521495224952349524495254952649527495284952949530495314953249533495344953549536495374953849539495404954149542495434954449545495464954749548495494955049551495524955349554495554955649557495584955949560495614956249563495644956549566495674956849569495704957149572495734957449575495764957749578495794958049581495824958349584495854958649587495884958949590495914959249593495944959549596495974959849599496004960149602496034960449605496064960749608496094961049611496124961349614496154961649617496184961949620496214962249623496244962549626496274962849629496304963149632496334963449635496364963749638496394964049641496424964349644496454964649647496484964949650496514965249653496544965549656496574965849659496604966149662496634966449665496664966749668496694967049671496724967349674496754967649677496784967949680496814968249683496844968549686496874968849689496904969149692496934969449695496964969749698496994970049701497024970349704497054970649707497084970949710497114971249713497144971549716497174971849719497204972149722497234972449725497264972749728497294973049731497324973349734497354973649737497384973949740497414974249743497444974549746497474974849749497504975149752497534975449755497564975749758497594976049761497624976349764497654976649767497684976949770497714977249773497744977549776497774977849779497804978149782497834978449785497864978749788497894979049791497924979349794497954979649797497984979949800498014980249803498044980549806498074980849809498104981149812498134981449815498164981749818498194982049821498224982349824498254982649827498284982949830498314983249833498344983549836498374983849839498404984149842498434984449845498464984749848498494985049851498524985349854498554985649857498584985949860498614986249863498644986549866498674986849869498704987149872498734987449875498764987749878498794988049881498824988349884498854988649887498884988949890498914989249893498944989549896498974989849899499004990149902499034990449905499064990749908499094991049911499124991349914499154991649917499184991949920499214992249923499244992549926499274992849929499304993149932499334993449935499364993749938499394994049941499424994349944499454994649947499484994949950499514995249953499544995549956499574995849959499604996149962499634996449965499664996749968499694997049971499724997349974499754997649977499784997949980499814998249983499844998549986499874998849989499904999149992499934999449995499964999749998499995000050001500025000350004500055000650007500085000950010500115001250013500145001550016500175001850019500205002150022500235002450025500265002750028500295003050031500325003350034500355003650037500385003950040500415004250043500445004550046500475004850049500505005150052500535005450055500565005750058500595006050061500625006350064500655006650067500685006950070500715007250073500745007550076500775007850079500805008150082500835008450085500865008750088500895009050091500925009350094500955009650097500985009950100501015010250103501045010550106501075010850109501105011150112501135011450115501165011750118501195012050121501225012350124501255012650127501285012950130501315013250133501345013550136501375013850139501405014150142501435014450145501465014750148501495015050151501525015350154501555015650157501585015950160501615016250163501645016550166501675016850169501705017150172501735017450175501765017750178501795018050181501825018350184501855018650187501885018950190501915019250193501945019550196501975019850199502005020150202502035020450205502065020750208502095021050211502125021350214502155021650217502185021950220502215022250223502245022550226502275022850229502305023150232502335023450235502365023750238502395024050241502425024350244502455024650247502485024950250502515025250253502545025550256502575025850259502605026150262502635026450265502665026750268502695027050271502725027350274502755027650277502785027950280502815028250283502845028550286502875028850289502905029150292502935029450295502965029750298502995030050301503025030350304503055030650307503085030950310503115031250313503145031550316503175031850319503205032150322503235032450325503265032750328503295033050331503325033350334503355033650337503385033950340503415034250343503445034550346503475034850349503505035150352503535035450355503565035750358503595036050361503625036350364503655036650367503685036950370503715037250373503745037550376503775037850379503805038150382503835038450385503865038750388503895039050391503925039350394503955039650397503985039950400504015040250403504045040550406504075040850409504105041150412504135041450415504165041750418504195042050421504225042350424504255042650427504285042950430504315043250433504345043550436504375043850439504405044150442504435044450445504465044750448504495045050451504525045350454504555045650457504585045950460504615046250463504645046550466504675046850469504705047150472504735047450475504765047750478504795048050481504825048350484504855048650487504885048950490504915049250493504945049550496504975049850499505005050150502505035050450505505065050750508505095051050511505125051350514505155051650517505185051950520505215052250523505245052550526505275052850529505305053150532505335053450535505365053750538505395054050541505425054350544505455054650547505485054950550505515055250553505545055550556505575055850559505605056150562505635056450565505665056750568505695057050571505725057350574505755057650577505785057950580505815058250583505845058550586505875058850589505905059150592505935059450595505965059750598505995060050601506025060350604506055060650607506085060950610506115061250613506145061550616506175061850619506205062150622506235062450625506265062750628506295063050631506325063350634506355063650637506385063950640506415064250643506445064550646506475064850649506505065150652506535065450655506565065750658506595066050661506625066350664506655066650667506685066950670506715067250673506745067550676506775067850679506805068150682506835068450685506865068750688506895069050691506925069350694506955069650697506985069950700507015070250703507045070550706507075070850709507105071150712507135071450715507165071750718507195072050721507225072350724507255072650727507285072950730507315073250733507345073550736507375073850739507405074150742507435074450745507465074750748507495075050751507525075350754507555075650757507585075950760507615076250763507645076550766507675076850769507705077150772507735077450775507765077750778507795078050781507825078350784507855078650787507885078950790507915079250793507945079550796507975079850799508005080150802508035080450805508065080750808508095081050811508125081350814508155081650817508185081950820508215082250823508245082550826508275082850829508305083150832508335083450835508365083750838508395084050841508425084350844508455084650847508485084950850508515085250853508545085550856508575085850859508605086150862508635086450865508665086750868508695087050871508725087350874508755087650877508785087950880508815088250883508845088550886508875088850889508905089150892508935089450895508965089750898508995090050901509025090350904509055090650907509085090950910509115091250913509145091550916509175091850919509205092150922509235092450925509265092750928509295093050931509325093350934509355093650937509385093950940509415094250943509445094550946509475094850949509505095150952509535095450955509565095750958509595096050961509625096350964509655096650967509685096950970509715097250973509745097550976509775097850979509805098150982509835098450985509865098750988509895099050991509925099350994509955099650997509985099951000510015100251003510045100551006510075100851009510105101151012510135101451015510165101751018510195102051021510225102351024510255102651027510285102951030510315103251033510345103551036510375103851039510405104151042510435104451045510465104751048510495105051051510525105351054510555105651057510585105951060510615106251063510645106551066510675106851069510705107151072510735107451075510765107751078510795108051081510825108351084510855108651087510885108951090510915109251093510945109551096510975109851099511005110151102511035110451105511065110751108511095111051111511125111351114511155111651117511185111951120511215112251123511245112551126511275112851129511305113151132511335113451135511365113751138511395114051141511425114351144511455114651147511485114951150511515115251153511545115551156511575115851159511605116151162511635116451165511665116751168511695117051171511725117351174511755117651177511785117951180511815118251183511845118551186511875118851189511905119151192511935119451195511965119751198511995120051201512025120351204512055120651207512085120951210512115121251213512145121551216512175121851219512205122151222512235122451225512265122751228512295123051231512325123351234512355123651237512385123951240512415124251243512445124551246512475124851249512505125151252512535125451255512565125751258512595126051261512625126351264512655126651267512685126951270512715127251273512745127551276512775127851279512805128151282512835128451285512865128751288512895129051291512925129351294512955129651297512985129951300513015130251303513045130551306513075130851309513105131151312513135131451315513165131751318513195132051321513225132351324513255132651327513285132951330513315133251333513345133551336513375133851339513405134151342513435134451345513465134751348513495135051351513525135351354513555135651357513585135951360513615136251363513645136551366513675136851369513705137151372513735137451375513765137751378513795138051381513825138351384513855138651387513885138951390513915139251393513945139551396513975139851399514005140151402514035140451405514065140751408514095141051411514125141351414514155141651417514185141951420514215142251423514245142551426514275142851429514305143151432514335143451435514365143751438514395144051441514425144351444514455144651447514485144951450514515145251453514545145551456514575145851459514605146151462514635146451465514665146751468514695147051471514725147351474514755147651477514785147951480514815148251483514845148551486514875148851489514905149151492514935149451495514965149751498514995150051501515025150351504515055150651507515085150951510515115151251513515145151551516515175151851519515205152151522515235152451525515265152751528515295153051531515325153351534515355153651537515385153951540515415154251543515445154551546515475154851549515505155151552515535155451555515565155751558515595156051561515625156351564515655156651567515685156951570515715157251573515745157551576515775157851579515805158151582515835158451585515865158751588515895159051591515925159351594515955159651597515985159951600516015160251603516045160551606516075160851609516105161151612516135161451615516165161751618516195162051621516225162351624516255162651627516285162951630516315163251633516345163551636516375163851639516405164151642516435164451645516465164751648516495165051651516525165351654516555165651657516585165951660516615166251663516645166551666516675166851669516705167151672516735167451675516765167751678516795168051681516825168351684516855168651687516885168951690516915169251693516945169551696516975169851699517005170151702517035170451705517065170751708517095171051711517125171351714517155171651717517185171951720517215172251723517245172551726517275172851729517305173151732517335173451735517365173751738517395174051741517425174351744517455174651747517485174951750517515175251753517545175551756517575175851759517605176151762517635176451765517665176751768517695177051771517725177351774517755177651777517785177951780517815178251783517845178551786517875178851789517905179151792517935179451795517965179751798517995180051801518025180351804518055180651807518085180951810518115181251813518145181551816518175181851819518205182151822518235182451825518265182751828518295183051831518325183351834518355183651837518385183951840518415184251843518445184551846518475184851849518505185151852518535185451855518565185751858518595186051861518625186351864518655186651867518685186951870518715187251873518745187551876518775187851879518805188151882518835188451885518865188751888518895189051891518925189351894518955189651897518985189951900519015190251903519045190551906519075190851909519105191151912519135191451915519165191751918519195192051921519225192351924519255192651927519285192951930519315193251933519345193551936519375193851939519405194151942519435194451945519465194751948519495195051951519525195351954519555195651957519585195951960519615196251963519645196551966519675196851969519705197151972519735197451975519765197751978519795198051981519825198351984519855198651987519885198951990519915199251993519945199551996519975199851999520005200152002520035200452005520065200752008520095201052011520125201352014520155201652017520185201952020520215202252023520245202552026520275202852029520305203152032520335203452035520365203752038520395204052041520425204352044520455204652047520485204952050520515205252053520545205552056520575205852059520605206152062520635206452065520665206752068520695207052071520725207352074520755207652077520785207952080520815208252083520845208552086520875208852089520905209152092520935209452095520965209752098520995210052101521025210352104521055210652107521085210952110521115211252113521145211552116521175211852119521205212152122521235212452125521265212752128521295213052131521325213352134521355213652137521385213952140521415214252143521445214552146521475214852149521505215152152521535215452155521565215752158521595216052161521625216352164521655216652167521685216952170521715217252173521745217552176521775217852179521805218152182521835218452185521865218752188521895219052191521925219352194521955219652197521985219952200522015220252203522045220552206522075220852209522105221152212522135221452215522165221752218522195222052221522225222352224522255222652227522285222952230522315223252233522345223552236522375223852239522405224152242522435224452245522465224752248522495225052251522525225352254522555225652257522585225952260522615226252263522645226552266522675226852269522705227152272522735227452275522765227752278522795228052281522825228352284522855228652287522885228952290522915229252293522945229552296522975229852299523005230152302523035230452305523065230752308523095231052311523125231352314523155231652317523185231952320523215232252323523245232552326523275232852329523305233152332523335233452335523365233752338523395234052341523425234352344523455234652347523485234952350523515235252353523545235552356523575235852359523605236152362523635236452365523665236752368523695237052371523725237352374523755237652377523785237952380523815238252383523845238552386523875238852389523905239152392523935239452395523965239752398523995240052401524025240352404524055240652407524085240952410524115241252413524145241552416524175241852419524205242152422524235242452425524265242752428524295243052431524325243352434524355243652437524385243952440524415244252443524445244552446524475244852449524505245152452524535245452455524565245752458524595246052461524625246352464524655246652467524685246952470524715247252473524745247552476524775247852479524805248152482524835248452485524865248752488524895249052491524925249352494524955249652497524985249952500525015250252503525045250552506525075250852509525105251152512525135251452515525165251752518525195252052521525225252352524525255252652527525285252952530525315253252533525345253552536525375253852539525405254152542525435254452545525465254752548525495255052551525525255352554525555255652557525585255952560525615256252563525645256552566525675256852569525705257152572525735257452575525765257752578525795258052581525825258352584525855258652587525885258952590525915259252593525945259552596525975259852599526005260152602526035260452605526065260752608526095261052611526125261352614526155261652617526185261952620526215262252623526245262552626526275262852629526305263152632526335263452635526365263752638526395264052641526425264352644526455264652647526485264952650526515265252653526545265552656526575265852659526605266152662526635266452665526665266752668526695267052671526725267352674526755267652677526785267952680526815268252683526845268552686526875268852689526905269152692526935269452695526965269752698526995270052701527025270352704527055270652707527085270952710527115271252713527145271552716527175271852719527205272152722527235272452725527265272752728527295273052731527325273352734527355273652737527385273952740527415274252743527445274552746527475274852749527505275152752527535275452755527565275752758527595276052761527625276352764527655276652767527685276952770527715277252773527745277552776527775277852779527805278152782527835278452785527865278752788527895279052791527925279352794527955279652797527985279952800528015280252803528045280552806528075280852809528105281152812528135281452815528165281752818528195282052821528225282352824528255282652827528285282952830528315283252833528345283552836528375283852839528405284152842528435284452845528465284752848528495285052851528525285352854528555285652857528585285952860528615286252863528645286552866528675286852869528705287152872528735287452875528765287752878528795288052881528825288352884528855288652887528885288952890528915289252893528945289552896528975289852899529005290152902529035290452905529065290752908529095291052911529125291352914529155291652917529185291952920529215292252923529245292552926529275292852929529305293152932529335293452935529365293752938529395294052941529425294352944529455294652947529485294952950529515295252953529545295552956529575295852959529605296152962529635296452965529665296752968529695297052971529725297352974529755297652977529785297952980529815298252983529845298552986529875298852989529905299152992529935299452995529965299752998529995300053001530025300353004530055300653007530085300953010530115301253013530145301553016530175301853019530205302153022530235302453025530265302753028530295303053031530325303353034530355303653037530385303953040530415304253043530445304553046530475304853049530505305153052530535305453055530565305753058530595306053061530625306353064530655306653067530685306953070530715307253073530745307553076530775307853079530805308153082530835308453085530865308753088530895309053091530925309353094530955309653097530985309953100531015310253103531045310553106531075310853109531105311153112531135311453115531165311753118531195312053121531225312353124531255312653127531285312953130531315313253133531345313553136531375313853139531405314153142531435314453145531465314753148531495315053151531525315353154531555315653157531585315953160531615316253163531645316553166531675316853169531705317153172531735317453175531765317753178531795318053181531825318353184531855318653187531885318953190531915319253193531945319553196531975319853199532005320153202532035320453205532065320753208532095321053211532125321353214532155321653217532185321953220532215322253223532245322553226532275322853229532305323153232532335323453235532365323753238532395324053241532425324353244532455324653247532485324953250532515325253253532545325553256532575325853259532605326153262532635326453265532665326753268532695327053271532725327353274532755327653277532785327953280532815328253283532845328553286532875328853289532905329153292532935329453295532965329753298532995330053301533025330353304533055330653307533085330953310533115331253313533145331553316533175331853319533205332153322533235332453325533265332753328533295333053331533325333353334533355333653337533385333953340533415334253343533445334553346533475334853349533505335153352533535335453355533565335753358533595336053361533625336353364533655336653367533685336953370533715337253373533745337553376533775337853379533805338153382533835338453385533865338753388533895339053391533925339353394533955339653397533985339953400534015340253403534045340553406534075340853409534105341153412534135341453415534165341753418534195342053421534225342353424534255342653427534285342953430534315343253433534345343553436534375343853439534405344153442534435344453445534465344753448534495345053451534525345353454534555345653457534585345953460534615346253463534645346553466534675346853469534705347153472534735347453475534765347753478534795348053481534825348353484534855348653487534885348953490534915349253493534945349553496534975349853499535005350153502535035350453505535065350753508535095351053511535125351353514535155351653517535185351953520535215352253523535245352553526535275352853529535305353153532535335353453535535365353753538535395354053541535425354353544535455354653547535485354953550535515355253553535545355553556535575355853559535605356153562535635356453565535665356753568535695357053571535725357353574535755357653577535785357953580535815358253583535845358553586535875358853589535905359153592535935359453595535965359753598535995360053601536025360353604536055360653607536085360953610536115361253613536145361553616536175361853619536205362153622536235362453625536265362753628536295363053631536325363353634536355363653637536385363953640536415364253643536445364553646536475364853649536505365153652536535365453655536565365753658536595366053661536625366353664536655366653667536685366953670536715367253673536745367553676536775367853679536805368153682536835368453685536865368753688536895369053691536925369353694536955369653697536985369953700537015370253703537045370553706537075370853709537105371153712537135371453715537165371753718537195372053721537225372353724537255372653727537285372953730537315373253733537345373553736537375373853739537405374153742537435374453745537465374753748537495375053751537525375353754537555375653757537585375953760537615376253763537645376553766537675376853769537705377153772537735377453775537765377753778537795378053781537825378353784537855378653787537885378953790537915379253793537945379553796537975379853799538005380153802538035380453805538065380753808538095381053811538125381353814538155381653817538185381953820538215382253823538245382553826538275382853829538305383153832538335383453835538365383753838538395384053841538425384353844538455384653847538485384953850538515385253853538545385553856538575385853859538605386153862538635386453865538665386753868538695387053871538725387353874538755387653877538785387953880538815388253883538845388553886538875388853889538905389153892538935389453895538965389753898538995390053901539025390353904539055390653907539085390953910539115391253913539145391553916539175391853919539205392153922539235392453925539265392753928539295393053931539325393353934539355393653937539385393953940539415394253943539445394553946539475394853949539505395153952539535395453955539565395753958539595396053961539625396353964539655396653967539685396953970539715397253973539745397553976539775397853979539805398153982539835398453985539865398753988539895399053991539925399353994539955399653997539985399954000540015400254003540045400554006540075400854009540105401154012540135401454015540165401754018540195402054021540225402354024540255402654027540285402954030540315403254033540345403554036540375403854039540405404154042540435404454045540465404754048540495405054051540525405354054540555405654057540585405954060540615406254063540645406554066540675406854069540705407154072540735407454075540765407754078540795408054081540825408354084540855408654087540885408954090540915409254093540945409554096540975409854099541005410154102541035410454105541065410754108541095411054111541125411354114541155411654117541185411954120541215412254123541245412554126541275412854129541305413154132541335413454135541365413754138541395414054141541425414354144541455414654147541485414954150541515415254153541545415554156541575415854159541605416154162541635416454165541665416754168541695417054171541725417354174541755417654177541785417954180541815418254183541845418554186541875418854189541905419154192541935419454195541965419754198541995420054201542025420354204542055420654207542085420954210542115421254213542145421554216542175421854219542205422154222542235422454225542265422754228542295423054231542325423354234542355423654237542385423954240542415424254243542445424554246542475424854249542505425154252542535425454255542565425754258542595426054261542625426354264542655426654267542685426954270542715427254273542745427554276542775427854279542805428154282542835428454285542865428754288542895429054291542925429354294542955429654297542985429954300543015430254303543045430554306543075430854309543105431154312543135431454315543165431754318543195432054321543225432354324543255432654327543285432954330543315433254333543345433554336543375433854339543405434154342543435434454345543465434754348543495435054351543525435354354543555435654357543585435954360543615436254363543645436554366543675436854369543705437154372543735437454375543765437754378543795438054381543825438354384543855438654387543885438954390543915439254393543945439554396543975439854399544005440154402544035440454405544065440754408544095441054411544125441354414544155441654417544185441954420544215442254423544245442554426544275442854429544305443154432544335443454435544365443754438544395444054441544425444354444544455444654447544485444954450544515445254453544545445554456544575445854459544605446154462544635446454465544665446754468544695447054471544725447354474544755447654477544785447954480544815448254483544845448554486544875448854489544905449154492544935449454495544965449754498544995450054501545025450354504545055450654507545085450954510545115451254513545145451554516545175451854519545205452154522545235452454525545265452754528545295453054531545325453354534545355453654537545385453954540545415454254543545445454554546545475454854549545505455154552545535455454555545565455754558545595456054561545625456354564545655456654567545685456954570545715457254573545745457554576545775457854579545805458154582545835458454585545865458754588545895459054591545925459354594545955459654597545985459954600546015460254603546045460554606546075460854609546105461154612546135461454615546165461754618546195462054621546225462354624546255462654627546285462954630546315463254633546345463554636546375463854639546405464154642546435464454645546465464754648546495465054651546525465354654546555465654657546585465954660546615466254663546645466554666546675466854669546705467154672546735467454675546765467754678546795468054681546825468354684546855468654687546885468954690546915469254693546945469554696546975469854699547005470154702547035470454705547065470754708547095471054711547125471354714547155471654717547185471954720547215472254723547245472554726547275472854729547305473154732547335473454735547365473754738547395474054741547425474354744547455474654747547485474954750547515475254753547545475554756547575475854759547605476154762547635476454765547665476754768547695477054771547725477354774547755477654777547785477954780547815478254783547845478554786547875478854789547905479154792547935479454795547965479754798547995480054801548025480354804548055480654807548085480954810548115481254813548145481554816548175481854819548205482154822548235482454825548265482754828548295483054831548325483354834548355483654837548385483954840548415484254843548445484554846548475484854849548505485154852548535485454855548565485754858548595486054861548625486354864548655486654867548685486954870548715487254873548745487554876548775487854879548805488154882548835488454885548865488754888548895489054891548925489354894548955489654897548985489954900549015490254903549045490554906549075490854909549105491154912549135491454915549165491754918549195492054921549225492354924549255492654927549285492954930549315493254933549345493554936549375493854939549405494154942549435494454945549465494754948549495495054951549525495354954549555495654957549585495954960549615496254963549645496554966549675496854969549705497154972549735497454975549765497754978549795498054981549825498354984549855498654987549885498954990549915499254993549945499554996549975499854999550005500155002550035500455005550065500755008550095501055011550125501355014550155501655017550185501955020550215502255023550245502555026550275502855029550305503155032550335503455035550365503755038550395504055041550425504355044550455504655047550485504955050550515505255053550545505555056550575505855059550605506155062550635506455065550665506755068550695507055071550725507355074550755507655077550785507955080550815508255083550845508555086550875508855089550905509155092550935509455095550965509755098550995510055101551025510355104551055510655107551085510955110551115511255113551145511555116551175511855119551205512155122551235512455125551265512755128551295513055131551325513355134551355513655137551385513955140551415514255143551445514555146551475514855149551505515155152551535515455155551565515755158551595516055161551625516355164551655516655167551685516955170551715517255173551745517555176551775517855179551805518155182551835518455185551865518755188551895519055191551925519355194551955519655197551985519955200552015520255203552045520555206552075520855209552105521155212552135521455215552165521755218552195522055221552225522355224552255522655227552285522955230552315523255233552345523555236552375523855239552405524155242552435524455245552465524755248552495525055251552525525355254552555525655257552585525955260552615526255263552645526555266552675526855269552705527155272552735527455275552765527755278552795528055281552825528355284552855528655287552885528955290552915529255293552945529555296552975529855299553005530155302553035530455305553065530755308553095531055311553125531355314553155531655317553185531955320553215532255323553245532555326553275532855329553305533155332553335533455335553365533755338553395534055341553425534355344553455534655347553485534955350553515535255353553545535555356553575535855359553605536155362553635536455365553665536755368553695537055371553725537355374553755537655377553785537955380553815538255383553845538555386553875538855389553905539155392553935539455395553965539755398553995540055401554025540355404554055540655407554085540955410554115541255413554145541555416554175541855419554205542155422554235542455425554265542755428554295543055431554325543355434554355543655437554385543955440554415544255443554445544555446554475544855449554505545155452554535545455455554565545755458554595546055461554625546355464554655546655467554685546955470554715547255473554745547555476554775547855479554805548155482554835548455485554865548755488554895549055491554925549355494554955549655497554985549955500555015550255503555045550555506555075550855509555105551155512555135551455515555165551755518555195552055521555225552355524555255552655527555285552955530555315553255533555345553555536555375553855539555405554155542555435554455545555465554755548555495555055551555525555355554555555555655557555585555955560555615556255563555645556555566555675556855569555705557155572555735557455575555765557755578555795558055581555825558355584555855558655587555885558955590555915559255593555945559555596555975559855599556005560155602556035560455605556065560755608556095561055611556125561355614556155561655617556185561955620556215562255623556245562555626556275562855629556305563155632556335563455635556365563755638556395564055641556425564355644556455564655647556485564955650556515565255653556545565555656556575565855659556605566155662556635566455665556665566755668556695567055671556725567355674556755567655677556785567955680556815568255683556845568555686556875568855689556905569155692556935569455695556965569755698556995570055701557025570355704557055570655707557085570955710557115571255713557145571555716557175571855719557205572155722557235572455725557265572755728557295573055731557325573355734557355573655737557385573955740557415574255743557445574555746557475574855749557505575155752557535575455755557565575755758557595576055761557625576355764557655576655767557685576955770557715577255773557745577555776557775577855779557805578155782557835578455785557865578755788557895579055791557925579355794557955579655797557985579955800558015580255803558045580555806558075580855809558105581155812558135581455815558165581755818558195582055821558225582355824558255582655827558285582955830558315583255833558345583555836558375583855839558405584155842558435584455845558465584755848558495585055851558525585355854558555585655857558585585955860558615586255863558645586555866558675586855869558705587155872558735587455875558765587755878558795588055881558825588355884558855588655887558885588955890558915589255893558945589555896558975589855899559005590155902559035590455905559065590755908559095591055911559125591355914559155591655917559185591955920559215592255923559245592555926559275592855929559305593155932559335593455935559365593755938559395594055941559425594355944559455594655947559485594955950559515595255953559545595555956559575595855959559605596155962559635596455965559665596755968559695597055971559725597355974559755597655977559785597955980559815598255983559845598555986559875598855989559905599155992559935599455995559965599755998559995600056001560025600356004560055600656007560085600956010560115601256013560145601556016560175601856019560205602156022560235602456025560265602756028560295603056031560325603356034560355603656037560385603956040560415604256043560445604556046560475604856049560505605156052560535605456055560565605756058560595606056061560625606356064560655606656067560685606956070560715607256073560745607556076560775607856079560805608156082560835608456085560865608756088560895609056091560925609356094560955609656097560985609956100561015610256103561045610556106561075610856109561105611156112561135611456115561165611756118561195612056121561225612356124561255612656127561285612956130561315613256133561345613556136561375613856139561405614156142561435614456145561465614756148561495615056151561525615356154561555615656157561585615956160561615616256163561645616556166561675616856169561705617156172561735617456175561765617756178561795618056181561825618356184561855618656187561885618956190561915619256193561945619556196561975619856199562005620156202562035620456205562065620756208562095621056211562125621356214562155621656217562185621956220562215622256223562245622556226562275622856229562305623156232562335623456235562365623756238562395624056241562425624356244562455624656247562485624956250562515625256253562545625556256562575625856259562605626156262562635626456265562665626756268562695627056271562725627356274562755627656277562785627956280562815628256283562845628556286562875628856289562905629156292562935629456295562965629756298562995630056301563025630356304563055630656307563085630956310563115631256313563145631556316563175631856319563205632156322563235632456325563265632756328563295633056331563325633356334563355633656337563385633956340563415634256343563445634556346563475634856349563505635156352563535635456355563565635756358563595636056361563625636356364563655636656367563685636956370563715637256373563745637556376563775637856379563805638156382563835638456385563865638756388563895639056391563925639356394563955639656397563985639956400564015640256403564045640556406564075640856409564105641156412564135641456415564165641756418564195642056421564225642356424564255642656427564285642956430564315643256433564345643556436564375643856439564405644156442564435644456445564465644756448564495645056451564525645356454564555645656457564585645956460564615646256463564645646556466564675646856469564705647156472564735647456475564765647756478564795648056481564825648356484564855648656487564885648956490564915649256493564945649556496564975649856499565005650156502565035650456505565065650756508565095651056511565125651356514565155651656517565185651956520565215652256523565245652556526565275652856529565305653156532565335653456535565365653756538565395654056541565425654356544565455654656547565485654956550565515655256553565545655556556565575655856559565605656156562565635656456565565665656756568565695657056571565725657356574565755657656577565785657956580565815658256583565845658556586565875658856589565905659156592565935659456595565965659756598565995660056601566025660356604566055660656607566085660956610566115661256613566145661556616566175661856619566205662156622566235662456625566265662756628566295663056631566325663356634566355663656637566385663956640566415664256643566445664556646566475664856649566505665156652566535665456655566565665756658566595666056661566625666356664566655666656667566685666956670566715667256673566745667556676566775667856679566805668156682566835668456685566865668756688566895669056691566925669356694566955669656697566985669956700567015670256703567045670556706567075670856709567105671156712567135671456715567165671756718567195672056721567225672356724567255672656727567285672956730567315673256733567345673556736567375673856739567405674156742567435674456745567465674756748567495675056751567525675356754567555675656757567585675956760567615676256763567645676556766567675676856769567705677156772567735677456775567765677756778567795678056781567825678356784567855678656787567885678956790567915679256793567945679556796567975679856799568005680156802568035680456805568065680756808568095681056811568125681356814568155681656817568185681956820568215682256823568245682556826568275682856829568305683156832568335683456835568365683756838568395684056841568425684356844568455684656847568485684956850568515685256853568545685556856568575685856859568605686156862568635686456865568665686756868568695687056871568725687356874568755687656877568785687956880568815688256883568845688556886568875688856889568905689156892568935689456895568965689756898568995690056901569025690356904569055690656907569085690956910569115691256913569145691556916569175691856919569205692156922569235692456925569265692756928569295693056931569325693356934569355693656937569385693956940569415694256943569445694556946569475694856949569505695156952569535695456955569565695756958569595696056961569625696356964569655696656967569685696956970569715697256973569745697556976569775697856979569805698156982569835698456985569865698756988569895699056991569925699356994569955699656997569985699957000570015700257003570045700557006570075700857009570105701157012570135701457015570165701757018570195702057021570225702357024570255702657027570285702957030570315703257033570345703557036570375703857039570405704157042570435704457045570465704757048570495705057051570525705357054570555705657057570585705957060570615706257063570645706557066570675706857069570705707157072570735707457075570765707757078570795708057081570825708357084570855708657087570885708957090570915709257093570945709557096570975709857099571005710157102571035710457105571065710757108571095711057111571125711357114571155711657117571185711957120571215712257123571245712557126571275712857129571305713157132571335713457135571365713757138571395714057141571425714357144571455714657147571485714957150571515715257153571545715557156571575715857159571605716157162571635716457165571665716757168571695717057171571725717357174571755717657177571785717957180571815718257183571845718557186571875718857189571905719157192571935719457195571965719757198571995720057201572025720357204572055720657207572085720957210572115721257213572145721557216572175721857219572205722157222572235722457225572265722757228572295723057231572325723357234572355723657237572385723957240572415724257243572445724557246572475724857249572505725157252572535725457255572565725757258572595726057261572625726357264572655726657267572685726957270572715727257273572745727557276572775727857279572805728157282572835728457285572865728757288572895729057291572925729357294572955729657297572985729957300573015730257303573045730557306573075730857309573105731157312573135731457315573165731757318573195732057321573225732357324573255732657327573285732957330573315733257333573345733557336573375733857339573405734157342573435734457345573465734757348573495735057351573525735357354573555735657357573585735957360573615736257363573645736557366573675736857369573705737157372573735737457375573765737757378573795738057381573825738357384573855738657387573885738957390573915739257393573945739557396573975739857399574005740157402574035740457405574065740757408574095741057411574125741357414574155741657417574185741957420574215742257423574245742557426574275742857429574305743157432574335743457435574365743757438574395744057441574425744357444574455744657447574485744957450574515745257453574545745557456574575745857459574605746157462574635746457465574665746757468574695747057471574725747357474574755747657477574785747957480574815748257483574845748557486574875748857489574905749157492574935749457495574965749757498574995750057501575025750357504575055750657507575085750957510575115751257513575145751557516575175751857519575205752157522575235752457525575265752757528575295753057531575325753357534575355753657537575385753957540575415754257543575445754557546575475754857549575505755157552575535755457555575565755757558575595756057561575625756357564575655756657567575685756957570575715757257573575745757557576575775757857579575805758157582575835758457585575865758757588575895759057591575925759357594575955759657597575985759957600576015760257603576045760557606576075760857609576105761157612576135761457615576165761757618576195762057621576225762357624576255762657627576285762957630576315763257633576345763557636576375763857639576405764157642576435764457645576465764757648576495765057651576525765357654576555765657657576585765957660576615766257663576645766557666576675766857669576705767157672576735767457675576765767757678576795768057681576825768357684576855768657687576885768957690576915769257693576945769557696576975769857699577005770157702577035770457705577065770757708577095771057711577125771357714577155771657717577185771957720577215772257723577245772557726577275772857729577305773157732577335773457735577365773757738577395774057741577425774357744577455774657747577485774957750577515775257753577545775557756577575775857759577605776157762577635776457765577665776757768577695777057771577725777357774577755777657777577785777957780577815778257783577845778557786577875778857789577905779157792577935779457795577965779757798577995780057801578025780357804578055780657807578085780957810578115781257813578145781557816578175781857819578205782157822578235782457825578265782757828578295783057831578325783357834578355783657837578385783957840578415784257843578445784557846578475784857849578505785157852578535785457855578565785757858578595786057861578625786357864578655786657867578685786957870578715787257873578745787557876578775787857879578805788157882578835788457885578865788757888578895789057891578925789357894578955789657897578985789957900579015790257903579045790557906579075790857909579105791157912579135791457915579165791757918579195792057921579225792357924579255792657927579285792957930579315793257933579345793557936579375793857939579405794157942579435794457945579465794757948579495795057951579525795357954579555795657957579585795957960579615796257963579645796557966579675796857969579705797157972579735797457975579765797757978579795798057981579825798357984579855798657987579885798957990579915799257993579945799557996579975799857999580005800158002580035800458005580065800758008580095801058011580125801358014580155801658017580185801958020580215802258023580245802558026580275802858029580305803158032580335803458035580365803758038580395804058041580425804358044580455804658047580485804958050580515805258053580545805558056580575805858059580605806158062580635806458065580665806758068580695807058071580725807358074580755807658077580785807958080580815808258083580845808558086580875808858089580905809158092580935809458095580965809758098580995810058101581025810358104581055810658107581085810958110581115811258113581145811558116581175811858119581205812158122581235812458125581265812758128581295813058131581325813358134581355813658137581385813958140581415814258143581445814558146581475814858149581505815158152581535815458155581565815758158581595816058161581625816358164581655816658167581685816958170581715817258173581745817558176581775817858179581805818158182581835818458185581865818758188581895819058191581925819358194581955819658197581985819958200582015820258203582045820558206582075820858209582105821158212582135821458215582165821758218582195822058221582225822358224582255822658227582285822958230582315823258233582345823558236582375823858239582405824158242582435824458245582465824758248582495825058251582525825358254582555825658257582585825958260582615826258263582645826558266582675826858269582705827158272582735827458275582765827758278582795828058281582825828358284582855828658287582885828958290582915829258293582945829558296582975829858299583005830158302583035830458305583065830758308583095831058311583125831358314583155831658317583185831958320583215832258323583245832558326583275832858329583305833158332583335833458335583365833758338583395834058341583425834358344583455834658347583485834958350583515835258353583545835558356583575835858359583605836158362583635836458365583665836758368583695837058371583725837358374583755837658377583785837958380583815838258383583845838558386583875838858389583905839158392583935839458395583965839758398583995840058401584025840358404584055840658407584085840958410584115841258413584145841558416584175841858419584205842158422584235842458425584265842758428584295843058431584325843358434584355843658437584385843958440584415844258443584445844558446584475844858449584505845158452584535845458455584565845758458584595846058461584625846358464584655846658467584685846958470584715847258473584745847558476584775847858479584805848158482584835848458485584865848758488584895849058491584925849358494584955849658497584985849958500585015850258503585045850558506585075850858509585105851158512585135851458515585165851758518585195852058521585225852358524585255852658527585285852958530585315853258533585345853558536585375853858539585405854158542585435854458545585465854758548585495855058551585525855358554585555855658557585585855958560585615856258563585645856558566585675856858569585705857158572585735857458575585765857758578585795858058581585825858358584585855858658587585885858958590585915859258593585945859558596585975859858599586005860158602586035860458605586065860758608586095861058611586125861358614586155861658617586185861958620586215862258623586245862558626586275862858629586305863158632586335863458635586365863758638586395864058641586425864358644586455864658647586485864958650586515865258653586545865558656586575865858659586605866158662586635866458665586665866758668586695867058671586725867358674586755867658677586785867958680586815868258683586845868558686586875868858689586905869158692586935869458695586965869758698586995870058701587025870358704587055870658707587085870958710587115871258713587145871558716587175871858719587205872158722587235872458725587265872758728587295873058731587325873358734587355873658737587385873958740587415874258743587445874558746587475874858749587505875158752587535875458755587565875758758587595876058761587625876358764587655876658767587685876958770587715877258773587745877558776587775877858779587805878158782587835878458785587865878758788587895879058791587925879358794587955879658797587985879958800588015880258803588045880558806588075880858809588105881158812588135881458815588165881758818588195882058821588225882358824588255882658827588285882958830588315883258833588345883558836588375883858839588405884158842588435884458845588465884758848588495885058851588525885358854588555885658857588585885958860588615886258863588645886558866588675886858869588705887158872588735887458875588765887758878588795888058881588825888358884588855888658887588885888958890588915889258893588945889558896588975889858899589005890158902589035890458905589065890758908589095891058911589125891358914589155891658917589185891958920589215892258923589245892558926589275892858929589305893158932589335893458935589365893758938589395894058941589425894358944589455894658947589485894958950589515895258953589545895558956589575895858959589605896158962589635896458965589665896758968589695897058971589725897358974589755897658977589785897958980589815898258983589845898558986589875898858989589905899158992589935899458995589965899758998589995900059001590025900359004590055900659007590085900959010590115901259013590145901559016590175901859019590205902159022590235902459025590265902759028590295903059031590325903359034590355903659037590385903959040590415904259043590445904559046590475904859049590505905159052590535905459055590565905759058590595906059061590625906359064590655906659067590685906959070590715907259073590745907559076590775907859079590805908159082590835908459085590865908759088590895909059091590925909359094590955909659097590985909959100591015910259103591045910559106591075910859109591105911159112591135911459115591165911759118591195912059121591225912359124591255912659127591285912959130591315913259133591345913559136591375913859139591405914159142591435914459145591465914759148591495915059151591525915359154591555915659157591585915959160591615916259163591645916559166591675916859169591705917159172591735917459175591765917759178591795918059181591825918359184591855918659187591885918959190591915919259193591945919559196591975919859199592005920159202592035920459205592065920759208592095921059211592125921359214592155921659217592185921959220592215922259223592245922559226592275922859229592305923159232592335923459235592365923759238592395924059241592425924359244592455924659247592485924959250592515925259253592545925559256592575925859259592605926159262592635926459265592665926759268592695927059271592725927359274592755927659277592785927959280592815928259283592845928559286592875928859289592905929159292592935929459295592965929759298592995930059301593025930359304593055930659307593085930959310593115931259313593145931559316593175931859319593205932159322593235932459325593265932759328593295933059331593325933359334593355933659337593385933959340593415934259343593445934559346593475934859349593505935159352593535935459355593565935759358593595936059361593625936359364593655936659367593685936959370593715937259373593745937559376593775937859379593805938159382593835938459385593865938759388593895939059391593925939359394593955939659397593985939959400594015940259403594045940559406594075940859409594105941159412594135941459415594165941759418594195942059421594225942359424594255942659427594285942959430594315943259433594345943559436594375943859439594405944159442594435944459445594465944759448594495945059451594525945359454594555945659457594585945959460594615946259463594645946559466594675946859469594705947159472594735947459475594765947759478594795948059481594825948359484594855948659487594885948959490594915949259493594945949559496594975949859499595005950159502595035950459505595065950759508595095951059511595125951359514595155951659517595185951959520595215952259523595245952559526595275952859529595305953159532595335953459535595365953759538595395954059541595425954359544595455954659547595485954959550595515955259553595545955559556595575955859559595605956159562595635956459565595665956759568595695957059571595725957359574595755957659577595785957959580595815958259583595845958559586595875958859589595905959159592595935959459595595965959759598595995960059601596025960359604596055960659607596085960959610596115961259613596145961559616596175961859619596205962159622596235962459625596265962759628596295963059631596325963359634596355963659637596385963959640596415964259643596445964559646596475964859649596505965159652596535965459655596565965759658596595966059661596625966359664596655966659667596685966959670596715967259673596745967559676596775967859679596805968159682596835968459685596865968759688596895969059691596925969359694596955969659697596985969959700597015970259703597045970559706597075970859709597105971159712597135971459715597165971759718597195972059721597225972359724597255972659727597285972959730597315973259733597345973559736597375973859739597405974159742597435974459745597465974759748597495975059751597525975359754597555975659757597585975959760597615976259763597645976559766597675976859769597705977159772597735977459775597765977759778597795978059781597825978359784597855978659787597885978959790597915979259793597945979559796597975979859799598005980159802598035980459805598065980759808598095981059811598125981359814598155981659817598185981959820598215982259823598245982559826598275982859829598305983159832598335983459835598365983759838598395984059841598425984359844598455984659847598485984959850598515985259853598545985559856598575985859859598605986159862598635986459865598665986759868598695987059871598725987359874598755987659877598785987959880598815988259883598845988559886598875988859889598905989159892598935989459895598965989759898598995990059901599025990359904599055990659907599085990959910599115991259913599145991559916599175991859919599205992159922599235992459925599265992759928599295993059931599325993359934599355993659937599385993959940599415994259943599445994559946599475994859949599505995159952599535995459955599565995759958599595996059961599625996359964599655996659967599685996959970599715997259973599745997559976599775997859979599805998159982599835998459985599865998759988599895999059991599925999359994599955999659997599985999960000600016000260003600046000560006600076000860009600106001160012600136001460015600166001760018600196002060021600226002360024600256002660027600286002960030600316003260033600346003560036600376003860039600406004160042600436004460045600466004760048600496005060051600526005360054600556005660057600586005960060600616006260063600646006560066600676006860069600706007160072600736007460075600766007760078600796008060081600826008360084600856008660087600886008960090600916009260093600946009560096600976009860099601006010160102601036010460105601066010760108601096011060111601126011360114601156011660117601186011960120601216012260123601246012560126601276012860129601306013160132601336013460135601366013760138601396014060141601426014360144601456014660147601486014960150601516015260153601546015560156601576015860159601606016160162601636016460165601666016760168601696017060171601726017360174601756017660177601786017960180601816018260183601846018560186601876018860189601906019160192601936019460195601966019760198601996020060201602026020360204602056020660207602086020960210602116021260213602146021560216602176021860219602206022160222602236022460225602266022760228602296023060231602326023360234602356023660237602386023960240602416024260243602446024560246602476024860249602506025160252602536025460255602566025760258602596026060261602626026360264602656026660267602686026960270602716027260273602746027560276602776027860279602806028160282602836028460285602866028760288602896029060291602926029360294602956029660297602986029960300603016030260303603046030560306603076030860309603106031160312603136031460315603166031760318603196032060321603226032360324603256032660327603286032960330603316033260333603346033560336603376033860339603406034160342603436034460345603466034760348603496035060351603526035360354603556035660357603586035960360603616036260363603646036560366603676036860369603706037160372603736037460375603766037760378603796038060381603826038360384603856038660387603886038960390603916039260393603946039560396603976039860399604006040160402604036040460405604066040760408604096041060411604126041360414604156041660417604186041960420604216042260423604246042560426604276042860429604306043160432604336043460435604366043760438604396044060441604426044360444604456044660447604486044960450604516045260453604546045560456604576045860459604606046160462604636046460465604666046760468604696047060471604726047360474604756047660477604786047960480604816048260483604846048560486604876048860489604906049160492604936049460495604966049760498604996050060501605026050360504605056050660507605086050960510605116051260513605146051560516605176051860519605206052160522605236052460525605266052760528605296053060531605326053360534605356053660537605386053960540605416054260543605446054560546605476054860549605506055160552605536055460555605566055760558605596056060561605626056360564605656056660567605686056960570605716057260573605746057560576605776057860579605806058160582605836058460585605866058760588605896059060591605926059360594605956059660597605986059960600606016060260603606046060560606606076060860609606106061160612606136061460615606166061760618606196062060621606226062360624606256062660627606286062960630606316063260633606346063560636606376063860639606406064160642606436064460645606466064760648606496065060651606526065360654606556065660657606586065960660606616066260663606646066560666606676066860669606706067160672606736067460675606766067760678606796068060681606826068360684606856068660687606886068960690606916069260693606946069560696606976069860699607006070160702607036070460705607066070760708607096071060711607126071360714607156071660717607186071960720607216072260723607246072560726607276072860729607306073160732607336073460735607366073760738607396074060741607426074360744607456074660747607486074960750607516075260753607546075560756607576075860759607606076160762607636076460765607666076760768607696077060771607726077360774607756077660777607786077960780607816078260783607846078560786607876078860789607906079160792607936079460795607966079760798607996080060801608026080360804608056080660807608086080960810608116081260813608146081560816608176081860819608206082160822608236082460825608266082760828608296083060831608326083360834608356083660837608386083960840608416084260843608446084560846608476084860849608506085160852608536085460855608566085760858608596086060861608626086360864608656086660867608686086960870608716087260873608746087560876608776087860879608806088160882608836088460885608866088760888608896089060891608926089360894608956089660897608986089960900609016090260903609046090560906609076090860909609106091160912609136091460915609166091760918609196092060921609226092360924609256092660927609286092960930609316093260933609346093560936609376093860939609406094160942609436094460945609466094760948609496095060951609526095360954609556095660957609586095960960609616096260963609646096560966609676096860969609706097160972609736097460975609766097760978609796098060981609826098360984609856098660987609886098960990609916099260993609946099560996609976099860999610006100161002610036100461005610066100761008610096101061011610126101361014610156101661017610186101961020610216102261023610246102561026610276102861029610306103161032610336103461035610366103761038610396104061041610426104361044610456104661047610486104961050610516105261053610546105561056610576105861059610606106161062610636106461065610666106761068610696107061071610726107361074610756107661077610786107961080610816108261083610846108561086610876108861089610906109161092610936109461095610966109761098610996110061101611026110361104611056110661107611086110961110611116111261113611146111561116611176111861119611206112161122611236112461125611266112761128611296113061131611326113361134611356113661137611386113961140611416114261143611446114561146611476114861149611506115161152611536115461155611566115761158611596116061161611626116361164611656116661167611686116961170611716117261173611746117561176611776117861179611806118161182611836118461185611866118761188611896119061191611926119361194611956119661197611986119961200612016120261203612046120561206612076120861209612106121161212612136121461215612166121761218612196122061221612226122361224612256122661227612286122961230612316123261233612346123561236612376123861239612406124161242612436124461245612466124761248612496125061251612526125361254612556125661257612586125961260612616126261263612646126561266612676126861269612706127161272612736127461275612766127761278612796128061281612826128361284612856128661287612886128961290612916129261293612946129561296612976129861299613006130161302613036130461305613066130761308613096131061311613126131361314613156131661317613186131961320613216132261323613246132561326613276132861329613306133161332613336133461335613366133761338613396134061341613426134361344613456134661347613486134961350613516135261353613546135561356613576135861359613606136161362613636136461365613666136761368613696137061371613726137361374613756137661377613786137961380613816138261383613846138561386613876138861389613906139161392613936139461395613966139761398613996140061401614026140361404614056140661407614086140961410614116141261413614146141561416614176141861419614206142161422614236142461425614266142761428614296143061431614326143361434614356143661437614386143961440614416144261443614446144561446614476144861449614506145161452614536145461455614566145761458614596146061461614626146361464614656146661467614686146961470614716147261473614746147561476614776147861479614806148161482614836148461485614866148761488614896149061491614926149361494614956149661497614986149961500615016150261503615046150561506615076150861509615106151161512615136151461515615166151761518615196152061521615226152361524615256152661527615286152961530615316153261533615346153561536615376153861539615406154161542615436154461545615466154761548615496155061551615526155361554615556155661557615586155961560615616156261563615646156561566615676156861569615706157161572615736157461575615766157761578615796158061581615826158361584615856158661587615886158961590615916159261593615946159561596615976159861599616006160161602616036160461605616066160761608616096161061611616126161361614616156161661617616186161961620616216162261623616246162561626616276162861629616306163161632616336163461635616366163761638616396164061641616426164361644616456164661647616486164961650616516165261653616546165561656616576165861659616606166161662616636166461665616666166761668616696167061671616726167361674616756167661677616786167961680616816168261683616846168561686616876168861689616906169161692616936169461695616966169761698616996170061701617026170361704617056170661707617086170961710617116171261713617146171561716617176171861719617206172161722617236172461725617266172761728617296173061731617326173361734617356173661737617386173961740617416174261743617446174561746617476174861749617506175161752617536175461755617566175761758617596176061761617626176361764617656176661767617686176961770617716177261773617746177561776617776177861779617806178161782617836178461785617866178761788617896179061791617926179361794617956179661797617986179961800618016180261803618046180561806618076180861809618106181161812618136181461815618166181761818618196182061821618226182361824618256182661827618286182961830618316183261833618346183561836618376183861839618406184161842618436184461845618466184761848618496185061851618526185361854618556185661857618586185961860618616186261863618646186561866618676186861869618706187161872618736187461875618766187761878618796188061881618826188361884618856188661887618886188961890618916189261893618946189561896618976189861899619006190161902619036190461905619066190761908619096191061911619126191361914619156191661917619186191961920619216192261923619246192561926619276192861929619306193161932619336193461935619366193761938619396194061941619426194361944619456194661947619486194961950619516195261953619546195561956619576195861959619606196161962619636196461965619666196761968619696197061971619726197361974619756197661977619786197961980619816198261983619846198561986619876198861989619906199161992619936199461995619966199761998619996200062001620026200362004620056200662007620086200962010620116201262013620146201562016620176201862019620206202162022620236202462025620266202762028620296203062031620326203362034620356203662037620386203962040620416204262043620446204562046620476204862049620506205162052620536205462055620566205762058620596206062061620626206362064620656206662067620686206962070620716207262073620746207562076620776207862079620806208162082620836208462085620866208762088620896209062091620926209362094620956209662097620986209962100621016210262103621046210562106621076210862109621106211162112621136211462115621166211762118621196212062121621226212362124621256212662127621286212962130621316213262133621346213562136621376213862139621406214162142621436214462145621466214762148621496215062151621526215362154621556215662157621586215962160621616216262163621646216562166621676216862169621706217162172621736217462175621766217762178621796218062181621826218362184621856218662187621886218962190621916219262193621946219562196621976219862199622006220162202622036220462205622066220762208622096221062211622126221362214622156221662217622186221962220622216222262223622246222562226622276222862229622306223162232622336223462235622366223762238622396224062241622426224362244622456224662247622486224962250622516225262253622546225562256622576225862259622606226162262622636226462265622666226762268622696227062271622726227362274622756227662277622786227962280622816228262283622846228562286622876228862289622906229162292622936229462295622966229762298622996230062301623026230362304623056230662307623086230962310623116231262313623146231562316623176231862319623206232162322623236232462325623266232762328623296233062331623326233362334623356233662337623386233962340623416234262343623446234562346623476234862349623506235162352623536235462355623566235762358623596236062361623626236362364623656236662367623686236962370623716237262373623746237562376623776237862379623806238162382623836238462385623866238762388623896239062391623926239362394623956239662397623986239962400624016240262403624046240562406624076240862409624106241162412624136241462415624166241762418624196242062421624226242362424624256242662427624286242962430624316243262433624346243562436624376243862439624406244162442624436244462445624466244762448624496245062451624526245362454624556245662457624586245962460624616246262463624646246562466624676246862469624706247162472624736247462475624766247762478624796248062481624826248362484624856248662487624886248962490624916249262493624946249562496624976249862499625006250162502625036250462505625066250762508625096251062511625126251362514625156251662517625186251962520625216252262523625246252562526625276252862529625306253162532625336253462535625366253762538625396254062541625426254362544625456254662547625486254962550625516255262553625546255562556625576255862559625606256162562625636256462565625666256762568625696257062571625726257362574625756257662577625786257962580625816258262583625846258562586625876258862589625906259162592625936259462595625966259762598625996260062601626026260362604626056260662607626086260962610626116261262613626146261562616626176261862619626206262162622626236262462625626266262762628626296263062631626326263362634626356263662637626386263962640626416264262643626446264562646626476264862649626506265162652626536265462655626566265762658626596266062661626626266362664626656266662667626686266962670626716267262673626746267562676626776267862679626806268162682626836268462685626866268762688626896269062691626926269362694626956269662697626986269962700627016270262703627046270562706627076270862709627106271162712627136271462715627166271762718627196272062721627226272362724627256272662727627286272962730627316273262733627346273562736627376273862739627406274162742627436274462745627466274762748627496275062751627526275362754627556275662757627586275962760627616276262763627646276562766627676276862769627706277162772627736277462775627766277762778627796278062781627826278362784627856278662787627886278962790627916279262793627946279562796627976279862799628006280162802628036280462805628066280762808628096281062811628126281362814628156281662817628186281962820628216282262823628246282562826628276282862829628306283162832628336283462835628366283762838628396284062841628426284362844628456284662847628486284962850628516285262853628546285562856628576285862859628606286162862628636286462865628666286762868628696287062871628726287362874628756287662877628786287962880628816288262883628846288562886628876288862889628906289162892628936289462895628966289762898628996290062901629026290362904629056290662907629086290962910629116291262913629146291562916629176291862919629206292162922629236292462925629266292762928629296293062931629326293362934629356293662937629386293962940629416294262943629446294562946629476294862949629506295162952629536295462955629566295762958629596296062961629626296362964629656296662967629686296962970629716297262973629746297562976629776297862979629806298162982629836298462985629866298762988629896299062991629926299362994629956299662997629986299963000630016300263003630046300563006630076300863009630106301163012630136301463015630166301763018630196302063021630226302363024630256302663027630286302963030630316303263033630346303563036630376303863039630406304163042630436304463045630466304763048630496305063051630526305363054630556305663057630586305963060630616306263063630646306563066630676306863069630706307163072630736307463075630766307763078630796308063081630826308363084630856308663087630886308963090630916309263093630946309563096630976309863099631006310163102631036310463105631066310763108631096311063111631126311363114631156311663117631186311963120631216312263123631246312563126631276312863129631306313163132631336313463135631366313763138631396314063141631426314363144631456314663147631486314963150631516315263153631546315563156631576315863159631606316163162631636316463165631666316763168631696317063171631726317363174631756317663177631786317963180631816318263183631846318563186631876318863189631906319163192631936319463195631966319763198631996320063201632026320363204632056320663207632086320963210632116321263213632146321563216632176321863219632206322163222632236322463225632266322763228632296323063231632326323363234632356323663237632386323963240632416324263243632446324563246632476324863249632506325163252632536325463255632566325763258632596326063261632626326363264632656326663267632686326963270632716327263273632746327563276632776327863279632806328163282632836328463285632866328763288632896329063291632926329363294632956329663297632986329963300633016330263303633046330563306633076330863309633106331163312633136331463315633166331763318633196332063321633226332363324633256332663327633286332963330633316333263333633346333563336633376333863339633406334163342633436334463345633466334763348633496335063351633526335363354633556335663357633586335963360633616336263363633646336563366633676336863369633706337163372633736337463375633766337763378633796338063381633826338363384633856338663387633886338963390633916339263393633946339563396633976339863399634006340163402634036340463405634066340763408634096341063411634126341363414634156341663417634186341963420634216342263423634246342563426634276342863429634306343163432634336343463435634366343763438634396344063441634426344363444634456344663447634486344963450634516345263453634546345563456634576345863459634606346163462634636346463465634666346763468634696347063471634726347363474634756347663477634786347963480634816348263483634846348563486634876348863489634906349163492634936349463495634966349763498634996350063501635026350363504635056350663507635086350963510635116351263513635146351563516635176351863519635206352163522635236352463525635266352763528635296353063531635326353363534635356353663537635386353963540635416354263543635446354563546635476354863549635506355163552635536355463555635566355763558635596356063561635626356363564635656356663567635686356963570635716357263573635746357563576635776357863579635806358163582635836358463585635866358763588635896359063591635926359363594635956359663597635986359963600636016360263603636046360563606636076360863609636106361163612636136361463615636166361763618636196362063621636226362363624636256362663627636286362963630636316363263633636346363563636636376363863639636406364163642636436364463645636466364763648636496365063651636526365363654636556365663657636586365963660636616366263663636646366563666636676366863669636706367163672636736367463675636766367763678636796368063681636826368363684636856368663687636886368963690636916369263693636946369563696636976369863699637006370163702637036370463705637066370763708637096371063711637126371363714637156371663717637186371963720637216372263723637246372563726637276372863729637306373163732637336373463735637366373763738637396374063741637426374363744637456374663747637486374963750637516375263753637546375563756637576375863759637606376163762637636376463765637666376763768637696377063771637726377363774637756377663777637786377963780637816378263783637846378563786637876378863789637906379163792637936379463795637966379763798637996380063801638026380363804638056380663807638086380963810638116381263813638146381563816638176381863819638206382163822638236382463825638266382763828638296383063831638326383363834638356383663837638386383963840638416384263843638446384563846638476384863849638506385163852638536385463855638566385763858638596386063861638626386363864638656386663867638686386963870638716387263873638746387563876638776387863879638806388163882638836388463885638866388763888638896389063891638926389363894638956389663897638986389963900639016390263903639046390563906639076390863909639106391163912639136391463915639166391763918639196392063921639226392363924639256392663927639286392963930639316393263933639346393563936639376393863939639406394163942639436394463945639466394763948639496395063951639526395363954639556395663957639586395963960639616396263963639646396563966639676396863969639706397163972639736397463975639766397763978639796398063981639826398363984639856398663987639886398963990639916399263993639946399563996639976399863999640006400164002640036400464005640066400764008640096401064011640126401364014640156401664017640186401964020640216402264023640246402564026640276402864029640306403164032640336403464035640366403764038640396404064041640426404364044640456404664047640486404964050640516405264053640546405564056640576405864059640606406164062640636406464065640666406764068640696407064071640726407364074640756407664077640786407964080640816408264083640846408564086640876408864089640906409164092640936409464095640966409764098640996410064101641026410364104641056410664107641086410964110641116411264113641146411564116641176411864119641206412164122641236412464125641266412764128641296413064131641326413364134641356413664137641386413964140641416414264143641446414564146641476414864149641506415164152641536415464155641566415764158641596416064161641626416364164641656416664167641686416964170641716417264173641746417564176641776417864179641806418164182641836418464185641866418764188641896419064191641926419364194641956419664197641986419964200642016420264203642046420564206642076420864209642106421164212642136421464215642166421764218642196422064221642226422364224642256422664227642286422964230642316423264233642346423564236642376423864239642406424164242642436424464245642466424764248642496425064251642526425364254642556425664257642586425964260642616426264263642646426564266642676426864269642706427164272642736427464275642766427764278642796428064281642826428364284642856428664287642886428964290642916429264293642946429564296642976429864299643006430164302643036430464305643066430764308643096431064311643126431364314643156431664317643186431964320643216432264323643246432564326643276432864329643306433164332643336433464335643366433764338643396434064341643426434364344643456434664347643486434964350643516435264353643546435564356643576435864359643606436164362643636436464365643666436764368643696437064371643726437364374643756437664377643786437964380643816438264383643846438564386643876438864389643906439164392643936439464395643966439764398643996440064401644026440364404644056440664407644086440964410644116441264413644146441564416644176441864419644206442164422644236442464425644266442764428644296443064431644326443364434644356443664437644386443964440644416444264443644446444564446644476444864449644506445164452644536445464455644566445764458644596446064461644626446364464644656446664467644686446964470644716447264473644746447564476644776447864479644806448164482644836448464485644866448764488644896449064491644926449364494644956449664497644986449964500645016450264503645046450564506645076450864509645106451164512645136451464515645166451764518645196452064521645226452364524645256452664527645286452964530645316453264533645346453564536645376453864539645406454164542645436454464545645466454764548645496455064551645526455364554645556455664557645586455964560645616456264563645646456564566645676456864569645706457164572645736457464575645766457764578645796458064581645826458364584645856458664587645886458964590645916459264593645946459564596645976459864599646006460164602646036460464605646066460764608646096461064611646126461364614646156461664617646186461964620646216462264623646246462564626646276462864629646306463164632646336463464635646366463764638646396464064641646426464364644646456464664647646486464964650646516465264653646546465564656646576465864659646606466164662646636466464665646666466764668646696467064671646726467364674646756467664677646786467964680646816468264683646846468564686646876468864689646906469164692646936469464695646966469764698646996470064701647026470364704647056470664707647086470964710647116471264713647146471564716647176471864719647206472164722647236472464725647266472764728647296473064731647326473364734647356473664737647386473964740647416474264743647446474564746647476474864749647506475164752647536475464755647566475764758647596476064761647626476364764647656476664767647686476964770647716477264773647746477564776647776477864779647806478164782647836478464785647866478764788647896479064791647926479364794647956479664797647986479964800648016480264803648046480564806648076480864809648106481164812648136481464815648166481764818648196482064821648226482364824648256482664827648286482964830648316483264833648346483564836648376483864839648406484164842648436484464845648466484764848648496485064851648526485364854648556485664857648586485964860648616486264863648646486564866648676486864869648706487164872648736487464875648766487764878648796488064881648826488364884648856488664887648886488964890648916489264893648946489564896648976489864899649006490164902649036490464905649066490764908649096491064911649126491364914649156491664917649186491964920649216492264923649246492564926649276492864929649306493164932649336493464935649366493764938649396494064941649426494364944649456494664947649486494964950649516495264953649546495564956649576495864959649606496164962649636496464965649666496764968649696497064971649726497364974649756497664977649786497964980649816498264983649846498564986649876498864989649906499164992649936499464995649966499764998649996500065001650026500365004650056500665007650086500965010650116501265013650146501565016650176501865019650206502165022650236502465025650266502765028650296503065031650326503365034650356503665037650386503965040650416504265043650446504565046650476504865049650506505165052650536505465055650566505765058650596506065061650626506365064650656506665067650686506965070650716507265073650746507565076650776507865079650806508165082650836508465085650866508765088650896509065091650926509365094650956509665097650986509965100651016510265103651046510565106651076510865109651106511165112651136511465115651166511765118651196512065121651226512365124651256512665127651286512965130651316513265133651346513565136651376513865139651406514165142651436514465145651466514765148651496515065151651526515365154651556515665157651586515965160651616516265163651646516565166651676516865169651706517165172651736517465175651766517765178651796518065181651826518365184651856518665187651886518965190651916519265193651946519565196651976519865199652006520165202652036520465205652066520765208652096521065211652126521365214652156521665217652186521965220652216522265223652246522565226652276522865229652306523165232652336523465235652366523765238652396524065241652426524365244652456524665247652486524965250652516525265253652546525565256652576525865259652606526165262652636526465265652666526765268652696527065271652726527365274652756527665277652786527965280652816528265283652846528565286652876528865289652906529165292652936529465295652966529765298652996530065301653026530365304653056530665307653086530965310653116531265313653146531565316653176531865319653206532165322653236532465325653266532765328653296533065331653326533365334653356533665337653386533965340653416534265343653446534565346653476534865349653506535165352653536535465355653566535765358653596536065361653626536365364653656536665367653686536965370653716537265373653746537565376653776537865379653806538165382653836538465385653866538765388653896539065391653926539365394653956539665397653986539965400654016540265403654046540565406654076540865409654106541165412654136541465415654166541765418654196542065421654226542365424654256542665427654286542965430654316543265433654346543565436654376543865439654406544165442654436544465445654466544765448654496545065451654526545365454654556545665457654586545965460654616546265463654646546565466654676546865469654706547165472654736547465475654766547765478654796548065481654826548365484654856548665487654886548965490654916549265493654946549565496654976549865499655006550165502655036550465505655066550765508655096551065511655126551365514655156551665517655186551965520655216552265523655246552565526655276552865529655306553165532655336553465535655366553765538655396554065541655426554365544655456554665547655486554965550655516555265553655546555565556655576555865559655606556165562655636556465565655666556765568655696557065571655726557365574655756557665577655786557965580655816558265583655846558565586655876558865589655906559165592655936559465595655966559765598655996560065601656026560365604656056560665607656086560965610656116561265613656146561565616656176561865619656206562165622656236562465625656266562765628656296563065631656326563365634656356563665637656386563965640656416564265643656446564565646656476564865649656506565165652656536565465655656566565765658656596566065661656626566365664656656566665667656686566965670656716567265673656746567565676656776567865679656806568165682656836568465685656866568765688656896569065691656926569365694656956569665697656986569965700657016570265703657046570565706657076570865709657106571165712657136571465715657166571765718657196572065721657226572365724657256572665727657286572965730657316573265733657346573565736657376573865739657406574165742657436574465745657466574765748657496575065751657526575365754657556575665757657586575965760657616576265763657646576565766657676576865769657706577165772657736577465775657766577765778657796578065781657826578365784657856578665787657886578965790657916579265793657946579565796657976579865799658006580165802658036580465805658066580765808658096581065811658126581365814658156581665817658186581965820658216582265823658246582565826658276582865829658306583165832658336583465835658366583765838658396584065841658426584365844658456584665847658486584965850658516585265853658546585565856658576585865859658606586165862658636586465865658666586765868658696587065871658726587365874658756587665877658786587965880658816588265883658846588565886658876588865889658906589165892658936589465895658966589765898658996590065901659026590365904659056590665907659086590965910659116591265913659146591565916659176591865919659206592165922659236592465925659266592765928659296593065931659326593365934659356593665937659386593965940659416594265943659446594565946659476594865949659506595165952659536595465955659566595765958659596596065961659626596365964659656596665967659686596965970659716597265973659746597565976659776597865979659806598165982659836598465985659866598765988659896599065991659926599365994659956599665997659986599966000660016600266003660046600566006660076600866009660106601166012660136601466015660166601766018660196602066021660226602366024660256602666027660286602966030660316603266033660346603566036660376603866039660406604166042660436604466045660466604766048660496605066051660526605366054660556605666057660586605966060660616606266063660646606566066660676606866069660706607166072660736607466075660766607766078660796608066081660826608366084660856608666087660886608966090660916609266093660946609566096660976609866099661006610166102661036610466105661066610766108661096611066111661126611366114661156611666117661186611966120661216612266123661246612566126661276612866129661306613166132661336613466135661366613766138661396614066141661426614366144661456614666147661486614966150661516615266153661546615566156661576615866159661606616166162661636616466165661666616766168661696617066171661726617366174661756617666177661786617966180661816618266183661846618566186661876618866189661906619166192661936619466195661966619766198661996620066201662026620366204662056620666207662086620966210662116621266213662146621566216662176621866219662206622166222662236622466225662266622766228662296623066231662326623366234662356623666237662386623966240662416624266243662446624566246662476624866249662506625166252662536625466255662566625766258662596626066261662626626366264662656626666267662686626966270662716627266273662746627566276662776627866279662806628166282662836628466285662866628766288662896629066291662926629366294662956629666297662986629966300663016630266303663046630566306663076630866309663106631166312663136631466315663166631766318663196632066321663226632366324663256632666327663286632966330663316633266333663346633566336663376633866339663406634166342663436634466345663466634766348663496635066351663526635366354663556635666357663586635966360663616636266363663646636566366663676636866369663706637166372663736637466375663766637766378663796638066381663826638366384663856638666387663886638966390663916639266393663946639566396663976639866399664006640166402664036640466405664066640766408664096641066411664126641366414664156641666417664186641966420664216642266423664246642566426664276642866429664306643166432664336643466435664366643766438664396644066441664426644366444664456644666447664486644966450664516645266453664546645566456664576645866459664606646166462664636646466465664666646766468664696647066471664726647366474664756647666477664786647966480664816648266483664846648566486664876648866489664906649166492664936649466495664966649766498664996650066501665026650366504665056650666507665086650966510665116651266513665146651566516665176651866519665206652166522665236652466525665266652766528665296653066531665326653366534665356653666537665386653966540665416654266543665446654566546665476654866549665506655166552665536655466555665566655766558665596656066561665626656366564665656656666567665686656966570665716657266573665746657566576665776657866579665806658166582665836658466585665866658766588665896659066591665926659366594665956659666597665986659966600666016660266603666046660566606666076660866609666106661166612666136661466615666166661766618666196662066621666226662366624666256662666627666286662966630666316663266633666346663566636666376663866639666406664166642666436664466645666466664766648666496665066651666526665366654666556665666657666586665966660666616666266663666646666566666666676666866669666706667166672666736667466675666766667766678666796668066681666826668366684666856668666687666886668966690666916669266693666946669566696666976669866699667006670166702667036670466705667066670766708667096671066711667126671366714667156671666717667186671966720667216672266723667246672566726667276672866729667306673166732667336673466735667366673766738667396674066741667426674366744667456674666747667486674966750667516675266753667546675566756667576675866759667606676166762667636676466765667666676766768667696677066771667726677366774667756677666777667786677966780667816678266783667846678566786667876678866789667906679166792667936679466795667966679766798667996680066801668026680366804668056680666807668086680966810668116681266813668146681566816668176681866819668206682166822668236682466825668266682766828668296683066831668326683366834668356683666837668386683966840668416684266843668446684566846668476684866849668506685166852668536685466855668566685766858668596686066861668626686366864668656686666867668686686966870668716687266873668746687566876668776687866879668806688166882668836688466885668866688766888668896689066891668926689366894668956689666897668986689966900669016690266903669046690566906669076690866909669106691166912669136691466915669166691766918669196692066921669226692366924669256692666927669286692966930669316693266933669346693566936669376693866939669406694166942669436694466945669466694766948669496695066951669526695366954669556695666957669586695966960669616696266963669646696566966669676696866969669706697166972669736697466975669766697766978669796698066981669826698366984669856698666987669886698966990669916699266993669946699566996669976699866999670006700167002670036700467005670066700767008670096701067011670126701367014670156701667017670186701967020670216702267023670246702567026670276702867029670306703167032670336703467035670366703767038670396704067041670426704367044670456704667047670486704967050670516705267053670546705567056670576705867059670606706167062670636706467065670666706767068670696707067071670726707367074670756707667077670786707967080670816708267083670846708567086670876708867089670906709167092670936709467095670966709767098670996710067101671026710367104671056710667107671086710967110671116711267113671146711567116671176711867119671206712167122671236712467125671266712767128671296713067131671326713367134671356713667137671386713967140671416714267143671446714567146671476714867149671506715167152671536715467155671566715767158671596716067161671626716367164671656716667167671686716967170671716717267173671746717567176671776717867179671806718167182671836718467185671866718767188671896719067191671926719367194671956719667197671986719967200672016720267203672046720567206672076720867209672106721167212672136721467215672166721767218672196722067221672226722367224672256722667227672286722967230672316723267233672346723567236672376723867239672406724167242672436724467245672466724767248672496725067251672526725367254672556725667257672586725967260672616726267263672646726567266672676726867269672706727167272672736727467275672766727767278672796728067281672826728367284672856728667287672886728967290672916729267293672946729567296672976729867299673006730167302673036730467305673066730767308673096731067311673126731367314673156731667317673186731967320673216732267323673246732567326673276732867329673306733167332673336733467335673366733767338673396734067341673426734367344673456734667347673486734967350673516735267353673546735567356673576735867359673606736167362673636736467365673666736767368673696737067371673726737367374673756737667377673786737967380673816738267383673846738567386673876738867389673906739167392673936739467395673966739767398673996740067401674026740367404674056740667407674086740967410674116741267413674146741567416674176741867419674206742167422674236742467425674266742767428674296743067431674326743367434674356743667437674386743967440674416744267443674446744567446674476744867449674506745167452674536745467455674566745767458674596746067461674626746367464674656746667467674686746967470674716747267473674746747567476674776747867479674806748167482674836748467485674866748767488674896749067491674926749367494674956749667497674986749967500675016750267503675046750567506675076750867509675106751167512675136751467515675166751767518675196752067521675226752367524675256752667527675286752967530675316753267533675346753567536675376753867539675406754167542675436754467545675466754767548675496755067551675526755367554675556755667557675586755967560675616756267563675646756567566675676756867569675706757167572675736757467575675766757767578675796758067581675826758367584675856758667587675886758967590675916759267593675946759567596675976759867599676006760167602676036760467605676066760767608676096761067611676126761367614676156761667617676186761967620676216762267623676246762567626676276762867629676306763167632676336763467635676366763767638676396764067641676426764367644676456764667647676486764967650676516765267653676546765567656676576765867659676606766167662676636766467665676666766767668676696767067671676726767367674676756767667677676786767967680676816768267683676846768567686676876768867689676906769167692676936769467695676966769767698676996770067701677026770367704677056770667707677086770967710677116771267713677146771567716677176771867719677206772167722677236772467725677266772767728677296773067731677326773367734677356773667737677386773967740677416774267743677446774567746677476774867749677506775167752677536775467755677566775767758677596776067761677626776367764677656776667767677686776967770677716777267773677746777567776677776777867779677806778167782677836778467785677866778767788677896779067791677926779367794677956779667797677986779967800678016780267803678046780567806678076780867809678106781167812678136781467815678166781767818678196782067821678226782367824678256782667827678286782967830678316783267833678346783567836678376783867839678406784167842678436784467845678466784767848678496785067851678526785367854678556785667857678586785967860678616786267863678646786567866678676786867869678706787167872678736787467875678766787767878678796788067881678826788367884678856788667887678886788967890678916789267893678946789567896678976789867899679006790167902679036790467905679066790767908679096791067911679126791367914679156791667917679186791967920679216792267923679246792567926679276792867929679306793167932679336793467935679366793767938679396794067941679426794367944679456794667947679486794967950679516795267953679546795567956679576795867959679606796167962679636796467965679666796767968679696797067971679726797367974679756797667977679786797967980679816798267983679846798567986679876798867989679906799167992679936799467995679966799767998679996800068001680026800368004680056800668007680086800968010680116801268013680146801568016680176801868019680206802168022680236802468025680266802768028680296803068031680326803368034680356803668037680386803968040680416804268043680446804568046680476804868049680506805168052680536805468055680566805768058680596806068061680626806368064680656806668067680686806968070680716807268073680746807568076680776807868079680806808168082680836808468085680866808768088680896809068091680926809368094680956809668097680986809968100681016810268103681046810568106681076810868109681106811168112681136811468115681166811768118681196812068121681226812368124681256812668127681286812968130681316813268133681346813568136681376813868139681406814168142681436814468145681466814768148681496815068151681526815368154681556815668157681586815968160681616816268163681646816568166681676816868169681706817168172681736817468175681766817768178681796818068181681826818368184681856818668187681886818968190681916819268193681946819568196681976819868199682006820168202682036820468205682066820768208682096821068211682126821368214682156821668217682186821968220682216822268223682246822568226682276822868229682306823168232682336823468235682366823768238682396824068241682426824368244682456824668247682486824968250682516825268253682546825568256682576825868259682606826168262682636826468265682666826768268682696827068271682726827368274682756827668277682786827968280682816828268283682846828568286682876828868289682906829168292682936829468295682966829768298682996830068301683026830368304683056830668307683086830968310683116831268313683146831568316683176831868319683206832168322683236832468325683266832768328683296833068331683326833368334683356833668337683386833968340683416834268343683446834568346683476834868349683506835168352683536835468355683566835768358683596836068361683626836368364683656836668367683686836968370683716837268373683746837568376683776837868379683806838168382683836838468385683866838768388683896839068391683926839368394683956839668397683986839968400684016840268403684046840568406684076840868409684106841168412684136841468415684166841768418684196842068421684226842368424684256842668427684286842968430684316843268433684346843568436684376843868439684406844168442684436844468445684466844768448684496845068451684526845368454684556845668457684586845968460684616846268463684646846568466684676846868469684706847168472684736847468475684766847768478684796848068481684826848368484684856848668487684886848968490684916849268493684946849568496684976849868499685006850168502685036850468505685066850768508685096851068511685126851368514685156851668517685186851968520685216852268523685246852568526685276852868529685306853168532685336853468535685366853768538685396854068541685426854368544685456854668547685486854968550685516855268553685546855568556685576855868559685606856168562685636856468565685666856768568685696857068571685726857368574685756857668577685786857968580685816858268583685846858568586685876858868589685906859168592685936859468595685966859768598685996860068601686026860368604686056860668607686086860968610686116861268613686146861568616686176861868619686206862168622686236862468625686266862768628686296863068631686326863368634686356863668637686386863968640686416864268643686446864568646686476864868649686506865168652686536865468655686566865768658686596866068661686626866368664686656866668667686686866968670686716867268673686746867568676686776867868679686806868168682686836868468685686866868768688686896869068691686926869368694686956869668697686986869968700687016870268703687046870568706687076870868709687106871168712687136871468715687166871768718687196872068721687226872368724687256872668727687286872968730687316873268733687346873568736687376873868739687406874168742687436874468745687466874768748687496875068751687526875368754687556875668757687586875968760687616876268763687646876568766687676876868769687706877168772687736877468775687766877768778687796878068781687826878368784687856878668787687886878968790687916879268793687946879568796687976879868799688006880168802688036880468805688066880768808688096881068811688126881368814688156881668817688186881968820688216882268823688246882568826688276882868829688306883168832688336883468835688366883768838688396884068841688426884368844688456884668847688486884968850688516885268853688546885568856688576885868859688606886168862688636886468865688666886768868688696887068871688726887368874688756887668877688786887968880688816888268883688846888568886688876888868889688906889168892688936889468895688966889768898688996890068901689026890368904689056890668907689086890968910689116891268913689146891568916689176891868919689206892168922689236892468925689266892768928689296893068931689326893368934689356893668937689386893968940689416894268943689446894568946689476894868949689506895168952689536895468955689566895768958689596896068961689626896368964689656896668967689686896968970689716897268973689746897568976689776897868979689806898168982689836898468985689866898768988689896899068991689926899368994689956899668997689986899969000690016900269003690046900569006690076900869009690106901169012690136901469015690166901769018690196902069021690226902369024690256902669027690286902969030690316903269033690346903569036690376903869039690406904169042690436904469045690466904769048690496905069051690526905369054690556905669057690586905969060690616906269063690646906569066690676906869069690706907169072690736907469075690766907769078690796908069081690826908369084690856908669087690886908969090690916909269093690946909569096690976909869099691006910169102691036910469105691066910769108691096911069111691126911369114691156911669117691186911969120691216912269123691246912569126691276912869129691306913169132691336913469135691366913769138691396914069141691426914369144691456914669147691486914969150691516915269153691546915569156691576915869159691606916169162691636916469165691666916769168691696917069171691726917369174691756917669177691786917969180691816918269183691846918569186691876918869189691906919169192691936919469195691966919769198691996920069201692026920369204692056920669207692086920969210692116921269213692146921569216692176921869219692206922169222692236922469225692266922769228692296923069231692326923369234692356923669237692386923969240692416924269243692446924569246692476924869249692506925169252692536925469255692566925769258692596926069261692626926369264692656926669267692686926969270692716927269273692746927569276692776927869279692806928169282692836928469285692866928769288692896929069291692926929369294692956929669297692986929969300693016930269303693046930569306693076930869309693106931169312693136931469315693166931769318693196932069321693226932369324693256932669327693286932969330693316933269333693346933569336693376933869339693406934169342693436934469345693466934769348693496935069351693526935369354693556935669357693586935969360693616936269363693646936569366693676936869369693706937169372693736937469375693766937769378693796938069381693826938369384693856938669387693886938969390693916939269393693946939569396693976939869399694006940169402694036940469405694066940769408694096941069411694126941369414694156941669417694186941969420694216942269423694246942569426694276942869429694306943169432694336943469435694366943769438694396944069441694426944369444694456944669447694486944969450694516945269453694546945569456694576945869459694606946169462694636946469465694666946769468694696947069471694726947369474694756947669477694786947969480694816948269483694846948569486694876948869489694906949169492694936949469495694966949769498694996950069501695026950369504695056950669507695086950969510695116951269513695146951569516695176951869519695206952169522695236952469525695266952769528695296953069531695326953369534695356953669537695386953969540695416954269543695446954569546695476954869549695506955169552695536955469555695566955769558695596956069561695626956369564695656956669567695686956969570695716957269573695746957569576695776957869579695806958169582695836958469585695866958769588695896959069591695926959369594695956959669597695986959969600696016960269603696046960569606696076960869609696106961169612696136961469615696166961769618696196962069621696226962369624696256962669627696286962969630696316963269633696346963569636696376963869639696406964169642696436964469645696466964769648696496965069651696526965369654696556965669657696586965969660696616966269663696646966569666696676966869669696706967169672696736967469675696766967769678696796968069681696826968369684696856968669687696886968969690696916969269693696946969569696696976969869699697006970169702697036970469705697066970769708697096971069711697126971369714697156971669717697186971969720697216972269723697246972569726697276972869729697306973169732697336973469735697366973769738697396974069741697426974369744697456974669747697486974969750697516975269753697546975569756697576975869759697606976169762697636976469765697666976769768697696977069771697726977369774697756977669777697786977969780697816978269783697846978569786697876978869789697906979169792697936979469795697966979769798697996980069801698026980369804698056980669807698086980969810698116981269813698146981569816698176981869819698206982169822698236982469825698266982769828698296983069831698326983369834698356983669837698386983969840698416984269843698446984569846698476984869849698506985169852698536985469855698566985769858698596986069861698626986369864698656986669867698686986969870698716987269873698746987569876698776987869879698806988169882698836988469885698866988769888698896989069891698926989369894698956989669897698986989969900699016990269903699046990569906699076990869909699106991169912699136991469915699166991769918699196992069921699226992369924699256992669927699286992969930699316993269933699346993569936699376993869939699406994169942699436994469945699466994769948699496995069951699526995369954699556995669957699586995969960699616996269963699646996569966699676996869969699706997169972699736997469975699766997769978699796998069981699826998369984699856998669987699886998969990699916999269993699946999569996699976999869999700007000170002700037000470005700067000770008700097001070011700127001370014700157001670017700187001970020700217002270023700247002570026700277002870029700307003170032700337003470035700367003770038700397004070041700427004370044700457004670047700487004970050700517005270053700547005570056700577005870059700607006170062700637006470065700667006770068700697007070071700727007370074700757007670077700787007970080700817008270083700847008570086700877008870089700907009170092700937009470095700967009770098700997010070101701027010370104701057010670107701087010970110701117011270113701147011570116701177011870119701207012170122701237012470125701267012770128701297013070131701327013370134701357013670137701387013970140701417014270143701447014570146701477014870149701507015170152701537015470155701567015770158701597016070161701627016370164701657016670167701687016970170701717017270173701747017570176701777017870179701807018170182701837018470185701867018770188701897019070191701927019370194701957019670197701987019970200702017020270203702047020570206702077020870209702107021170212702137021470215702167021770218702197022070221702227022370224702257022670227702287022970230702317023270233702347023570236702377023870239702407024170242702437024470245702467024770248702497025070251702527025370254702557025670257702587025970260702617026270263702647026570266702677026870269702707027170272702737027470275702767027770278702797028070281702827028370284702857028670287702887028970290702917029270293702947029570296702977029870299703007030170302703037030470305703067030770308703097031070311703127031370314703157031670317703187031970320703217032270323703247032570326703277032870329703307033170332703337033470335703367033770338703397034070341703427034370344703457034670347703487034970350703517035270353703547035570356703577035870359703607036170362703637036470365703667036770368703697037070371703727037370374703757037670377703787037970380703817038270383703847038570386703877038870389703907039170392703937039470395703967039770398703997040070401704027040370404704057040670407704087040970410704117041270413704147041570416704177041870419704207042170422704237042470425704267042770428704297043070431704327043370434704357043670437704387043970440704417044270443704447044570446704477044870449704507045170452704537045470455704567045770458704597046070461704627046370464704657046670467704687046970470704717047270473704747047570476704777047870479704807048170482704837048470485704867048770488704897049070491704927049370494704957049670497704987049970500705017050270503705047050570506705077050870509705107051170512705137051470515705167051770518705197052070521705227052370524705257052670527705287052970530705317053270533705347053570536705377053870539705407054170542705437054470545705467054770548705497055070551705527055370554705557055670557705587055970560705617056270563705647056570566705677056870569705707057170572705737057470575705767057770578705797058070581705827058370584705857058670587705887058970590705917059270593705947059570596705977059870599706007060170602706037060470605706067060770608706097061070611706127061370614706157061670617706187061970620706217062270623706247062570626706277062870629706307063170632706337063470635706367063770638706397064070641706427064370644706457064670647706487064970650706517065270653706547065570656706577065870659706607066170662706637066470665706667066770668706697067070671706727067370674706757067670677706787067970680706817068270683706847068570686706877068870689706907069170692706937069470695706967069770698706997070070701707027070370704707057070670707707087070970710707117071270713707147071570716707177071870719707207072170722707237072470725707267072770728707297073070731707327073370734707357073670737707387073970740707417074270743707447074570746707477074870749707507075170752707537075470755707567075770758707597076070761707627076370764707657076670767707687076970770707717077270773707747077570776707777077870779707807078170782707837078470785707867078770788707897079070791707927079370794707957079670797707987079970800708017080270803708047080570806708077080870809708107081170812708137081470815708167081770818708197082070821708227082370824708257082670827708287082970830708317083270833708347083570836708377083870839708407084170842708437084470845708467084770848708497085070851708527085370854708557085670857708587085970860708617086270863708647086570866708677086870869708707087170872708737087470875708767087770878708797088070881708827088370884708857088670887708887088970890708917089270893708947089570896708977089870899709007090170902709037090470905709067090770908709097091070911709127091370914709157091670917709187091970920709217092270923709247092570926709277092870929709307093170932709337093470935709367093770938709397094070941709427094370944709457094670947709487094970950709517095270953709547095570956709577095870959709607096170962709637096470965709667096770968709697097070971709727097370974709757097670977709787097970980709817098270983709847098570986709877098870989709907099170992709937099470995709967099770998709997100071001710027100371004710057100671007710087100971010710117101271013710147101571016710177101871019710207102171022710237102471025710267102771028710297103071031710327103371034710357103671037710387103971040710417104271043710447104571046710477104871049710507105171052710537105471055710567105771058710597106071061710627106371064710657106671067710687106971070710717107271073710747107571076710777107871079710807108171082710837108471085710867108771088710897109071091710927109371094710957109671097710987109971100711017110271103711047110571106711077110871109711107111171112711137111471115711167111771118711197112071121711227112371124711257112671127711287112971130711317113271133711347113571136711377113871139711407114171142711437114471145711467114771148711497115071151711527115371154711557115671157711587115971160711617116271163711647116571166711677116871169711707117171172711737117471175711767117771178711797118071181711827118371184711857118671187711887118971190711917119271193711947119571196711977119871199712007120171202712037120471205712067120771208712097121071211712127121371214712157121671217712187121971220712217122271223712247122571226712277122871229712307123171232712337123471235712367123771238712397124071241712427124371244712457124671247712487124971250712517125271253712547125571256712577125871259712607126171262712637126471265712667126771268712697127071271712727127371274712757127671277712787127971280712817128271283712847128571286712877128871289712907129171292712937129471295712967129771298712997130071301713027130371304713057130671307713087130971310713117131271313713147131571316713177131871319713207132171322713237132471325713267132771328713297133071331713327133371334713357133671337713387133971340713417134271343713447134571346713477134871349713507135171352713537135471355713567135771358713597136071361713627136371364713657136671367713687136971370713717137271373713747137571376713777137871379713807138171382713837138471385713867138771388713897139071391713927139371394713957139671397713987139971400714017140271403714047140571406714077140871409714107141171412714137141471415714167141771418714197142071421714227142371424714257142671427714287142971430714317143271433714347143571436714377143871439714407144171442714437144471445714467144771448714497145071451714527145371454714557145671457714587145971460714617146271463714647146571466714677146871469714707147171472714737147471475714767147771478714797148071481714827148371484714857148671487714887148971490714917149271493714947149571496714977149871499715007150171502715037150471505715067150771508715097151071511715127151371514715157151671517715187151971520715217152271523715247152571526715277152871529715307153171532715337153471535715367153771538715397154071541715427154371544715457154671547715487154971550715517155271553715547155571556715577155871559715607156171562715637156471565715667156771568715697157071571715727157371574715757157671577715787157971580715817158271583715847158571586715877158871589715907159171592715937159471595715967159771598715997160071601716027160371604716057160671607716087160971610716117161271613716147161571616716177161871619716207162171622716237162471625716267162771628716297163071631716327163371634716357163671637716387163971640716417164271643716447164571646716477164871649716507165171652716537165471655716567165771658716597166071661716627166371664716657166671667716687166971670716717167271673716747167571676716777167871679716807168171682716837168471685716867168771688716897169071691716927169371694716957169671697716987169971700717017170271703717047170571706717077170871709717107171171712717137171471715717167171771718717197172071721717227172371724717257172671727717287172971730717317173271733717347173571736717377173871739717407174171742717437174471745717467174771748717497175071751717527175371754717557175671757717587175971760717617176271763717647176571766717677176871769717707177171772717737177471775717767177771778717797178071781717827178371784717857178671787717887178971790717917179271793717947179571796717977179871799718007180171802718037180471805718067180771808718097181071811718127181371814718157181671817718187181971820718217182271823718247182571826718277182871829718307183171832718337183471835718367183771838718397184071841718427184371844718457184671847718487184971850718517185271853718547185571856718577185871859718607186171862718637186471865718667186771868718697187071871718727187371874718757187671877718787187971880718817188271883718847188571886718877188871889718907189171892718937189471895718967189771898718997190071901719027190371904719057190671907719087190971910719117191271913719147191571916719177191871919719207192171922719237192471925719267192771928719297193071931719327193371934719357193671937719387193971940719417194271943719447194571946719477194871949719507195171952719537195471955719567195771958719597196071961719627196371964719657196671967719687196971970719717197271973719747197571976719777197871979719807198171982719837198471985719867198771988719897199071991719927199371994719957199671997719987199972000720017200272003720047200572006720077200872009720107201172012720137201472015720167201772018720197202072021720227202372024720257202672027720287202972030720317203272033720347203572036720377203872039720407204172042720437204472045720467204772048720497205072051720527205372054720557205672057720587205972060720617206272063720647206572066720677206872069720707207172072720737207472075720767207772078720797208072081720827208372084720857208672087720887208972090720917209272093720947209572096720977209872099721007210172102721037210472105721067210772108721097211072111721127211372114721157211672117721187211972120721217212272123721247212572126721277212872129721307213172132721337213472135721367213772138721397214072141721427214372144721457214672147721487214972150721517215272153721547215572156721577215872159721607216172162721637216472165721667216772168721697217072171721727217372174721757217672177721787217972180721817218272183721847218572186721877218872189721907219172192721937219472195721967219772198721997220072201722027220372204722057220672207722087220972210722117221272213722147221572216722177221872219722207222172222722237222472225722267222772228722297223072231722327223372234722357223672237722387223972240722417224272243722447224572246722477224872249722507225172252722537225472255722567225772258722597226072261722627226372264722657226672267722687226972270722717227272273722747227572276722777227872279722807228172282722837228472285722867228772288722897229072291722927229372294722957229672297722987229972300723017230272303723047230572306723077230872309723107231172312723137231472315723167231772318723197232072321723227232372324723257232672327723287232972330723317233272333723347233572336723377233872339723407234172342723437234472345723467234772348723497235072351723527235372354723557235672357723587235972360723617236272363723647236572366723677236872369723707237172372723737237472375723767237772378723797238072381723827238372384723857238672387723887238972390723917239272393723947239572396723977239872399724007240172402724037240472405724067240772408724097241072411724127241372414724157241672417724187241972420724217242272423724247242572426724277242872429724307243172432724337243472435724367243772438724397244072441724427244372444724457244672447724487244972450724517245272453724547245572456724577245872459724607246172462724637246472465724667246772468724697247072471724727247372474724757247672477724787247972480724817248272483724847248572486724877248872489724907249172492724937249472495724967249772498724997250072501725027250372504725057250672507725087250972510725117251272513725147251572516725177251872519725207252172522725237252472525725267252772528725297253072531725327253372534725357253672537725387253972540725417254272543725447254572546725477254872549725507255172552725537255472555725567255772558725597256072561725627256372564725657256672567725687256972570725717257272573725747257572576725777257872579725807258172582725837258472585725867258772588725897259072591725927259372594725957259672597725987259972600726017260272603726047260572606726077260872609726107261172612726137261472615726167261772618726197262072621726227262372624726257262672627726287262972630726317263272633726347263572636726377263872639726407264172642726437264472645726467264772648726497265072651726527265372654726557265672657726587265972660726617266272663726647266572666726677266872669726707267172672726737267472675726767267772678726797268072681726827268372684726857268672687726887268972690726917269272693726947269572696726977269872699727007270172702727037270472705727067270772708727097271072711727127271372714727157271672717727187271972720727217272272723727247272572726727277272872729727307273172732727337273472735727367273772738727397274072741727427274372744727457274672747727487274972750727517275272753727547275572756727577275872759727607276172762727637276472765727667276772768727697277072771727727277372774727757277672777727787277972780727817278272783727847278572786727877278872789727907279172792727937279472795727967279772798727997280072801728027280372804728057280672807728087280972810728117281272813728147281572816728177281872819728207282172822728237282472825728267282772828728297283072831728327283372834728357283672837728387283972840728417284272843728447284572846728477284872849728507285172852728537285472855728567285772858728597286072861728627286372864728657286672867728687286972870728717287272873728747287572876728777287872879728807288172882728837288472885728867288772888728897289072891728927289372894728957289672897728987289972900729017290272903729047290572906729077290872909729107291172912729137291472915729167291772918729197292072921729227292372924729257292672927729287292972930729317293272933729347293572936729377293872939729407294172942729437294472945729467294772948729497295072951729527295372954729557295672957729587295972960729617296272963729647296572966729677296872969729707297172972729737297472975729767297772978729797298072981729827298372984729857298672987729887298972990729917299272993729947299572996729977299872999730007300173002730037300473005730067300773008730097301073011730127301373014730157301673017730187301973020730217302273023730247302573026730277302873029730307303173032730337303473035730367303773038730397304073041730427304373044730457304673047730487304973050730517305273053730547305573056730577305873059730607306173062730637306473065730667306773068730697307073071730727307373074730757307673077730787307973080730817308273083730847308573086730877308873089730907309173092730937309473095730967309773098730997310073101731027310373104731057310673107731087310973110731117311273113731147311573116731177311873119731207312173122731237312473125731267312773128731297313073131731327313373134731357313673137731387313973140731417314273143731447314573146731477314873149731507315173152731537315473155731567315773158731597316073161731627316373164731657316673167731687316973170731717317273173731747317573176731777317873179731807318173182731837318473185731867318773188731897319073191731927319373194731957319673197731987319973200732017320273203732047320573206732077320873209732107321173212732137321473215732167321773218732197322073221732227322373224732257322673227732287322973230732317323273233732347323573236732377323873239732407324173242732437324473245732467324773248732497325073251732527325373254732557325673257732587325973260732617326273263732647326573266732677326873269732707327173272732737327473275732767327773278732797328073281732827328373284732857328673287732887328973290732917329273293732947329573296732977329873299733007330173302733037330473305733067330773308733097331073311733127331373314733157331673317733187331973320733217332273323733247332573326733277332873329733307333173332733337333473335733367333773338733397334073341733427334373344733457334673347733487334973350733517335273353733547335573356733577335873359733607336173362733637336473365733667336773368733697337073371733727337373374733757337673377733787337973380733817338273383733847338573386733877338873389733907339173392733937339473395733967339773398733997340073401734027340373404734057340673407734087340973410734117341273413734147341573416734177341873419734207342173422734237342473425734267342773428734297343073431734327343373434734357343673437734387343973440734417344273443734447344573446734477344873449734507345173452734537345473455734567345773458734597346073461734627346373464734657346673467734687346973470734717347273473734747347573476734777347873479734807348173482734837348473485734867348773488734897349073491734927349373494734957349673497734987349973500735017350273503735047350573506735077350873509735107351173512735137351473515735167351773518735197352073521735227352373524735257352673527735287352973530735317353273533735347353573536735377353873539735407354173542735437354473545735467354773548735497355073551735527355373554735557355673557735587355973560735617356273563735647356573566735677356873569735707357173572735737357473575735767357773578735797358073581735827358373584735857358673587735887358973590735917359273593735947359573596735977359873599736007360173602736037360473605736067360773608736097361073611736127361373614736157361673617736187361973620736217362273623736247362573626736277362873629736307363173632736337363473635736367363773638736397364073641736427364373644736457364673647736487364973650736517365273653736547365573656736577365873659736607366173662736637366473665736667366773668736697367073671736727367373674736757367673677736787367973680736817368273683736847368573686736877368873689736907369173692736937369473695736967369773698736997370073701737027370373704737057370673707737087370973710737117371273713737147371573716737177371873719737207372173722737237372473725737267372773728737297373073731737327373373734737357373673737737387373973740737417374273743737447374573746737477374873749737507375173752737537375473755737567375773758737597376073761737627376373764737657376673767737687376973770737717377273773737747377573776737777377873779737807378173782737837378473785737867378773788737897379073791737927379373794737957379673797737987379973800738017380273803738047380573806738077380873809738107381173812738137381473815738167381773818738197382073821738227382373824738257382673827738287382973830738317383273833738347383573836738377383873839738407384173842738437384473845738467384773848738497385073851738527385373854738557385673857738587385973860738617386273863738647386573866738677386873869738707387173872738737387473875738767387773878738797388073881738827388373884738857388673887738887388973890738917389273893738947389573896738977389873899739007390173902739037390473905739067390773908739097391073911739127391373914739157391673917739187391973920739217392273923739247392573926739277392873929739307393173932739337393473935739367393773938739397394073941739427394373944739457394673947739487394973950739517395273953739547395573956739577395873959739607396173962739637396473965739667396773968739697397073971739727397373974739757397673977739787397973980739817398273983739847398573986739877398873989739907399173992739937399473995739967399773998739997400074001740027400374004740057400674007740087400974010740117401274013740147401574016740177401874019740207402174022740237402474025740267402774028740297403074031740327403374034740357403674037740387403974040740417404274043740447404574046740477404874049740507405174052740537405474055740567405774058740597406074061740627406374064740657406674067740687406974070740717407274073740747407574076740777407874079740807408174082740837408474085740867408774088740897409074091740927409374094740957409674097740987409974100741017410274103741047410574106741077410874109741107411174112741137411474115741167411774118741197412074121741227412374124741257412674127741287412974130741317413274133741347413574136741377413874139741407414174142741437414474145741467414774148741497415074151741527415374154741557415674157741587415974160741617416274163741647416574166741677416874169741707417174172741737417474175741767417774178741797418074181741827418374184741857418674187741887418974190741917419274193741947419574196741977419874199742007420174202742037420474205742067420774208742097421074211742127421374214742157421674217742187421974220742217422274223742247422574226742277422874229742307423174232742337423474235742367423774238742397424074241742427424374244742457424674247742487424974250742517425274253742547425574256742577425874259742607426174262742637426474265742667426774268742697427074271742727427374274742757427674277742787427974280742817428274283742847428574286742877428874289742907429174292742937429474295742967429774298742997430074301743027430374304743057430674307743087430974310743117431274313743147431574316743177431874319743207432174322743237432474325743267432774328743297433074331743327433374334743357433674337743387433974340743417434274343743447434574346743477434874349743507435174352743537435474355743567435774358743597436074361743627436374364743657436674367743687436974370743717437274373743747437574376743777437874379743807438174382743837438474385743867438774388743897439074391743927439374394743957439674397743987439974400744017440274403744047440574406744077440874409744107441174412744137441474415744167441774418744197442074421744227442374424744257442674427744287442974430744317443274433744347443574436744377443874439744407444174442744437444474445744467444774448744497445074451744527445374454744557445674457744587445974460744617446274463744647446574466744677446874469744707447174472744737447474475744767447774478744797448074481744827448374484744857448674487744887448974490744917449274493744947449574496744977449874499745007450174502745037450474505745067450774508745097451074511745127451374514745157451674517745187451974520745217452274523745247452574526745277452874529745307453174532745337453474535745367453774538745397454074541745427454374544745457454674547745487454974550745517455274553745547455574556745577455874559745607456174562745637456474565745667456774568745697457074571745727457374574745757457674577745787457974580745817458274583745847458574586745877458874589745907459174592745937459474595745967459774598745997460074601746027460374604746057460674607746087460974610746117461274613746147461574616746177461874619746207462174622746237462474625746267462774628746297463074631746327463374634746357463674637746387463974640746417464274643746447464574646746477464874649746507465174652746537465474655746567465774658746597466074661746627466374664746657466674667746687466974670746717467274673746747467574676746777467874679746807468174682746837468474685746867468774688746897469074691746927469374694746957469674697746987469974700747017470274703747047470574706747077470874709747107471174712747137471474715747167471774718747197472074721747227472374724747257472674727747287472974730747317473274733747347473574736747377473874739747407474174742747437474474745747467474774748747497475074751747527475374754747557475674757747587475974760747617476274763747647476574766747677476874769747707477174772747737477474775747767477774778747797478074781747827478374784747857478674787747887478974790747917479274793747947479574796747977479874799748007480174802748037480474805748067480774808748097481074811748127481374814748157481674817748187481974820748217482274823748247482574826748277482874829748307483174832748337483474835748367483774838748397484074841748427484374844748457484674847748487484974850748517485274853748547485574856748577485874859748607486174862748637486474865748667486774868748697487074871748727487374874748757487674877748787487974880748817488274883748847488574886748877488874889748907489174892748937489474895748967489774898748997490074901749027490374904749057490674907749087490974910749117491274913749147491574916749177491874919749207492174922749237492474925749267492774928749297493074931749327493374934749357493674937749387493974940749417494274943749447494574946749477494874949749507495174952749537495474955749567495774958749597496074961749627496374964749657496674967749687496974970749717497274973749747497574976749777497874979749807498174982749837498474985749867498774988749897499074991749927499374994749957499674997749987499975000750017500275003750047500575006750077500875009750107501175012750137501475015750167501775018750197502075021750227502375024750257502675027750287502975030750317503275033750347503575036750377503875039750407504175042750437504475045750467504775048750497505075051750527505375054750557505675057750587505975060750617506275063750647506575066750677506875069750707507175072750737507475075750767507775078750797508075081750827508375084750857508675087750887508975090750917509275093750947509575096750977509875099751007510175102751037510475105751067510775108751097511075111751127511375114751157511675117751187511975120751217512275123751247512575126751277512875129751307513175132751337513475135751367513775138751397514075141751427514375144751457514675147751487514975150751517515275153751547515575156751577515875159751607516175162751637516475165751667516775168751697517075171751727517375174751757517675177751787517975180751817518275183751847518575186751877518875189751907519175192751937519475195751967519775198751997520075201752027520375204752057520675207752087520975210752117521275213752147521575216752177521875219752207522175222752237522475225752267522775228752297523075231752327523375234752357523675237752387523975240752417524275243752447524575246752477524875249752507525175252752537525475255752567525775258752597526075261752627526375264752657526675267752687526975270752717527275273752747527575276752777527875279752807528175282752837528475285752867528775288752897529075291752927529375294752957529675297752987529975300753017530275303753047530575306753077530875309753107531175312753137531475315753167531775318753197532075321753227532375324753257532675327753287532975330753317533275333753347533575336753377533875339753407534175342753437534475345753467534775348753497535075351753527535375354753557535675357753587535975360753617536275363753647536575366753677536875369753707537175372753737537475375753767537775378753797538075381753827538375384753857538675387753887538975390753917539275393753947539575396753977539875399754007540175402754037540475405754067540775408754097541075411754127541375414754157541675417754187541975420754217542275423754247542575426754277542875429754307543175432754337543475435754367543775438754397544075441754427544375444754457544675447754487544975450754517545275453754547545575456754577545875459754607546175462754637546475465754667546775468754697547075471754727547375474754757547675477754787547975480754817548275483754847548575486754877548875489754907549175492754937549475495754967549775498754997550075501755027550375504755057550675507755087550975510755117551275513755147551575516755177551875519755207552175522755237552475525755267552775528755297553075531755327553375534755357553675537755387553975540755417554275543755447554575546755477554875549755507555175552755537555475555755567555775558755597556075561755627556375564755657556675567755687556975570755717557275573755747557575576755777557875579755807558175582755837558475585755867558775588755897559075591755927559375594755957559675597755987559975600756017560275603756047560575606756077560875609756107561175612756137561475615756167561775618756197562075621756227562375624756257562675627756287562975630756317563275633756347563575636756377563875639756407564175642756437564475645756467564775648756497565075651756527565375654756557565675657756587565975660756617566275663756647566575666756677566875669756707567175672756737567475675756767567775678756797568075681756827568375684756857568675687756887568975690756917569275693756947569575696756977569875699757007570175702757037570475705757067570775708757097571075711757127571375714757157571675717757187571975720757217572275723757247572575726757277572875729757307573175732757337573475735757367573775738757397574075741757427574375744757457574675747757487574975750757517575275753757547575575756757577575875759757607576175762757637576475765757667576775768757697577075771757727577375774757757577675777757787577975780757817578275783757847578575786757877578875789757907579175792757937579475795757967579775798757997580075801758027580375804758057580675807758087580975810758117581275813758147581575816758177581875819758207582175822758237582475825758267582775828758297583075831758327583375834758357583675837758387583975840758417584275843758447584575846758477584875849758507585175852758537585475855758567585775858758597586075861758627586375864758657586675867758687586975870758717587275873758747587575876758777587875879758807588175882758837588475885758867588775888758897589075891758927589375894758957589675897758987589975900759017590275903759047590575906759077590875909759107591175912759137591475915759167591775918759197592075921759227592375924759257592675927759287592975930759317593275933759347593575936759377593875939759407594175942759437594475945759467594775948759497595075951759527595375954759557595675957759587595975960759617596275963759647596575966759677596875969759707597175972759737597475975759767597775978759797598075981759827598375984759857598675987759887598975990759917599275993759947599575996759977599875999760007600176002760037600476005760067600776008760097601076011760127601376014760157601676017760187601976020760217602276023760247602576026760277602876029760307603176032760337603476035760367603776038760397604076041760427604376044760457604676047760487604976050760517605276053760547605576056760577605876059760607606176062760637606476065760667606776068760697607076071760727607376074760757607676077760787607976080760817608276083760847608576086760877608876089760907609176092760937609476095760967609776098760997610076101761027610376104761057610676107761087610976110761117611276113761147611576116761177611876119761207612176122761237612476125761267612776128761297613076131761327613376134761357613676137761387613976140761417614276143761447614576146761477614876149761507615176152761537615476155761567615776158761597616076161761627616376164761657616676167761687616976170761717617276173761747617576176761777617876179761807618176182761837618476185761867618776188761897619076191761927619376194761957619676197761987619976200762017620276203762047620576206762077620876209762107621176212762137621476215762167621776218762197622076221762227622376224762257622676227762287622976230762317623276233762347623576236762377623876239762407624176242762437624476245762467624776248762497625076251762527625376254762557625676257762587625976260762617626276263762647626576266762677626876269762707627176272762737627476275762767627776278762797628076281762827628376284762857628676287762887628976290762917629276293762947629576296762977629876299763007630176302763037630476305763067630776308763097631076311763127631376314763157631676317763187631976320763217632276323763247632576326763277632876329763307633176332763337633476335763367633776338763397634076341763427634376344763457634676347763487634976350763517635276353763547635576356763577635876359763607636176362763637636476365763667636776368763697637076371763727637376374763757637676377763787637976380763817638276383763847638576386763877638876389763907639176392763937639476395763967639776398763997640076401764027640376404764057640676407764087640976410764117641276413764147641576416764177641876419764207642176422764237642476425764267642776428764297643076431764327643376434764357643676437764387643976440764417644276443764447644576446764477644876449764507645176452764537645476455764567645776458764597646076461764627646376464764657646676467764687646976470764717647276473764747647576476764777647876479764807648176482764837648476485764867648776488764897649076491764927649376494764957649676497764987649976500765017650276503765047650576506765077650876509765107651176512765137651476515765167651776518765197652076521765227652376524765257652676527765287652976530765317653276533765347653576536765377653876539765407654176542765437654476545765467654776548765497655076551765527655376554765557655676557765587655976560765617656276563765647656576566765677656876569765707657176572765737657476575765767657776578765797658076581765827658376584765857658676587765887658976590765917659276593765947659576596765977659876599766007660176602766037660476605766067660776608766097661076611766127661376614766157661676617766187661976620766217662276623766247662576626766277662876629766307663176632766337663476635766367663776638766397664076641766427664376644766457664676647766487664976650766517665276653766547665576656766577665876659766607666176662766637666476665766667666776668766697667076671766727667376674766757667676677766787667976680766817668276683766847668576686766877668876689766907669176692766937669476695766967669776698766997670076701767027670376704767057670676707767087670976710767117671276713767147671576716767177671876719767207672176722767237672476725767267672776728767297673076731767327673376734767357673676737767387673976740767417674276743767447674576746767477674876749767507675176752767537675476755767567675776758767597676076761767627676376764767657676676767767687676976770767717677276773767747677576776767777677876779767807678176782767837678476785767867678776788767897679076791767927679376794767957679676797767987679976800768017680276803768047680576806768077680876809768107681176812768137681476815768167681776818768197682076821768227682376824768257682676827768287682976830768317683276833768347683576836768377683876839768407684176842768437684476845768467684776848768497685076851768527685376854768557685676857768587685976860768617686276863768647686576866768677686876869768707687176872768737687476875768767687776878768797688076881768827688376884768857688676887768887688976890768917689276893768947689576896768977689876899769007690176902769037690476905769067690776908769097691076911769127691376914769157691676917769187691976920769217692276923769247692576926769277692876929769307693176932769337693476935769367693776938769397694076941769427694376944769457694676947769487694976950769517695276953769547695576956769577695876959769607696176962769637696476965769667696776968769697697076971769727697376974769757697676977769787697976980769817698276983769847698576986769877698876989769907699176992769937699476995769967699776998769997700077001770027700377004770057700677007770087700977010770117701277013770147701577016770177701877019770207702177022770237702477025770267702777028770297703077031770327703377034770357703677037770387703977040770417704277043770447704577046770477704877049770507705177052770537705477055770567705777058770597706077061770627706377064770657706677067770687706977070770717707277073770747707577076770777707877079770807708177082770837708477085770867708777088770897709077091770927709377094770957709677097770987709977100771017710277103771047710577106771077710877109771107711177112771137711477115771167711777118771197712077121771227712377124771257712677127771287712977130771317713277133771347713577136771377713877139771407714177142771437714477145771467714777148771497715077151771527715377154771557715677157771587715977160771617716277163771647716577166771677716877169771707717177172771737717477175771767717777178771797718077181771827718377184771857718677187771887718977190771917719277193771947719577196771977719877199772007720177202772037720477205772067720777208772097721077211772127721377214772157721677217772187721977220772217722277223772247722577226772277722877229772307723177232772337723477235772367723777238772397724077241772427724377244772457724677247772487724977250772517725277253772547725577256772577725877259772607726177262772637726477265772667726777268772697727077271772727727377274772757727677277772787727977280772817728277283772847728577286772877728877289772907729177292772937729477295772967729777298772997730077301773027730377304773057730677307773087730977310773117731277313773147731577316773177731877319773207732177322773237732477325773267732777328773297733077331773327733377334773357733677337773387733977340773417734277343773447734577346773477734877349773507735177352773537735477355773567735777358773597736077361773627736377364773657736677367773687736977370773717737277373773747737577376773777737877379773807738177382773837738477385773867738777388773897739077391773927739377394773957739677397773987739977400774017740277403774047740577406774077740877409774107741177412774137741477415774167741777418774197742077421774227742377424774257742677427774287742977430774317743277433774347743577436774377743877439774407744177442774437744477445774467744777448774497745077451774527745377454774557745677457774587745977460774617746277463774647746577466774677746877469774707747177472774737747477475774767747777478774797748077481774827748377484774857748677487774887748977490774917749277493774947749577496774977749877499775007750177502775037750477505775067750777508775097751077511775127751377514775157751677517775187751977520775217752277523775247752577526775277752877529775307753177532775337753477535775367753777538775397754077541775427754377544775457754677547775487754977550775517755277553775547755577556775577755877559775607756177562775637756477565775667756777568775697757077571775727757377574775757757677577775787757977580775817758277583775847758577586775877758877589775907759177592775937759477595775967759777598775997760077601776027760377604776057760677607776087760977610776117761277613776147761577616776177761877619776207762177622776237762477625776267762777628776297763077631776327763377634776357763677637776387763977640776417764277643776447764577646776477764877649776507765177652776537765477655776567765777658776597766077661776627766377664776657766677667776687766977670776717767277673776747767577676776777767877679776807768177682776837768477685776867768777688776897769077691776927769377694776957769677697776987769977700777017770277703777047770577706777077770877709777107771177712777137771477715777167771777718777197772077721777227772377724777257772677727777287772977730777317773277733777347773577736777377773877739777407774177742777437774477745777467774777748777497775077751777527775377754777557775677757777587775977760777617776277763777647776577766777677776877769777707777177772777737777477775777767777777778777797778077781777827778377784777857778677787777887778977790777917779277793777947779577796777977779877799778007780177802778037780477805778067780777808778097781077811778127781377814778157781677817778187781977820778217782277823778247782577826778277782877829778307783177832778337783477835778367783777838778397784077841778427784377844778457784677847778487784977850778517785277853778547785577856778577785877859778607786177862778637786477865778667786777868778697787077871778727787377874778757787677877778787787977880778817788277883778847788577886778877788877889778907789177892778937789477895778967789777898778997790077901779027790377904779057790677907779087790977910779117791277913779147791577916779177791877919779207792177922779237792477925779267792777928779297793077931779327793377934779357793677937779387793977940779417794277943779447794577946779477794877949779507795177952779537795477955779567795777958779597796077961779627796377964779657796677967779687796977970779717797277973779747797577976779777797877979779807798177982779837798477985779867798777988779897799077991779927799377994779957799677997779987799978000780017800278003780047800578006780077800878009780107801178012780137801478015780167801778018780197802078021780227802378024780257802678027780287802978030780317803278033780347803578036780377803878039780407804178042780437804478045780467804778048780497805078051780527805378054780557805678057780587805978060780617806278063780647806578066780677806878069780707807178072780737807478075780767807778078780797808078081780827808378084780857808678087780887808978090780917809278093780947809578096780977809878099781007810178102781037810478105781067810778108781097811078111781127811378114781157811678117781187811978120781217812278123781247812578126781277812878129781307813178132781337813478135781367813778138781397814078141781427814378144781457814678147781487814978150781517815278153781547815578156781577815878159781607816178162781637816478165781667816778168781697817078171781727817378174781757817678177781787817978180781817818278183781847818578186781877818878189781907819178192781937819478195781967819778198781997820078201782027820378204782057820678207782087820978210782117821278213782147821578216782177821878219782207822178222782237822478225782267822778228782297823078231782327823378234782357823678237782387823978240782417824278243782447824578246782477824878249782507825178252782537825478255782567825778258782597826078261782627826378264782657826678267782687826978270782717827278273782747827578276782777827878279782807828178282782837828478285782867828778288782897829078291782927829378294782957829678297782987829978300783017830278303783047830578306783077830878309783107831178312783137831478315783167831778318783197832078321783227832378324783257832678327783287832978330783317833278333783347833578336783377833878339783407834178342783437834478345783467834778348783497835078351783527835378354783557835678357783587835978360783617836278363783647836578366783677836878369783707837178372783737837478375783767837778378783797838078381783827838378384783857838678387783887838978390783917839278393783947839578396783977839878399784007840178402784037840478405784067840778408784097841078411784127841378414784157841678417784187841978420784217842278423784247842578426784277842878429784307843178432784337843478435784367843778438784397844078441784427844378444784457844678447784487844978450784517845278453784547845578456784577845878459784607846178462784637846478465784667846778468784697847078471784727847378474784757847678477784787847978480784817848278483784847848578486784877848878489784907849178492784937849478495784967849778498784997850078501785027850378504785057850678507785087850978510785117851278513785147851578516785177851878519785207852178522785237852478525785267852778528785297853078531785327853378534785357853678537785387853978540785417854278543785447854578546785477854878549785507855178552785537855478555785567855778558785597856078561785627856378564785657856678567785687856978570785717857278573785747857578576785777857878579785807858178582785837858478585785867858778588785897859078591785927859378594785957859678597785987859978600786017860278603786047860578606786077860878609786107861178612786137861478615786167861778618786197862078621786227862378624786257862678627786287862978630786317863278633786347863578636786377863878639786407864178642786437864478645786467864778648786497865078651786527865378654786557865678657786587865978660786617866278663786647866578666786677866878669786707867178672786737867478675786767867778678786797868078681786827868378684786857868678687786887868978690786917869278693786947869578696786977869878699787007870178702787037870478705787067870778708787097871078711787127871378714787157871678717787187871978720787217872278723787247872578726787277872878729787307873178732787337873478735787367873778738787397874078741787427874378744787457874678747787487874978750787517875278753787547875578756787577875878759787607876178762787637876478765787667876778768787697877078771787727877378774787757877678777787787877978780787817878278783787847878578786787877878878789787907879178792787937879478795787967879778798787997880078801788027880378804788057880678807788087880978810788117881278813788147881578816788177881878819788207882178822788237882478825788267882778828788297883078831788327883378834788357883678837788387883978840788417884278843788447884578846788477884878849788507885178852788537885478855788567885778858788597886078861788627886378864788657886678867788687886978870788717887278873788747887578876788777887878879788807888178882788837888478885788867888778888788897889078891788927889378894788957889678897788987889978900789017890278903789047890578906789077890878909789107891178912789137891478915789167891778918789197892078921789227892378924789257892678927789287892978930789317893278933789347893578936789377893878939789407894178942789437894478945789467894778948789497895078951789527895378954789557895678957789587895978960789617896278963789647896578966789677896878969789707897178972789737897478975789767897778978789797898078981789827898378984789857898678987789887898978990789917899278993789947899578996789977899878999790007900179002790037900479005790067900779008790097901079011790127901379014790157901679017790187901979020790217902279023790247902579026790277902879029790307903179032790337903479035790367903779038790397904079041790427904379044790457904679047790487904979050790517905279053790547905579056790577905879059790607906179062790637906479065790667906779068790697907079071790727907379074790757907679077790787907979080790817908279083790847908579086790877908879089790907909179092790937909479095790967909779098790997910079101791027910379104791057910679107791087910979110791117911279113791147911579116791177911879119791207912179122791237912479125791267912779128791297913079131791327913379134791357913679137791387913979140791417914279143791447914579146791477914879149791507915179152791537915479155791567915779158791597916079161791627916379164791657916679167791687916979170791717917279173791747917579176791777917879179791807918179182791837918479185791867918779188791897919079191791927919379194791957919679197791987919979200792017920279203792047920579206792077920879209792107921179212792137921479215792167921779218792197922079221792227922379224792257922679227792287922979230792317923279233792347923579236792377923879239792407924179242792437924479245792467924779248792497925079251792527925379254792557925679257792587925979260792617926279263792647926579266792677926879269792707927179272792737927479275792767927779278792797928079281792827928379284792857928679287792887928979290792917929279293792947929579296792977929879299793007930179302793037930479305793067930779308793097931079311793127931379314793157931679317793187931979320793217932279323793247932579326793277932879329793307933179332793337933479335793367933779338793397934079341793427934379344793457934679347793487934979350793517935279353793547935579356793577935879359793607936179362793637936479365793667936779368793697937079371793727937379374793757937679377793787937979380793817938279383793847938579386793877938879389793907939179392793937939479395793967939779398793997940079401794027940379404794057940679407794087940979410794117941279413794147941579416794177941879419794207942179422794237942479425794267942779428794297943079431794327943379434794357943679437794387943979440794417944279443794447944579446794477944879449794507945179452794537945479455794567945779458794597946079461794627946379464794657946679467794687946979470794717947279473794747947579476794777947879479794807948179482794837948479485794867948779488794897949079491794927949379494794957949679497794987949979500795017950279503795047950579506795077950879509795107951179512795137951479515795167951779518795197952079521795227952379524795257952679527795287952979530795317953279533795347953579536795377953879539795407954179542795437954479545795467954779548795497955079551795527955379554795557955679557795587955979560795617956279563795647956579566795677956879569795707957179572795737957479575795767957779578795797958079581795827958379584795857958679587795887958979590795917959279593795947959579596795977959879599796007960179602796037960479605796067960779608796097961079611796127961379614796157961679617796187961979620796217962279623796247962579626796277962879629796307963179632796337963479635796367963779638796397964079641796427964379644796457964679647796487964979650796517965279653796547965579656796577965879659796607966179662796637966479665796667966779668796697967079671796727967379674796757967679677796787967979680796817968279683796847968579686796877968879689796907969179692796937969479695796967969779698796997970079701797027970379704797057970679707797087970979710797117971279713797147971579716797177971879719797207972179722797237972479725797267972779728797297973079731797327973379734797357973679737797387973979740797417974279743797447974579746797477974879749797507975179752797537975479755797567975779758797597976079761797627976379764797657976679767797687976979770797717977279773797747977579776797777977879779797807978179782797837978479785797867978779788797897979079791797927979379794797957979679797797987979979800798017980279803798047980579806798077980879809798107981179812798137981479815798167981779818798197982079821798227982379824798257982679827798287982979830798317983279833798347983579836798377983879839798407984179842798437984479845798467984779848798497985079851798527985379854798557985679857798587985979860798617986279863798647986579866798677986879869798707987179872798737987479875798767987779878798797988079881798827988379884798857988679887798887988979890798917989279893798947989579896798977989879899799007990179902799037990479905799067990779908799097991079911799127991379914799157991679917799187991979920799217992279923799247992579926799277992879929799307993179932799337993479935799367993779938799397994079941799427994379944799457994679947799487994979950799517995279953799547995579956799577995879959799607996179962799637996479965799667996779968799697997079971799727997379974799757997679977799787997979980799817998279983799847998579986799877998879989799907999179992799937999479995799967999779998799998000080001800028000380004800058000680007800088000980010800118001280013800148001580016800178001880019800208002180022800238002480025800268002780028800298003080031800328003380034800358003680037800388003980040800418004280043800448004580046800478004880049800508005180052800538005480055800568005780058800598006080061800628006380064800658006680067800688006980070800718007280073800748007580076800778007880079800808008180082800838008480085800868008780088800898009080091800928009380094800958009680097800988009980100801018010280103801048010580106801078010880109801108011180112801138011480115801168011780118801198012080121801228012380124801258012680127801288012980130801318013280133801348013580136801378013880139801408014180142801438014480145801468014780148801498015080151801528015380154801558015680157801588015980160801618016280163801648016580166801678016880169801708017180172801738017480175801768017780178801798018080181801828018380184801858018680187801888018980190801918019280193801948019580196801978019880199802008020180202802038020480205802068020780208802098021080211802128021380214802158021680217802188021980220802218022280223802248022580226802278022880229802308023180232802338023480235802368023780238802398024080241802428024380244802458024680247802488024980250802518025280253802548025580256802578025880259802608026180262802638026480265802668026780268802698027080271802728027380274802758027680277802788027980280802818028280283802848028580286802878028880289802908029180292802938029480295802968029780298802998030080301803028030380304803058030680307803088030980310803118031280313803148031580316803178031880319803208032180322803238032480325803268032780328803298033080331803328033380334803358033680337803388033980340803418034280343803448034580346803478034880349803508035180352803538035480355803568035780358803598036080361803628036380364803658036680367803688036980370803718037280373803748037580376803778037880379803808038180382803838038480385803868038780388803898039080391803928039380394803958039680397803988039980400804018040280403804048040580406804078040880409804108041180412804138041480415804168041780418804198042080421804228042380424804258042680427804288042980430804318043280433804348043580436804378043880439804408044180442804438044480445804468044780448804498045080451804528045380454804558045680457804588045980460804618046280463804648046580466804678046880469804708047180472804738047480475804768047780478804798048080481804828048380484804858048680487804888048980490804918049280493804948049580496804978049880499805008050180502805038050480505805068050780508805098051080511805128051380514805158051680517805188051980520805218052280523805248052580526805278052880529805308053180532805338053480535805368053780538805398054080541805428054380544805458054680547805488054980550805518055280553805548055580556805578055880559805608056180562805638056480565805668056780568805698057080571805728057380574805758057680577805788057980580805818058280583805848058580586805878058880589805908059180592805938059480595805968059780598805998060080601806028060380604806058060680607806088060980610806118061280613806148061580616806178061880619806208062180622806238062480625806268062780628806298063080631806328063380634806358063680637806388063980640806418064280643806448064580646806478064880649806508065180652806538065480655806568065780658806598066080661806628066380664806658066680667806688066980670806718067280673806748067580676806778067880679806808068180682806838068480685806868068780688806898069080691806928069380694806958069680697806988069980700807018070280703807048070580706807078070880709807108071180712807138071480715807168071780718807198072080721807228072380724807258072680727807288072980730807318073280733807348073580736807378073880739807408074180742807438074480745807468074780748807498075080751807528075380754807558075680757807588075980760807618076280763807648076580766807678076880769807708077180772807738077480775807768077780778807798078080781807828078380784807858078680787807888078980790807918079280793807948079580796807978079880799808008080180802808038080480805808068080780808808098081080811808128081380814808158081680817808188081980820808218082280823808248082580826808278082880829808308083180832808338083480835808368083780838808398084080841808428084380844808458084680847808488084980850808518085280853808548085580856808578085880859808608086180862808638086480865808668086780868808698087080871808728087380874808758087680877808788087980880808818088280883808848088580886808878088880889808908089180892808938089480895808968089780898808998090080901809028090380904809058090680907809088090980910809118091280913809148091580916809178091880919809208092180922809238092480925809268092780928809298093080931809328093380934809358093680937809388093980940809418094280943809448094580946809478094880949809508095180952809538095480955809568095780958809598096080961809628096380964809658096680967809688096980970809718097280973809748097580976809778097880979809808098180982809838098480985809868098780988809898099080991809928099380994809958099680997809988099981000810018100281003810048100581006810078100881009810108101181012810138101481015810168101781018810198102081021810228102381024810258102681027810288102981030810318103281033810348103581036810378103881039810408104181042810438104481045810468104781048810498105081051810528105381054810558105681057810588105981060810618106281063810648106581066810678106881069810708107181072810738107481075810768107781078810798108081081810828108381084810858108681087810888108981090810918109281093810948109581096810978109881099811008110181102811038110481105811068110781108811098111081111811128111381114811158111681117811188111981120811218112281123811248112581126811278112881129811308113181132811338113481135811368113781138811398114081141811428114381144811458114681147811488114981150811518115281153811548115581156811578115881159811608116181162811638116481165811668116781168811698117081171811728117381174811758117681177811788117981180811818118281183811848118581186811878118881189811908119181192811938119481195811968119781198811998120081201812028120381204812058120681207812088120981210812118121281213812148121581216812178121881219812208122181222812238122481225812268122781228812298123081231812328123381234812358123681237812388123981240812418124281243812448124581246812478124881249812508125181252812538125481255812568125781258812598126081261812628126381264812658126681267812688126981270812718127281273812748127581276812778127881279812808128181282812838128481285812868128781288812898129081291812928129381294812958129681297812988129981300813018130281303813048130581306813078130881309813108131181312813138131481315813168131781318813198132081321813228132381324813258132681327813288132981330813318133281333813348133581336813378133881339813408134181342813438134481345813468134781348813498135081351813528135381354813558135681357813588135981360813618136281363813648136581366813678136881369813708137181372813738137481375813768137781378813798138081381813828138381384813858138681387813888138981390813918139281393813948139581396813978139881399814008140181402814038140481405814068140781408814098141081411814128141381414814158141681417814188141981420814218142281423814248142581426814278142881429814308143181432814338143481435814368143781438814398144081441814428144381444814458144681447814488144981450814518145281453814548145581456814578145881459814608146181462814638146481465814668146781468814698147081471814728147381474814758147681477814788147981480814818148281483814848148581486814878148881489814908149181492814938149481495814968149781498814998150081501815028150381504815058150681507815088150981510815118151281513815148151581516815178151881519815208152181522815238152481525815268152781528815298153081531815328153381534815358153681537815388153981540815418154281543815448154581546815478154881549815508155181552815538155481555815568155781558815598156081561815628156381564815658156681567815688156981570815718157281573815748157581576815778157881579815808158181582815838158481585815868158781588815898159081591815928159381594815958159681597815988159981600816018160281603816048160581606816078160881609816108161181612816138161481615816168161781618816198162081621816228162381624816258162681627816288162981630816318163281633816348163581636816378163881639816408164181642816438164481645816468164781648816498165081651816528165381654816558165681657816588165981660816618166281663816648166581666816678166881669816708167181672816738167481675816768167781678816798168081681816828168381684816858168681687816888168981690816918169281693816948169581696816978169881699817008170181702817038170481705817068170781708817098171081711817128171381714817158171681717817188171981720817218172281723817248172581726817278172881729817308173181732817338173481735817368173781738817398174081741817428174381744817458174681747817488174981750817518175281753817548175581756817578175881759817608176181762817638176481765817668176781768817698177081771817728177381774817758177681777817788177981780817818178281783817848178581786817878178881789817908179181792817938179481795817968179781798817998180081801818028180381804818058180681807818088180981810818118181281813818148181581816818178181881819818208182181822818238182481825818268182781828818298183081831818328183381834818358183681837818388183981840818418184281843818448184581846818478184881849818508185181852818538185481855818568185781858818598186081861818628186381864818658186681867818688186981870818718187281873818748187581876818778187881879818808188181882818838188481885818868188781888818898189081891818928189381894818958189681897818988189981900819018190281903819048190581906819078190881909819108191181912819138191481915819168191781918819198192081921819228192381924819258192681927819288192981930819318193281933819348193581936819378193881939819408194181942819438194481945819468194781948819498195081951819528195381954819558195681957819588195981960819618196281963819648196581966819678196881969819708197181972819738197481975819768197781978819798198081981819828198381984819858198681987819888198981990819918199281993819948199581996819978199881999820008200182002820038200482005820068200782008820098201082011820128201382014820158201682017820188201982020820218202282023820248202582026820278202882029820308203182032820338203482035820368203782038820398204082041820428204382044820458204682047820488204982050820518205282053820548205582056820578205882059820608206182062820638206482065820668206782068820698207082071820728207382074820758207682077820788207982080820818208282083820848208582086820878208882089820908209182092820938209482095820968209782098820998210082101821028210382104821058210682107821088210982110821118211282113821148211582116821178211882119821208212182122821238212482125821268212782128821298213082131821328213382134821358213682137821388213982140821418214282143821448214582146821478214882149821508215182152821538215482155821568215782158821598216082161821628216382164821658216682167821688216982170821718217282173821748217582176821778217882179821808218182182821838218482185821868218782188821898219082191821928219382194821958219682197821988219982200822018220282203822048220582206822078220882209822108221182212822138221482215822168221782218822198222082221822228222382224822258222682227822288222982230822318223282233822348223582236822378223882239822408224182242822438224482245822468224782248822498225082251822528225382254822558225682257822588225982260822618226282263822648226582266822678226882269822708227182272822738227482275822768227782278822798228082281822828228382284822858228682287822888228982290822918229282293822948229582296822978229882299823008230182302823038230482305823068230782308823098231082311823128231382314823158231682317823188231982320823218232282323823248232582326823278232882329823308233182332823338233482335823368233782338823398234082341823428234382344823458234682347823488234982350823518235282353823548235582356823578235882359823608236182362823638236482365823668236782368823698237082371823728237382374823758237682377823788237982380823818238282383823848238582386823878238882389823908239182392823938239482395823968239782398823998240082401824028240382404824058240682407824088240982410824118241282413824148241582416824178241882419824208242182422824238242482425824268242782428824298243082431824328243382434824358243682437824388243982440824418244282443824448244582446824478244882449824508245182452824538245482455824568245782458824598246082461824628246382464824658246682467824688246982470824718247282473824748247582476824778247882479824808248182482824838248482485824868248782488824898249082491824928249382494824958249682497824988249982500825018250282503825048250582506825078250882509825108251182512825138251482515825168251782518825198252082521825228252382524825258252682527825288252982530825318253282533825348253582536825378253882539825408254182542825438254482545825468254782548825498255082551825528255382554825558255682557825588255982560825618256282563825648256582566825678256882569825708257182572825738257482575825768257782578825798258082581825828258382584825858258682587825888258982590825918259282593825948259582596825978259882599826008260182602826038260482605826068260782608826098261082611826128261382614826158261682617826188261982620826218262282623826248262582626826278262882629826308263182632826338263482635826368263782638826398264082641826428264382644826458264682647826488264982650826518265282653826548265582656826578265882659826608266182662826638266482665826668266782668826698267082671826728267382674826758267682677826788267982680826818268282683826848268582686826878268882689826908269182692826938269482695826968269782698826998270082701827028270382704827058270682707827088270982710827118271282713827148271582716827178271882719827208272182722827238272482725827268272782728827298273082731827328273382734827358273682737827388273982740827418274282743827448274582746827478274882749827508275182752827538275482755827568275782758827598276082761827628276382764827658276682767827688276982770827718277282773827748277582776827778277882779827808278182782827838278482785827868278782788827898279082791827928279382794827958279682797827988279982800828018280282803828048280582806828078280882809828108281182812828138281482815828168281782818828198282082821828228282382824828258282682827828288282982830828318283282833828348283582836828378283882839828408284182842828438284482845828468284782848828498285082851828528285382854828558285682857828588285982860828618286282863828648286582866828678286882869828708287182872828738287482875828768287782878828798288082881828828288382884828858288682887828888288982890828918289282893828948289582896828978289882899829008290182902829038290482905829068290782908829098291082911829128291382914829158291682917829188291982920829218292282923829248292582926829278292882929829308293182932829338293482935829368293782938829398294082941829428294382944829458294682947829488294982950829518295282953829548295582956829578295882959829608296182962829638296482965829668296782968829698297082971829728297382974829758297682977829788297982980829818298282983829848298582986829878298882989829908299182992829938299482995829968299782998829998300083001830028300383004830058300683007830088300983010830118301283013830148301583016830178301883019830208302183022830238302483025830268302783028830298303083031830328303383034830358303683037830388303983040830418304283043830448304583046830478304883049830508305183052830538305483055830568305783058830598306083061830628306383064830658306683067830688306983070830718307283073830748307583076830778307883079830808308183082830838308483085830868308783088830898309083091830928309383094830958309683097830988309983100831018310283103831048310583106831078310883109831108311183112831138311483115831168311783118831198312083121831228312383124831258312683127831288312983130831318313283133831348313583136831378313883139831408314183142831438314483145831468314783148831498315083151831528315383154831558315683157831588315983160831618316283163831648316583166831678316883169831708317183172831738317483175831768317783178831798318083181831828318383184831858318683187831888318983190831918319283193831948319583196831978319883199832008320183202832038320483205832068320783208832098321083211832128321383214832158321683217832188321983220832218322283223832248322583226832278322883229832308323183232832338323483235832368323783238832398324083241832428324383244832458324683247832488324983250832518325283253832548325583256832578325883259832608326183262832638326483265832668326783268832698327083271832728327383274832758327683277832788327983280832818328283283832848328583286832878328883289832908329183292832938329483295832968329783298832998330083301833028330383304833058330683307833088330983310833118331283313833148331583316833178331883319833208332183322833238332483325833268332783328833298333083331833328333383334833358333683337833388333983340833418334283343833448334583346833478334883349833508335183352833538335483355833568335783358833598336083361833628336383364833658336683367833688336983370833718337283373833748337583376833778337883379833808338183382833838338483385833868338783388833898339083391833928339383394833958339683397833988339983400834018340283403834048340583406834078340883409834108341183412834138341483415834168341783418834198342083421834228342383424834258342683427834288342983430834318343283433834348343583436834378343883439834408344183442834438344483445834468344783448834498345083451834528345383454834558345683457834588345983460834618346283463834648346583466834678346883469834708347183472834738347483475834768347783478834798348083481834828348383484834858348683487834888348983490834918349283493834948349583496834978349883499835008350183502835038350483505835068350783508835098351083511835128351383514835158351683517835188351983520835218352283523835248352583526835278352883529835308353183532835338353483535835368353783538835398354083541835428354383544835458354683547835488354983550835518355283553835548355583556835578355883559835608356183562835638356483565835668356783568835698357083571835728357383574835758357683577835788357983580835818358283583835848358583586835878358883589835908359183592835938359483595835968359783598835998360083601836028360383604836058360683607836088360983610836118361283613836148361583616836178361883619836208362183622836238362483625836268362783628836298363083631836328363383634836358363683637836388363983640836418364283643836448364583646836478364883649836508365183652836538365483655836568365783658836598366083661836628366383664836658366683667836688366983670836718367283673836748367583676836778367883679836808368183682836838368483685836868368783688836898369083691836928369383694836958369683697836988369983700837018370283703837048370583706837078370883709837108371183712837138371483715837168371783718837198372083721837228372383724837258372683727837288372983730837318373283733837348373583736837378373883739837408374183742837438374483745837468374783748837498375083751837528375383754837558375683757837588375983760837618376283763837648376583766837678376883769837708377183772837738377483775837768377783778837798378083781837828378383784837858378683787837888378983790837918379283793837948379583796837978379883799838008380183802838038380483805838068380783808838098381083811838128381383814838158381683817838188381983820838218382283823838248382583826838278382883829838308383183832838338383483835838368383783838838398384083841838428384383844838458384683847838488384983850838518385283853838548385583856838578385883859838608386183862838638386483865838668386783868838698387083871838728387383874838758387683877838788387983880838818388283883838848388583886838878388883889838908389183892838938389483895838968389783898838998390083901839028390383904839058390683907839088390983910839118391283913839148391583916839178391883919839208392183922839238392483925839268392783928839298393083931839328393383934839358393683937839388393983940839418394283943839448394583946839478394883949839508395183952839538395483955839568395783958839598396083961839628396383964839658396683967839688396983970839718397283973839748397583976839778397883979839808398183982839838398483985839868398783988839898399083991839928399383994839958399683997839988399984000840018400284003840048400584006840078400884009840108401184012840138401484015840168401784018840198402084021840228402384024840258402684027840288402984030840318403284033840348403584036840378403884039840408404184042840438404484045840468404784048840498405084051840528405384054840558405684057840588405984060840618406284063840648406584066840678406884069840708407184072840738407484075840768407784078840798408084081840828408384084840858408684087840888408984090840918409284093840948409584096840978409884099841008410184102841038410484105841068410784108841098411084111841128411384114841158411684117841188411984120841218412284123841248412584126841278412884129841308413184132841338413484135841368413784138841398414084141841428414384144841458414684147841488414984150841518415284153841548415584156841578415884159841608416184162841638416484165841668416784168841698417084171841728417384174841758417684177841788417984180841818418284183841848418584186841878418884189841908419184192841938419484195841968419784198841998420084201842028420384204842058420684207842088420984210842118421284213842148421584216842178421884219842208422184222842238422484225842268422784228842298423084231842328423384234842358423684237842388423984240842418424284243842448424584246842478424884249842508425184252842538425484255842568425784258842598426084261842628426384264842658426684267842688426984270842718427284273842748427584276842778427884279842808428184282842838428484285842868428784288842898429084291842928429384294842958429684297842988429984300843018430284303843048430584306843078430884309843108431184312843138431484315843168431784318843198432084321843228432384324843258432684327843288432984330843318433284333843348433584336843378433884339843408434184342843438434484345843468434784348843498435084351843528435384354843558435684357843588435984360843618436284363843648436584366843678436884369843708437184372843738437484375843768437784378843798438084381843828438384384843858438684387843888438984390843918439284393843948439584396843978439884399844008440184402844038440484405844068440784408844098441084411844128441384414844158441684417844188441984420844218442284423844248442584426844278442884429844308443184432844338443484435844368443784438844398444084441844428444384444844458444684447844488444984450844518445284453844548445584456844578445884459844608446184462844638446484465844668446784468844698447084471844728447384474844758447684477844788447984480844818448284483844848448584486844878448884489844908449184492844938449484495844968449784498844998450084501845028450384504845058450684507845088450984510845118451284513845148451584516845178451884519845208452184522845238452484525845268452784528845298453084531845328453384534845358453684537845388453984540845418454284543845448454584546845478454884549845508455184552845538455484555845568455784558845598456084561845628456384564845658456684567845688456984570845718457284573845748457584576845778457884579845808458184582845838458484585845868458784588845898459084591845928459384594845958459684597845988459984600846018460284603846048460584606846078460884609846108461184612846138461484615846168461784618846198462084621846228462384624846258462684627846288462984630846318463284633846348463584636846378463884639846408464184642846438464484645846468464784648846498465084651846528465384654846558465684657846588465984660846618466284663846648466584666846678466884669846708467184672846738467484675846768467784678846798468084681846828468384684846858468684687846888468984690846918469284693846948469584696846978469884699847008470184702847038470484705847068470784708847098471084711847128471384714847158471684717847188471984720847218472284723847248472584726847278472884729847308473184732847338473484735847368473784738847398474084741847428474384744847458474684747847488474984750847518475284753847548475584756847578475884759847608476184762847638476484765847668476784768847698477084771847728477384774847758477684777847788477984780847818478284783847848478584786847878478884789847908479184792847938479484795847968479784798847998480084801848028480384804848058480684807848088480984810848118481284813848148481584816848178481884819848208482184822848238482484825848268482784828848298483084831848328483384834848358483684837848388483984840848418484284843848448484584846848478484884849848508485184852848538485484855848568485784858848598486084861848628486384864848658486684867848688486984870848718487284873848748487584876848778487884879848808488184882848838488484885848868488784888848898489084891848928489384894848958489684897848988489984900849018490284903849048490584906849078490884909849108491184912849138491484915849168491784918849198492084921849228492384924849258492684927849288492984930849318493284933849348493584936849378493884939849408494184942849438494484945849468494784948849498495084951849528495384954849558495684957849588495984960849618496284963849648496584966849678496884969849708497184972849738497484975849768497784978849798498084981849828498384984849858498684987849888498984990849918499284993849948499584996849978499884999850008500185002850038500485005850068500785008850098501085011850128501385014850158501685017850188501985020850218502285023850248502585026850278502885029850308503185032850338503485035850368503785038850398504085041850428504385044850458504685047850488504985050850518505285053850548505585056850578505885059850608506185062850638506485065850668506785068850698507085071850728507385074850758507685077850788507985080850818508285083850848508585086850878508885089850908509185092850938509485095850968509785098850998510085101851028510385104851058510685107851088510985110851118511285113851148511585116851178511885119851208512185122851238512485125851268512785128851298513085131851328513385134851358513685137851388513985140851418514285143851448514585146851478514885149851508515185152851538515485155851568515785158851598516085161851628516385164851658516685167851688516985170851718517285173851748517585176851778517885179851808518185182851838518485185851868518785188851898519085191851928519385194851958519685197851988519985200852018520285203852048520585206852078520885209852108521185212852138521485215852168521785218852198522085221852228522385224852258522685227852288522985230852318523285233852348523585236852378523885239852408524185242852438524485245852468524785248852498525085251852528525385254852558525685257852588525985260852618526285263852648526585266852678526885269852708527185272852738527485275852768527785278852798528085281852828528385284852858528685287852888528985290852918529285293852948529585296852978529885299853008530185302853038530485305853068530785308853098531085311853128531385314853158531685317853188531985320853218532285323853248532585326853278532885329853308533185332853338533485335853368533785338853398534085341853428534385344853458534685347853488534985350853518535285353853548535585356853578535885359853608536185362853638536485365853668536785368853698537085371853728537385374853758537685377853788537985380853818538285383853848538585386853878538885389853908539185392853938539485395853968539785398853998540085401854028540385404854058540685407854088540985410854118541285413854148541585416854178541885419854208542185422854238542485425854268542785428854298543085431854328543385434854358543685437854388543985440854418544285443854448544585446854478544885449854508545185452854538545485455854568545785458854598546085461854628546385464854658546685467854688546985470854718547285473854748547585476854778547885479854808548185482854838548485485854868548785488854898549085491854928549385494854958549685497854988549985500855018550285503855048550585506855078550885509855108551185512855138551485515855168551785518855198552085521855228552385524855258552685527855288552985530855318553285533855348553585536855378553885539855408554185542855438554485545855468554785548855498555085551855528555385554855558555685557855588555985560855618556285563855648556585566855678556885569855708557185572855738557485575855768557785578855798558085581855828558385584855858558685587855888558985590855918559285593855948559585596855978559885599856008560185602856038560485605856068560785608856098561085611856128561385614856158561685617856188561985620856218562285623856248562585626856278562885629856308563185632856338563485635856368563785638856398564085641856428564385644856458564685647856488564985650856518565285653856548565585656856578565885659856608566185662856638566485665856668566785668856698567085671856728567385674856758567685677856788567985680856818568285683856848568585686856878568885689856908569185692856938569485695856968569785698856998570085701857028570385704857058570685707857088570985710857118571285713857148571585716857178571885719857208572185722857238572485725857268572785728857298573085731857328573385734857358573685737857388573985740857418574285743857448574585746857478574885749857508575185752857538575485755857568575785758857598576085761857628576385764857658576685767857688576985770857718577285773857748577585776857778577885779857808578185782857838578485785857868578785788857898579085791857928579385794857958579685797857988579985800858018580285803858048580585806858078580885809858108581185812858138581485815858168581785818858198582085821858228582385824858258582685827858288582985830858318583285833858348583585836858378583885839858408584185842858438584485845858468584785848858498585085851858528585385854858558585685857858588585985860858618586285863858648586585866858678586885869858708587185872858738587485875858768587785878858798588085881858828588385884858858588685887858888588985890858918589285893858948589585896858978589885899859008590185902859038590485905859068590785908859098591085911859128591385914859158591685917859188591985920859218592285923859248592585926859278592885929859308593185932859338593485935859368593785938859398594085941859428594385944859458594685947859488594985950859518595285953859548595585956859578595885959859608596185962859638596485965859668596785968859698597085971859728597385974859758597685977859788597985980859818598285983859848598585986859878598885989859908599185992859938599485995859968599785998859998600086001860028600386004860058600686007860088600986010860118601286013860148601586016860178601886019860208602186022860238602486025860268602786028860298603086031860328603386034860358603686037860388603986040860418604286043860448604586046860478604886049860508605186052860538605486055860568605786058860598606086061860628606386064860658606686067860688606986070860718607286073860748607586076860778607886079860808608186082860838608486085860868608786088860898609086091860928609386094860958609686097860988609986100861018610286103861048610586106861078610886109861108611186112861138611486115861168611786118861198612086121861228612386124861258612686127861288612986130861318613286133861348613586136861378613886139861408614186142861438614486145861468614786148861498615086151861528615386154861558615686157861588615986160861618616286163861648616586166861678616886169861708617186172861738617486175861768617786178861798618086181861828618386184861858618686187861888618986190861918619286193861948619586196861978619886199862008620186202862038620486205862068620786208862098621086211862128621386214862158621686217862188621986220862218622286223862248622586226862278622886229862308623186232862338623486235862368623786238862398624086241862428624386244862458624686247862488624986250862518625286253862548625586256862578625886259862608626186262862638626486265862668626786268862698627086271862728627386274862758627686277862788627986280862818628286283862848628586286862878628886289862908629186292862938629486295862968629786298862998630086301863028630386304863058630686307863088630986310863118631286313863148631586316863178631886319863208632186322863238632486325863268632786328863298633086331863328633386334863358633686337863388633986340863418634286343863448634586346863478634886349863508635186352863538635486355863568635786358863598636086361863628636386364863658636686367863688636986370863718637286373863748637586376863778637886379863808638186382863838638486385863868638786388863898639086391863928639386394863958639686397863988639986400864018640286403864048640586406864078640886409864108641186412864138641486415864168641786418864198642086421864228642386424864258642686427864288642986430864318643286433864348643586436864378643886439864408644186442864438644486445864468644786448864498645086451864528645386454864558645686457864588645986460864618646286463864648646586466864678646886469864708647186472864738647486475864768647786478864798648086481864828648386484864858648686487864888648986490864918649286493864948649586496864978649886499865008650186502865038650486505865068650786508865098651086511865128651386514865158651686517865188651986520865218652286523865248652586526865278652886529865308653186532865338653486535865368653786538865398654086541865428654386544865458654686547865488654986550865518655286553865548655586556865578655886559865608656186562865638656486565865668656786568865698657086571865728657386574865758657686577865788657986580865818658286583865848658586586865878658886589865908659186592865938659486595865968659786598865998660086601866028660386604866058660686607866088660986610866118661286613866148661586616866178661886619866208662186622866238662486625866268662786628866298663086631866328663386634866358663686637866388663986640866418664286643866448664586646866478664886649866508665186652866538665486655866568665786658866598666086661866628666386664866658666686667866688666986670866718667286673866748667586676866778667886679866808668186682866838668486685866868668786688866898669086691866928669386694866958669686697866988669986700867018670286703867048670586706867078670886709867108671186712867138671486715867168671786718867198672086721867228672386724867258672686727867288672986730867318673286733867348673586736867378673886739867408674186742867438674486745867468674786748867498675086751867528675386754867558675686757867588675986760867618676286763867648676586766867678676886769867708677186772867738677486775867768677786778867798678086781867828678386784867858678686787867888678986790867918679286793867948679586796867978679886799868008680186802868038680486805868068680786808868098681086811868128681386814868158681686817868188681986820868218682286823868248682586826868278682886829868308683186832868338683486835868368683786838868398684086841868428684386844868458684686847868488684986850868518685286853868548685586856868578685886859868608686186862868638686486865868668686786868868698687086871868728687386874868758687686877868788687986880868818688286883868848688586886868878688886889868908689186892868938689486895868968689786898868998690086901869028690386904869058690686907869088690986910869118691286913869148691586916869178691886919869208692186922869238692486925869268692786928869298693086931869328693386934869358693686937869388693986940869418694286943869448694586946869478694886949869508695186952869538695486955869568695786958869598696086961869628696386964869658696686967869688696986970869718697286973869748697586976869778697886979869808698186982869838698486985869868698786988869898699086991869928699386994869958699686997869988699987000870018700287003870048700587006870078700887009870108701187012870138701487015870168701787018870198702087021870228702387024870258702687027870288702987030870318703287033870348703587036870378703887039870408704187042870438704487045870468704787048870498705087051870528705387054870558705687057870588705987060870618706287063870648706587066870678706887069870708707187072870738707487075870768707787078870798708087081870828708387084870858708687087870888708987090870918709287093870948709587096870978709887099871008710187102871038710487105871068710787108871098711087111871128711387114871158711687117871188711987120871218712287123871248712587126871278712887129871308713187132871338713487135871368713787138871398714087141871428714387144871458714687147871488714987150871518715287153871548715587156871578715887159871608716187162871638716487165871668716787168871698717087171871728717387174871758717687177871788717987180871818718287183871848718587186871878718887189871908719187192871938719487195871968719787198871998720087201872028720387204872058720687207872088720987210872118721287213872148721587216872178721887219872208722187222872238722487225872268722787228872298723087231872328723387234872358723687237872388723987240872418724287243872448724587246872478724887249872508725187252872538725487255872568725787258872598726087261872628726387264872658726687267872688726987270872718727287273872748727587276872778727887279872808728187282872838728487285872868728787288872898729087291872928729387294872958729687297872988729987300873018730287303873048730587306873078730887309873108731187312873138731487315873168731787318873198732087321873228732387324873258732687327873288732987330873318733287333873348733587336873378733887339873408734187342873438734487345873468734787348873498735087351873528735387354873558735687357873588735987360873618736287363873648736587366873678736887369873708737187372873738737487375873768737787378873798738087381873828738387384873858738687387873888738987390873918739287393873948739587396873978739887399874008740187402874038740487405874068740787408874098741087411874128741387414874158741687417874188741987420874218742287423874248742587426874278742887429874308743187432874338743487435874368743787438874398744087441874428744387444874458744687447874488744987450874518745287453874548745587456874578745887459874608746187462874638746487465874668746787468874698747087471874728747387474874758747687477874788747987480874818748287483874848748587486874878748887489874908749187492874938749487495874968749787498874998750087501875028750387504875058750687507875088750987510875118751287513875148751587516875178751887519875208752187522875238752487525875268752787528875298753087531875328753387534875358753687537875388753987540875418754287543875448754587546875478754887549875508755187552875538755487555875568755787558875598756087561875628756387564875658756687567875688756987570875718757287573875748757587576875778757887579875808758187582875838758487585875868758787588875898759087591875928759387594875958759687597875988759987600876018760287603876048760587606876078760887609876108761187612876138761487615876168761787618876198762087621876228762387624876258762687627876288762987630876318763287633876348763587636876378763887639876408764187642876438764487645876468764787648876498765087651876528765387654876558765687657876588765987660876618766287663876648766587666876678766887669876708767187672876738767487675876768767787678876798768087681876828768387684876858768687687876888768987690876918769287693876948769587696876978769887699877008770187702877038770487705877068770787708877098771087711877128771387714877158771687717877188771987720877218772287723877248772587726877278772887729877308773187732877338773487735877368773787738877398774087741877428774387744877458774687747877488774987750877518775287753877548775587756877578775887759877608776187762877638776487765877668776787768877698777087771877728777387774877758777687777877788777987780877818778287783877848778587786877878778887789877908779187792877938779487795877968779787798877998780087801878028780387804878058780687807878088780987810878118781287813878148781587816878178781887819878208782187822878238782487825878268782787828878298783087831878328783387834878358783687837878388783987840878418784287843878448784587846878478784887849878508785187852878538785487855878568785787858878598786087861878628786387864878658786687867878688786987870878718787287873878748787587876878778787887879878808788187882878838788487885878868788787888878898789087891878928789387894878958789687897878988789987900879018790287903879048790587906879078790887909879108791187912879138791487915879168791787918879198792087921879228792387924879258792687927879288792987930879318793287933879348793587936879378793887939879408794187942879438794487945879468794787948879498795087951879528795387954879558795687957879588795987960879618796287963879648796587966879678796887969879708797187972879738797487975879768797787978879798798087981879828798387984879858798687987879888798987990879918799287993879948799587996879978799887999880008800188002880038800488005880068800788008880098801088011880128801388014880158801688017880188801988020880218802288023880248802588026880278802888029880308803188032880338803488035880368803788038880398804088041880428804388044880458804688047880488804988050880518805288053880548805588056880578805888059880608806188062880638806488065880668806788068880698807088071880728807388074880758807688077880788807988080880818808288083880848808588086880878808888089880908809188092880938809488095880968809788098880998810088101881028810388104881058810688107881088810988110881118811288113881148811588116881178811888119881208812188122881238812488125881268812788128881298813088131881328813388134881358813688137881388813988140881418814288143881448814588146881478814888149881508815188152881538815488155881568815788158881598816088161881628816388164881658816688167881688816988170881718817288173881748817588176881778817888179881808818188182881838818488185881868818788188881898819088191881928819388194881958819688197881988819988200882018820288203882048820588206882078820888209882108821188212882138821488215882168821788218882198822088221882228822388224882258822688227882288822988230882318823288233882348823588236882378823888239882408824188242882438824488245882468824788248882498825088251882528825388254882558825688257882588825988260882618826288263882648826588266882678826888269882708827188272882738827488275882768827788278882798828088281882828828388284882858828688287882888828988290882918829288293882948829588296882978829888299883008830188302883038830488305883068830788308883098831088311883128831388314883158831688317883188831988320883218832288323883248832588326883278832888329883308833188332883338833488335883368833788338883398834088341883428834388344883458834688347883488834988350883518835288353883548835588356883578835888359883608836188362883638836488365883668836788368883698837088371883728837388374883758837688377883788837988380883818838288383883848838588386883878838888389883908839188392883938839488395883968839788398883998840088401884028840388404884058840688407884088840988410884118841288413884148841588416884178841888419884208842188422884238842488425884268842788428884298843088431884328843388434884358843688437884388843988440884418844288443884448844588446884478844888449884508845188452884538845488455884568845788458884598846088461884628846388464884658846688467884688846988470884718847288473884748847588476884778847888479884808848188482884838848488485884868848788488884898849088491884928849388494884958849688497884988849988500885018850288503885048850588506885078850888509885108851188512885138851488515885168851788518885198852088521885228852388524885258852688527885288852988530885318853288533885348853588536885378853888539885408854188542885438854488545885468854788548885498855088551885528855388554885558855688557885588855988560885618856288563885648856588566885678856888569885708857188572885738857488575885768857788578885798858088581885828858388584885858858688587885888858988590885918859288593885948859588596885978859888599886008860188602886038860488605886068860788608886098861088611886128861388614886158861688617886188861988620886218862288623886248862588626886278862888629886308863188632886338863488635886368863788638886398864088641886428864388644886458864688647886488864988650886518865288653886548865588656886578865888659886608866188662886638866488665886668866788668886698867088671886728867388674886758867688677886788867988680886818868288683886848868588686886878868888689886908869188692886938869488695886968869788698886998870088701887028870388704887058870688707887088870988710887118871288713887148871588716887178871888719887208872188722887238872488725887268872788728887298873088731887328873388734887358873688737887388873988740887418874288743887448874588746887478874888749887508875188752887538875488755887568875788758887598876088761887628876388764887658876688767887688876988770887718877288773887748877588776887778877888779887808878188782887838878488785887868878788788887898879088791887928879388794887958879688797887988879988800888018880288803888048880588806888078880888809888108881188812888138881488815888168881788818888198882088821888228882388824888258882688827888288882988830888318883288833888348883588836888378883888839888408884188842888438884488845888468884788848888498885088851888528885388854888558885688857888588885988860888618886288863888648886588866888678886888869888708887188872888738887488875888768887788878888798888088881888828888388884888858888688887888888888988890888918889288893888948889588896888978889888899889008890188902889038890488905889068890788908889098891088911889128891388914889158891688917889188891988920889218892288923889248892588926889278892888929889308893188932889338893488935889368893788938889398894088941889428894388944889458894688947889488894988950889518895288953889548895588956889578895888959889608896188962889638896488965889668896788968889698897088971889728897388974889758897688977889788897988980889818898288983889848898588986889878898888989889908899188992889938899488995889968899788998889998900089001890028900389004890058900689007890088900989010890118901289013890148901589016890178901889019890208902189022890238902489025890268902789028890298903089031890328903389034890358903689037890388903989040890418904289043890448904589046890478904889049890508905189052890538905489055890568905789058890598906089061890628906389064890658906689067890688906989070890718907289073890748907589076890778907889079890808908189082890838908489085890868908789088890898909089091890928909389094890958909689097890988909989100891018910289103891048910589106891078910889109891108911189112891138911489115891168911789118891198912089121891228912389124891258912689127891288912989130891318913289133891348913589136891378913889139891408914189142891438914489145891468914789148891498915089151891528915389154891558915689157891588915989160891618916289163891648916589166891678916889169891708917189172891738917489175891768917789178891798918089181891828918389184891858918689187891888918989190891918919289193891948919589196891978919889199892008920189202892038920489205892068920789208892098921089211892128921389214892158921689217892188921989220892218922289223892248922589226892278922889229892308923189232892338923489235892368923789238892398924089241892428924389244892458924689247892488924989250892518925289253892548925589256892578925889259892608926189262892638926489265892668926789268892698927089271892728927389274892758927689277892788927989280892818928289283892848928589286892878928889289892908929189292892938929489295892968929789298892998930089301893028930389304893058930689307893088930989310893118931289313893148931589316893178931889319893208932189322893238932489325893268932789328893298933089331893328933389334893358933689337893388933989340893418934289343893448934589346893478934889349893508935189352893538935489355893568935789358893598936089361893628936389364893658936689367893688936989370893718937289373893748937589376893778937889379893808938189382893838938489385893868938789388893898939089391893928939389394893958939689397893988939989400894018940289403894048940589406894078940889409894108941189412894138941489415894168941789418894198942089421894228942389424894258942689427894288942989430894318943289433894348943589436894378943889439894408944189442894438944489445894468944789448894498945089451894528945389454894558945689457894588945989460894618946289463894648946589466894678946889469894708947189472894738947489475894768947789478894798948089481894828948389484894858948689487894888948989490894918949289493894948949589496894978949889499895008950189502895038950489505895068950789508895098951089511895128951389514895158951689517895188951989520895218952289523895248952589526895278952889529895308953189532895338953489535895368953789538895398954089541895428954389544895458954689547895488954989550895518955289553895548955589556895578955889559895608956189562895638956489565895668956789568895698957089571895728957389574895758957689577895788957989580895818958289583895848958589586895878958889589895908959189592895938959489595895968959789598895998960089601896028960389604896058960689607896088960989610896118961289613896148961589616896178961889619896208962189622896238962489625896268962789628896298963089631896328963389634896358963689637896388963989640896418964289643896448964589646896478964889649896508965189652896538965489655896568965789658896598966089661896628966389664896658966689667896688966989670896718967289673896748967589676896778967889679896808968189682896838968489685896868968789688896898969089691896928969389694896958969689697896988969989700897018970289703897048970589706897078970889709897108971189712897138971489715897168971789718897198972089721897228972389724897258972689727897288972989730897318973289733897348973589736897378973889739897408974189742897438974489745897468974789748897498975089751897528975389754897558975689757897588975989760897618976289763897648976589766897678976889769897708977189772897738977489775897768977789778897798978089781897828978389784897858978689787897888978989790897918979289793897948979589796897978979889799898008980189802898038980489805898068980789808898098981089811898128981389814898158981689817898188981989820898218982289823898248982589826898278982889829898308983189832898338983489835898368983789838898398984089841898428984389844898458984689847898488984989850898518985289853898548985589856898578985889859898608986189862898638986489865898668986789868898698987089871898728987389874898758987689877898788987989880898818988289883898848988589886898878988889889898908989189892898938989489895898968989789898898998990089901899028990389904899058990689907899088990989910899118991289913899148991589916899178991889919899208992189922899238992489925899268992789928899298993089931899328993389934899358993689937899388993989940899418994289943899448994589946899478994889949899508995189952899538995489955899568995789958899598996089961899628996389964899658996689967899688996989970899718997289973899748997589976899778997889979899808998189982899838998489985899868998789988899898999089991899928999389994899958999689997899988999990000900019000290003900049000590006900079000890009900109001190012900139001490015900169001790018900199002090021900229002390024900259002690027900289002990030900319003290033900349003590036900379003890039900409004190042900439004490045900469004790048900499005090051900529005390054900559005690057900589005990060900619006290063900649006590066900679006890069900709007190072900739007490075900769007790078900799008090081900829008390084900859008690087900889008990090900919009290093900949009590096900979009890099901009010190102901039010490105901069010790108901099011090111901129011390114901159011690117901189011990120901219012290123901249012590126901279012890129901309013190132901339013490135901369013790138901399014090141901429014390144901459014690147901489014990150901519015290153901549015590156901579015890159901609016190162901639016490165901669016790168901699017090171901729017390174901759017690177901789017990180901819018290183901849018590186901879018890189901909019190192901939019490195901969019790198901999020090201902029020390204902059020690207902089020990210902119021290213902149021590216902179021890219902209022190222902239022490225902269022790228902299023090231902329023390234902359023690237902389023990240902419024290243902449024590246902479024890249902509025190252902539025490255902569025790258902599026090261902629026390264902659026690267902689026990270902719027290273902749027590276902779027890279902809028190282902839028490285902869028790288902899029090291902929029390294902959029690297902989029990300903019030290303903049030590306903079030890309903109031190312903139031490315903169031790318903199032090321903229032390324903259032690327903289032990330903319033290333903349033590336903379033890339903409034190342903439034490345903469034790348903499035090351903529035390354903559035690357903589035990360903619036290363903649036590366903679036890369903709037190372903739037490375903769037790378903799038090381903829038390384903859038690387903889038990390903919039290393903949039590396903979039890399904009040190402904039040490405904069040790408904099041090411904129041390414904159041690417904189041990420904219042290423904249042590426904279042890429904309043190432904339043490435904369043790438904399044090441904429044390444904459044690447904489044990450904519045290453904549045590456904579045890459904609046190462904639046490465904669046790468904699047090471904729047390474904759047690477904789047990480904819048290483904849048590486904879048890489904909049190492904939049490495904969049790498904999050090501905029050390504905059050690507905089050990510905119051290513905149051590516905179051890519905209052190522905239052490525905269052790528905299053090531905329053390534905359053690537905389053990540905419054290543905449054590546905479054890549905509055190552905539055490555905569055790558905599056090561905629056390564905659056690567905689056990570905719057290573905749057590576905779057890579905809058190582905839058490585905869058790588905899059090591905929059390594905959059690597905989059990600906019060290603906049060590606906079060890609906109061190612906139061490615906169061790618906199062090621906229062390624906259062690627906289062990630906319063290633906349063590636906379063890639906409064190642906439064490645906469064790648906499065090651906529065390654906559065690657906589065990660906619066290663906649066590666906679066890669906709067190672906739067490675906769067790678906799068090681906829068390684906859068690687906889068990690906919069290693906949069590696906979069890699907009070190702907039070490705907069070790708907099071090711907129071390714907159071690717907189071990720907219072290723907249072590726907279072890729907309073190732907339073490735907369073790738907399074090741907429074390744907459074690747907489074990750907519075290753907549075590756907579075890759907609076190762907639076490765907669076790768907699077090771907729077390774907759077690777907789077990780907819078290783907849078590786907879078890789907909079190792907939079490795907969079790798907999080090801908029080390804908059080690807908089080990810908119081290813908149081590816908179081890819908209082190822908239082490825908269082790828908299083090831908329083390834908359083690837908389083990840908419084290843908449084590846908479084890849908509085190852908539085490855908569085790858908599086090861908629086390864908659086690867908689086990870908719087290873908749087590876908779087890879908809088190882908839088490885908869088790888908899089090891908929089390894908959089690897908989089990900909019090290903909049090590906909079090890909909109091190912909139091490915909169091790918909199092090921909229092390924909259092690927909289092990930909319093290933909349093590936909379093890939909409094190942909439094490945909469094790948909499095090951909529095390954909559095690957909589095990960909619096290963909649096590966909679096890969909709097190972909739097490975909769097790978909799098090981909829098390984909859098690987909889098990990909919099290993909949099590996909979099890999910009100191002910039100491005910069100791008910099101091011910129101391014910159101691017910189101991020910219102291023910249102591026910279102891029910309103191032910339103491035910369103791038910399104091041910429104391044910459104691047910489104991050910519105291053910549105591056910579105891059910609106191062910639106491065910669106791068910699107091071910729107391074910759107691077910789107991080910819108291083910849108591086910879108891089910909109191092910939109491095910969109791098910999110091101911029110391104911059110691107911089110991110911119111291113911149111591116911179111891119911209112191122911239112491125911269112791128911299113091131911329113391134911359113691137911389113991140911419114291143911449114591146911479114891149911509115191152911539115491155911569115791158911599116091161911629116391164911659116691167911689116991170911719117291173911749117591176911779117891179911809118191182911839118491185911869118791188911899119091191911929119391194911959119691197911989119991200912019120291203912049120591206912079120891209912109121191212912139121491215912169121791218912199122091221912229122391224912259122691227912289122991230912319123291233912349123591236912379123891239912409124191242912439124491245912469124791248912499125091251912529125391254912559125691257912589125991260912619126291263912649126591266912679126891269912709127191272912739127491275912769127791278912799128091281912829128391284912859128691287912889128991290912919129291293912949129591296912979129891299913009130191302913039130491305913069130791308913099131091311913129131391314913159131691317913189131991320913219132291323913249132591326913279132891329913309133191332913339133491335913369133791338913399134091341913429134391344913459134691347913489134991350913519135291353913549135591356913579135891359913609136191362913639136491365913669136791368913699137091371913729137391374913759137691377913789137991380913819138291383913849138591386913879138891389913909139191392913939139491395913969139791398913999140091401914029140391404914059140691407914089140991410914119141291413914149141591416914179141891419914209142191422914239142491425914269142791428914299143091431914329143391434914359143691437914389143991440914419144291443914449144591446914479144891449914509145191452914539145491455914569145791458914599146091461914629146391464914659146691467914689146991470914719147291473914749147591476914779147891479914809148191482914839148491485914869148791488914899149091491914929149391494914959149691497914989149991500915019150291503915049150591506915079150891509915109151191512915139151491515915169151791518915199152091521915229152391524915259152691527915289152991530915319153291533915349153591536915379153891539915409154191542915439154491545915469154791548915499155091551915529155391554915559155691557915589155991560915619156291563915649156591566915679156891569915709157191572915739157491575915769157791578915799158091581915829158391584915859158691587915889158991590915919159291593915949159591596915979159891599916009160191602916039160491605916069160791608916099161091611916129161391614916159161691617916189161991620916219162291623916249162591626916279162891629916309163191632916339163491635916369163791638916399164091641916429164391644916459164691647916489164991650916519165291653916549165591656916579165891659916609166191662916639166491665916669166791668916699167091671916729167391674916759167691677916789167991680916819168291683916849168591686916879168891689916909169191692916939169491695916969169791698916999170091701917029170391704917059170691707917089170991710917119171291713917149171591716917179171891719917209172191722917239172491725917269172791728917299173091731917329173391734917359173691737917389173991740917419174291743917449174591746917479174891749917509175191752917539175491755917569175791758917599176091761917629176391764917659176691767917689176991770917719177291773917749177591776917779177891779917809178191782917839178491785917869178791788917899179091791917929179391794917959179691797917989179991800918019180291803918049180591806918079180891809918109181191812918139181491815918169181791818918199182091821918229182391824918259182691827918289182991830918319183291833918349183591836918379183891839918409184191842918439184491845918469184791848918499185091851918529185391854918559185691857918589185991860918619186291863918649186591866918679186891869918709187191872918739187491875918769187791878918799188091881918829188391884918859188691887918889188991890918919189291893918949189591896918979189891899919009190191902919039190491905919069190791908919099191091911919129191391914919159191691917919189191991920919219192291923919249192591926919279192891929919309193191932919339193491935919369193791938919399194091941919429194391944919459194691947919489194991950919519195291953919549195591956919579195891959919609196191962919639196491965919669196791968919699197091971919729197391974919759197691977919789197991980919819198291983919849198591986919879198891989919909199191992919939199491995919969199791998919999200092001920029200392004920059200692007920089200992010920119201292013920149201592016920179201892019920209202192022920239202492025920269202792028920299203092031920329203392034920359203692037920389203992040920419204292043920449204592046920479204892049920509205192052920539205492055920569205792058920599206092061920629206392064920659206692067920689206992070920719207292073920749207592076920779207892079920809208192082920839208492085920869208792088920899209092091920929209392094920959209692097920989209992100921019210292103921049210592106921079210892109921109211192112921139211492115921169211792118921199212092121921229212392124921259212692127921289212992130921319213292133921349213592136921379213892139921409214192142921439214492145921469214792148921499215092151921529215392154921559215692157921589215992160921619216292163921649216592166921679216892169921709217192172921739217492175921769217792178921799218092181921829218392184921859218692187921889218992190921919219292193921949219592196921979219892199922009220192202922039220492205922069220792208922099221092211922129221392214922159221692217922189221992220922219222292223922249222592226922279222892229922309223192232922339223492235922369223792238922399224092241922429224392244922459224692247922489224992250922519225292253922549225592256922579225892259922609226192262922639226492265922669226792268922699227092271922729227392274922759227692277922789227992280922819228292283922849228592286922879228892289922909229192292922939229492295922969229792298922999230092301923029230392304923059230692307923089230992310923119231292313923149231592316923179231892319923209232192322923239232492325923269232792328923299233092331923329233392334923359233692337923389233992340923419234292343923449234592346923479234892349923509235192352923539235492355923569235792358923599236092361923629236392364923659236692367923689236992370923719237292373923749237592376923779237892379923809238192382923839238492385923869238792388923899239092391923929239392394923959239692397923989239992400924019240292403924049240592406924079240892409924109241192412924139241492415924169241792418924199242092421924229242392424924259242692427924289242992430924319243292433924349243592436924379243892439924409244192442924439244492445924469244792448924499245092451924529245392454924559245692457924589245992460924619246292463924649246592466924679246892469924709247192472924739247492475924769247792478924799248092481924829248392484924859248692487924889248992490924919249292493924949249592496924979249892499925009250192502925039250492505925069250792508925099251092511925129251392514925159251692517925189251992520925219252292523925249252592526925279252892529925309253192532925339253492535925369253792538925399254092541925429254392544925459254692547925489254992550925519255292553925549255592556925579255892559925609256192562925639256492565925669256792568925699257092571925729257392574925759257692577925789257992580925819258292583925849258592586925879258892589925909259192592925939259492595925969259792598925999260092601926029260392604926059260692607926089260992610926119261292613926149261592616926179261892619926209262192622926239262492625926269262792628926299263092631926329263392634926359263692637926389263992640926419264292643926449264592646926479264892649926509265192652926539265492655926569265792658926599266092661926629266392664926659266692667926689266992670926719267292673926749267592676926779267892679926809268192682926839268492685926869268792688926899269092691926929269392694926959269692697926989269992700927019270292703927049270592706927079270892709927109271192712927139271492715927169271792718927199272092721927229272392724927259272692727927289272992730927319273292733927349273592736927379273892739927409274192742927439274492745927469274792748927499275092751927529275392754927559275692757927589275992760927619276292763927649276592766927679276892769927709277192772927739277492775927769277792778927799278092781927829278392784927859278692787927889278992790927919279292793927949279592796927979279892799928009280192802928039280492805928069280792808928099281092811928129281392814928159281692817928189281992820928219282292823928249282592826928279282892829928309283192832928339283492835928369283792838928399284092841928429284392844928459284692847928489284992850928519285292853928549285592856928579285892859928609286192862928639286492865928669286792868928699287092871928729287392874928759287692877928789287992880928819288292883928849288592886928879288892889928909289192892928939289492895928969289792898928999290092901929029290392904929059290692907929089290992910929119291292913929149291592916929179291892919929209292192922929239292492925929269292792928929299293092931929329293392934929359293692937929389293992940929419294292943929449294592946929479294892949929509295192952929539295492955929569295792958929599296092961929629296392964929659296692967929689296992970929719297292973929749297592976929779297892979929809298192982929839298492985929869298792988929899299092991929929299392994929959299692997929989299993000930019300293003930049300593006930079300893009930109301193012930139301493015930169301793018930199302093021930229302393024930259302693027930289302993030930319303293033930349303593036930379303893039930409304193042930439304493045930469304793048930499305093051930529305393054930559305693057930589305993060930619306293063930649306593066930679306893069930709307193072930739307493075930769307793078930799308093081930829308393084930859308693087930889308993090930919309293093930949309593096930979309893099931009310193102931039310493105931069310793108931099311093111931129311393114931159311693117931189311993120931219312293123931249312593126931279312893129931309313193132931339313493135931369313793138931399314093141931429314393144931459314693147931489314993150931519315293153931549315593156931579315893159931609316193162931639316493165931669316793168931699317093171931729317393174931759317693177931789317993180931819318293183931849318593186931879318893189931909319193192931939319493195931969319793198931999320093201932029320393204932059320693207932089320993210932119321293213932149321593216932179321893219932209322193222932239322493225932269322793228932299323093231932329323393234932359323693237932389323993240932419324293243932449324593246932479324893249932509325193252932539325493255932569325793258932599326093261932629326393264932659326693267932689326993270932719327293273932749327593276932779327893279932809328193282932839328493285932869328793288932899329093291932929329393294932959329693297932989329993300933019330293303933049330593306933079330893309933109331193312933139331493315933169331793318933199332093321933229332393324933259332693327933289332993330933319333293333933349333593336933379333893339933409334193342933439334493345933469334793348933499335093351933529335393354933559335693357933589335993360933619336293363933649336593366933679336893369933709337193372933739337493375933769337793378933799338093381933829338393384933859338693387933889338993390933919339293393933949339593396933979339893399934009340193402934039340493405934069340793408934099341093411934129341393414934159341693417934189341993420934219342293423934249342593426934279342893429934309343193432934339343493435934369343793438934399344093441934429344393444934459344693447934489344993450934519345293453934549345593456934579345893459934609346193462934639346493465934669346793468934699347093471934729347393474934759347693477934789347993480934819348293483934849348593486934879348893489934909349193492934939349493495934969349793498934999350093501935029350393504935059350693507935089350993510935119351293513935149351593516935179351893519935209352193522935239352493525935269352793528935299353093531935329353393534935359353693537935389353993540935419354293543935449354593546935479354893549935509355193552935539355493555935569355793558935599356093561935629356393564935659356693567935689356993570935719357293573935749357593576935779357893579935809358193582935839358493585935869358793588935899359093591935929359393594935959359693597935989359993600936019360293603936049360593606936079360893609936109361193612936139361493615936169361793618936199362093621936229362393624936259362693627936289362993630936319363293633936349363593636936379363893639936409364193642936439364493645936469364793648936499365093651936529365393654936559365693657936589365993660936619366293663936649366593666936679366893669936709367193672936739367493675936769367793678936799368093681936829368393684936859368693687936889368993690936919369293693936949369593696936979369893699937009370193702937039370493705937069370793708937099371093711937129371393714937159371693717937189371993720937219372293723937249372593726937279372893729937309373193732937339373493735937369373793738937399374093741937429374393744937459374693747937489374993750937519375293753937549375593756937579375893759937609376193762937639376493765937669376793768937699377093771937729377393774937759377693777937789377993780937819378293783937849378593786937879378893789937909379193792937939379493795937969379793798937999380093801938029380393804938059380693807938089380993810938119381293813938149381593816938179381893819938209382193822938239382493825938269382793828938299383093831938329383393834938359383693837938389383993840938419384293843938449384593846938479384893849938509385193852938539385493855938569385793858938599386093861938629386393864938659386693867938689386993870938719387293873938749387593876938779387893879938809388193882938839388493885938869388793888938899389093891938929389393894938959389693897938989389993900939019390293903939049390593906939079390893909939109391193912939139391493915939169391793918939199392093921939229392393924939259392693927939289392993930939319393293933939349393593936939379393893939939409394193942939439394493945939469394793948939499395093951939529395393954939559395693957939589395993960939619396293963939649396593966939679396893969939709397193972939739397493975939769397793978939799398093981939829398393984939859398693987939889398993990939919399293993939949399593996939979399893999940009400194002940039400494005940069400794008940099401094011940129401394014940159401694017940189401994020940219402294023940249402594026940279402894029940309403194032940339403494035940369403794038940399404094041940429404394044940459404694047940489404994050940519405294053940549405594056940579405894059940609406194062940639406494065940669406794068940699407094071940729407394074940759407694077940789407994080940819408294083940849408594086940879408894089940909409194092940939409494095940969409794098940999410094101941029410394104941059410694107941089410994110941119411294113941149411594116941179411894119941209412194122941239412494125941269412794128941299413094131941329413394134941359413694137941389413994140941419414294143941449414594146941479414894149941509415194152941539415494155941569415794158941599416094161941629416394164941659416694167941689416994170941719417294173941749417594176941779417894179941809418194182941839418494185941869418794188941899419094191941929419394194941959419694197941989419994200942019420294203942049420594206942079420894209942109421194212942139421494215942169421794218942199422094221942229422394224942259422694227942289422994230942319423294233942349423594236942379423894239942409424194242942439424494245942469424794248942499425094251942529425394254942559425694257942589425994260942619426294263942649426594266942679426894269942709427194272942739427494275942769427794278942799428094281942829428394284942859428694287942889428994290942919429294293942949429594296942979429894299943009430194302943039430494305943069430794308943099431094311943129431394314943159431694317943189431994320943219432294323943249432594326943279432894329943309433194332943339433494335943369433794338943399434094341943429434394344943459434694347943489434994350943519435294353943549435594356943579435894359943609436194362943639436494365943669436794368943699437094371943729437394374943759437694377943789437994380943819438294383943849438594386943879438894389943909439194392943939439494395943969439794398943999440094401944029440394404944059440694407944089440994410944119441294413944149441594416944179441894419944209442194422944239442494425944269442794428944299443094431944329443394434944359443694437944389443994440944419444294443944449444594446944479444894449944509445194452944539445494455944569445794458944599446094461944629446394464944659446694467944689446994470944719447294473944749447594476944779447894479944809448194482944839448494485944869448794488944899449094491944929449394494944959449694497944989449994500945019450294503945049450594506945079450894509945109451194512945139451494515945169451794518945199452094521945229452394524945259452694527945289452994530945319453294533945349453594536945379453894539945409454194542945439454494545945469454794548945499455094551945529455394554945559455694557945589455994560945619456294563945649456594566945679456894569945709457194572945739457494575945769457794578945799458094581945829458394584945859458694587945889458994590945919459294593945949459594596945979459894599946009460194602946039460494605946069460794608946099461094611946129461394614946159461694617946189461994620946219462294623946249462594626946279462894629946309463194632946339463494635946369463794638946399464094641946429464394644946459464694647946489464994650946519465294653946549465594656946579465894659946609466194662946639466494665946669466794668946699467094671946729467394674946759467694677946789467994680946819468294683946849468594686946879468894689946909469194692946939469494695946969469794698946999470094701947029470394704947059470694707947089470994710947119471294713947149471594716947179471894719947209472194722947239472494725947269472794728947299473094731947329473394734947359473694737947389473994740947419474294743947449474594746947479474894749947509475194752947539475494755947569475794758947599476094761947629476394764947659476694767947689476994770947719477294773947749477594776947779477894779947809478194782947839478494785947869478794788947899479094791947929479394794947959479694797947989479994800948019480294803948049480594806948079480894809948109481194812948139481494815948169481794818948199482094821948229482394824948259482694827948289482994830948319483294833948349483594836948379483894839948409484194842948439484494845948469484794848948499485094851948529485394854948559485694857948589485994860948619486294863948649486594866948679486894869948709487194872948739487494875948769487794878948799488094881948829488394884948859488694887948889488994890948919489294893948949489594896948979489894899949009490194902949039490494905949069490794908949099491094911949129491394914949159491694917949189491994920949219492294923949249492594926949279492894929949309493194932949339493494935949369493794938949399494094941949429494394944949459494694947949489494994950949519495294953949549495594956949579495894959949609496194962949639496494965949669496794968949699497094971949729497394974949759497694977949789497994980949819498294983949849498594986949879498894989949909499194992949939499494995949969499794998949999500095001950029500395004950059500695007950089500995010950119501295013950149501595016950179501895019950209502195022950239502495025950269502795028950299503095031950329503395034950359503695037950389503995040950419504295043950449504595046950479504895049950509505195052950539505495055950569505795058950599506095061950629506395064950659506695067950689506995070950719507295073950749507595076950779507895079950809508195082950839508495085950869508795088950899509095091950929509395094950959509695097950989509995100951019510295103951049510595106951079510895109951109511195112951139511495115951169511795118951199512095121951229512395124951259512695127951289512995130951319513295133951349513595136951379513895139951409514195142951439514495145951469514795148951499515095151951529515395154951559515695157951589515995160951619516295163951649516595166951679516895169951709517195172951739517495175951769517795178951799518095181951829518395184951859518695187951889518995190951919519295193951949519595196951979519895199952009520195202952039520495205952069520795208952099521095211952129521395214952159521695217952189521995220952219522295223952249522595226952279522895229952309523195232952339523495235952369523795238952399524095241952429524395244952459524695247952489524995250952519525295253952549525595256952579525895259952609526195262952639526495265952669526795268952699527095271952729527395274952759527695277952789527995280952819528295283952849528595286952879528895289952909529195292952939529495295952969529795298952999530095301953029530395304953059530695307953089530995310953119531295313953149531595316953179531895319953209532195322953239532495325953269532795328953299533095331953329533395334953359533695337953389533995340953419534295343953449534595346953479534895349953509535195352953539535495355953569535795358953599536095361953629536395364953659536695367953689536995370953719537295373953749537595376953779537895379953809538195382953839538495385953869538795388953899539095391953929539395394953959539695397953989539995400954019540295403954049540595406954079540895409954109541195412954139541495415954169541795418954199542095421954229542395424954259542695427954289542995430954319543295433954349543595436954379543895439954409544195442954439544495445954469544795448954499545095451954529545395454954559545695457954589545995460954619546295463954649546595466954679546895469954709547195472954739547495475954769547795478954799548095481954829548395484954859548695487954889548995490954919549295493954949549595496954979549895499955009550195502955039550495505955069550795508955099551095511955129551395514955159551695517955189551995520955219552295523955249552595526955279552895529955309553195532955339553495535955369553795538955399554095541955429554395544955459554695547955489554995550955519555295553955549555595556955579555895559955609556195562955639556495565955669556795568955699557095571955729557395574955759557695577955789557995580955819558295583955849558595586955879558895589955909559195592955939559495595955969559795598955999560095601956029560395604956059560695607956089560995610956119561295613956149561595616956179561895619956209562195622956239562495625956269562795628956299563095631956329563395634956359563695637956389563995640956419564295643956449564595646956479564895649956509565195652956539565495655956569565795658956599566095661956629566395664956659566695667956689566995670956719567295673956749567595676956779567895679956809568195682956839568495685956869568795688956899569095691956929569395694956959569695697956989569995700957019570295703957049570595706957079570895709957109571195712957139571495715957169571795718957199572095721957229572395724957259572695727957289572995730957319573295733957349573595736957379573895739957409574195742957439574495745957469574795748957499575095751957529575395754957559575695757957589575995760957619576295763957649576595766957679576895769957709577195772957739577495775957769577795778957799578095781957829578395784957859578695787957889578995790957919579295793957949579595796957979579895799958009580195802958039580495805958069580795808958099581095811958129581395814958159581695817958189581995820958219582295823958249582595826958279582895829958309583195832958339583495835958369583795838958399584095841958429584395844958459584695847958489584995850958519585295853958549585595856958579585895859958609586195862958639586495865958669586795868958699587095871958729587395874958759587695877958789587995880958819588295883958849588595886958879588895889958909589195892958939589495895958969589795898958999590095901959029590395904959059590695907959089590995910959119591295913959149591595916959179591895919959209592195922959239592495925959269592795928959299593095931959329593395934959359593695937959389593995940959419594295943959449594595946959479594895949959509595195952959539595495955959569595795958959599596095961959629596395964959659596695967959689596995970959719597295973959749597595976959779597895979959809598195982959839598495985959869598795988959899599095991959929599395994959959599695997959989599996000960019600296003960049600596006960079600896009960109601196012960139601496015960169601796018960199602096021960229602396024960259602696027960289602996030960319603296033960349603596036960379603896039960409604196042960439604496045960469604796048960499605096051960529605396054960559605696057960589605996060960619606296063960649606596066960679606896069960709607196072960739607496075960769607796078960799608096081960829608396084960859608696087960889608996090960919609296093960949609596096960979609896099961009610196102961039610496105961069610796108961099611096111961129611396114961159611696117961189611996120961219612296123961249612596126961279612896129961309613196132961339613496135961369613796138961399614096141961429614396144961459614696147961489614996150961519615296153961549615596156961579615896159961609616196162961639616496165961669616796168961699617096171961729617396174961759617696177961789617996180961819618296183961849618596186961879618896189961909619196192961939619496195961969619796198961999620096201962029620396204962059620696207962089620996210962119621296213962149621596216962179621896219962209622196222962239622496225962269622796228962299623096231962329623396234962359623696237962389623996240962419624296243962449624596246962479624896249962509625196252962539625496255962569625796258962599626096261962629626396264962659626696267962689626996270962719627296273962749627596276962779627896279962809628196282962839628496285962869628796288962899629096291962929629396294962959629696297962989629996300963019630296303963049630596306963079630896309963109631196312963139631496315963169631796318963199632096321963229632396324963259632696327963289632996330963319633296333963349633596336963379633896339963409634196342963439634496345963469634796348963499635096351963529635396354963559635696357963589635996360963619636296363963649636596366963679636896369963709637196372963739637496375963769637796378963799638096381963829638396384963859638696387963889638996390963919639296393963949639596396963979639896399964009640196402964039640496405964069640796408964099641096411964129641396414964159641696417964189641996420964219642296423964249642596426964279642896429964309643196432964339643496435964369643796438964399644096441964429644396444964459644696447964489644996450964519645296453964549645596456964579645896459964609646196462964639646496465964669646796468964699647096471964729647396474964759647696477964789647996480964819648296483964849648596486964879648896489964909649196492964939649496495964969649796498964999650096501965029650396504965059650696507965089650996510965119651296513965149651596516965179651896519965209652196522965239652496525965269652796528965299653096531965329653396534965359653696537965389653996540965419654296543965449654596546965479654896549965509655196552965539655496555965569655796558965599656096561965629656396564965659656696567965689656996570965719657296573965749657596576965779657896579965809658196582965839658496585965869658796588965899659096591965929659396594965959659696597965989659996600966019660296603966049660596606966079660896609966109661196612966139661496615966169661796618966199662096621966229662396624966259662696627966289662996630966319663296633966349663596636966379663896639966409664196642966439664496645966469664796648966499665096651966529665396654966559665696657966589665996660966619666296663966649666596666966679666896669966709667196672966739667496675966769667796678966799668096681966829668396684966859668696687966889668996690966919669296693966949669596696966979669896699967009670196702967039670496705967069670796708967099671096711967129671396714967159671696717967189671996720967219672296723967249672596726967279672896729967309673196732967339673496735967369673796738967399674096741967429674396744967459674696747967489674996750967519675296753967549675596756967579675896759967609676196762967639676496765967669676796768967699677096771967729677396774967759677696777967789677996780967819678296783967849678596786967879678896789967909679196792967939679496795967969679796798967999680096801968029680396804968059680696807968089680996810968119681296813968149681596816968179681896819968209682196822968239682496825968269682796828968299683096831968329683396834968359683696837968389683996840968419684296843968449684596846968479684896849968509685196852968539685496855968569685796858968599686096861968629686396864968659686696867968689686996870968719687296873968749687596876968779687896879968809688196882968839688496885968869688796888968899689096891968929689396894968959689696897968989689996900969019690296903969049690596906969079690896909969109691196912969139691496915969169691796918969199692096921969229692396924969259692696927969289692996930969319693296933969349693596936969379693896939969409694196942969439694496945969469694796948969499695096951969529695396954969559695696957969589695996960969619696296963969649696596966969679696896969969709697196972969739697496975969769697796978969799698096981969829698396984969859698696987969889698996990969919699296993969949699596996969979699896999970009700197002970039700497005970069700797008970099701097011970129701397014970159701697017970189701997020970219702297023970249702597026970279702897029970309703197032970339703497035970369703797038970399704097041970429704397044970459704697047970489704997050970519705297053970549705597056970579705897059970609706197062970639706497065970669706797068970699707097071970729707397074970759707697077970789707997080970819708297083970849708597086970879708897089970909709197092970939709497095970969709797098970999710097101971029710397104971059710697107971089710997110971119711297113971149711597116971179711897119971209712197122971239712497125971269712797128971299713097131971329713397134971359713697137971389713997140971419714297143971449714597146971479714897149971509715197152971539715497155971569715797158971599716097161971629716397164971659716697167971689716997170971719717297173971749717597176971779717897179971809718197182971839718497185971869718797188971899719097191971929719397194971959719697197971989719997200972019720297203972049720597206972079720897209972109721197212972139721497215972169721797218972199722097221972229722397224972259722697227972289722997230972319723297233972349723597236972379723897239972409724197242972439724497245972469724797248972499725097251972529725397254972559725697257972589725997260972619726297263972649726597266972679726897269972709727197272972739727497275972769727797278972799728097281972829728397284972859728697287972889728997290972919729297293972949729597296972979729897299973009730197302973039730497305973069730797308973099731097311973129731397314973159731697317973189731997320973219732297323973249732597326973279732897329973309733197332973339733497335973369733797338973399734097341973429734397344973459734697347973489734997350973519735297353973549735597356973579735897359973609736197362973639736497365973669736797368973699737097371973729737397374973759737697377973789737997380973819738297383973849738597386973879738897389973909739197392973939739497395973969739797398973999740097401974029740397404974059740697407974089740997410974119741297413974149741597416974179741897419974209742197422974239742497425974269742797428974299743097431974329743397434974359743697437974389743997440974419744297443974449744597446974479744897449974509745197452974539745497455974569745797458974599746097461974629746397464974659746697467974689746997470974719747297473974749747597476974779747897479974809748197482974839748497485974869748797488974899749097491974929749397494974959749697497974989749997500975019750297503975049750597506975079750897509975109751197512975139751497515975169751797518975199752097521975229752397524975259752697527975289752997530975319753297533975349753597536975379753897539975409754197542975439754497545975469754797548975499755097551975529755397554975559755697557975589755997560975619756297563975649756597566975679756897569975709757197572975739757497575975769757797578975799758097581975829758397584975859758697587975889758997590975919759297593975949759597596975979759897599976009760197602976039760497605976069760797608976099761097611976129761397614976159761697617976189761997620976219762297623976249762597626976279762897629976309763197632976339763497635976369763797638976399764097641976429764397644976459764697647976489764997650976519765297653976549765597656976579765897659976609766197662976639766497665976669766797668976699767097671976729767397674976759767697677976789767997680976819768297683976849768597686976879768897689976909769197692976939769497695976969769797698976999770097701977029770397704977059770697707977089770997710977119771297713977149771597716977179771897719977209772197722977239772497725977269772797728977299773097731977329773397734977359773697737977389773997740977419774297743977449774597746977479774897749977509775197752977539775497755977569775797758977599776097761977629776397764977659776697767977689776997770977719777297773977749777597776977779777897779977809778197782977839778497785977869778797788977899779097791977929779397794977959779697797977989779997800978019780297803978049780597806978079780897809978109781197812978139781497815978169781797818978199782097821978229782397824978259782697827978289782997830978319783297833978349783597836978379783897839978409784197842978439784497845978469784797848978499785097851978529785397854978559785697857978589785997860978619786297863978649786597866978679786897869978709787197872978739787497875978769787797878978799788097881978829788397884978859788697887978889788997890978919789297893978949789597896978979789897899979009790197902979039790497905979069790797908979099791097911979129791397914979159791697917979189791997920979219792297923979249792597926979279792897929979309793197932979339793497935979369793797938979399794097941979429794397944979459794697947979489794997950979519795297953979549795597956979579795897959979609796197962979639796497965979669796797968979699797097971979729797397974979759797697977979789797997980979819798297983979849798597986979879798897989979909799197992979939799497995979969799797998979999800098001980029800398004980059800698007980089800998010980119801298013980149801598016980179801898019980209802198022980239802498025980269802798028980299803098031980329803398034980359803698037980389803998040980419804298043980449804598046980479804898049980509805198052980539805498055980569805798058980599806098061980629806398064980659806698067980689806998070980719807298073980749807598076980779807898079980809808198082980839808498085980869808798088980899809098091980929809398094980959809698097980989809998100981019810298103981049810598106981079810898109981109811198112981139811498115981169811798118981199812098121981229812398124981259812698127981289812998130981319813298133981349813598136981379813898139981409814198142981439814498145981469814798148981499815098151981529815398154981559815698157981589815998160981619816298163981649816598166981679816898169981709817198172981739817498175981769817798178981799818098181981829818398184981859818698187981889818998190981919819298193981949819598196981979819898199982009820198202982039820498205982069820798208982099821098211982129821398214982159821698217982189821998220982219822298223982249822598226982279822898229982309823198232982339823498235982369823798238982399824098241982429824398244982459824698247982489824998250982519825298253982549825598256982579825898259982609826198262982639826498265982669826798268982699827098271982729827398274982759827698277982789827998280982819828298283982849828598286982879828898289982909829198292982939829498295982969829798298982999830098301983029830398304983059830698307983089830998310983119831298313983149831598316983179831898319983209832198322983239832498325983269832798328983299833098331983329833398334983359833698337983389833998340983419834298343983449834598346983479834898349983509835198352983539835498355983569835798358983599836098361983629836398364983659836698367983689836998370983719837298373983749837598376983779837898379983809838198382983839838498385983869838798388983899839098391983929839398394983959839698397983989839998400984019840298403984049840598406984079840898409984109841198412984139841498415984169841798418984199842098421984229842398424984259842698427984289842998430984319843298433984349843598436984379843898439984409844198442984439844498445984469844798448984499845098451984529845398454984559845698457984589845998460984619846298463984649846598466984679846898469984709847198472984739847498475984769847798478984799848098481984829848398484984859848698487984889848998490984919849298493984949849598496984979849898499985009850198502985039850498505985069850798508985099851098511985129851398514985159851698517985189851998520985219852298523985249852598526985279852898529985309853198532985339853498535985369853798538985399854098541985429854398544985459854698547985489854998550985519855298553985549855598556985579855898559985609856198562985639856498565985669856798568985699857098571985729857398574985759857698577985789857998580985819858298583985849858598586985879858898589985909859198592985939859498595985969859798598985999860098601986029860398604986059860698607986089860998610986119861298613986149861598616986179861898619986209862198622986239862498625986269862798628986299863098631986329863398634986359863698637986389863998640986419864298643986449864598646986479864898649986509865198652986539865498655986569865798658986599866098661986629866398664986659866698667986689866998670986719867298673986749867598676986779867898679986809868198682986839868498685986869868798688986899869098691986929869398694986959869698697986989869998700987019870298703987049870598706987079870898709987109871198712987139871498715987169871798718987199872098721987229872398724987259872698727987289872998730987319873298733987349873598736987379873898739987409874198742987439874498745987469874798748987499875098751987529875398754987559875698757987589875998760987619876298763987649876598766987679876898769987709877198772987739877498775987769877798778987799878098781987829878398784987859878698787987889878998790987919879298793987949879598796987979879898799988009880198802988039880498805988069880798808988099881098811988129881398814988159881698817988189881998820988219882298823988249882598826988279882898829988309883198832988339883498835988369883798838988399884098841988429884398844988459884698847988489884998850988519885298853988549885598856988579885898859988609886198862988639886498865988669886798868988699887098871988729887398874988759887698877988789887998880988819888298883988849888598886988879888898889988909889198892988939889498895988969889798898988999890098901989029890398904989059890698907989089890998910989119891298913989149891598916989179891898919989209892198922989239892498925989269892798928989299893098931989329893398934989359893698937989389893998940989419894298943989449894598946989479894898949989509895198952989539895498955989569895798958989599896098961989629896398964989659896698967989689896998970989719897298973989749897598976989779897898979989809898198982989839898498985989869898798988989899899098991989929899398994989959899698997989989899999000990019900299003990049900599006990079900899009990109901199012990139901499015990169901799018990199902099021990229902399024990259902699027990289902999030990319903299033990349903599036990379903899039990409904199042990439904499045990469904799048990499905099051990529905399054990559905699057990589905999060990619906299063990649906599066990679906899069990709907199072990739907499075990769907799078990799908099081990829908399084990859908699087990889908999090990919909299093990949909599096990979909899099991009910199102991039910499105991069910799108991099911099111991129911399114991159911699117991189911999120991219912299123991249912599126991279912899129991309913199132991339913499135991369913799138991399914099141991429914399144991459914699147991489914999150991519915299153991549915599156991579915899159991609916199162991639916499165991669916799168991699917099171991729917399174991759917699177991789917999180991819918299183991849918599186991879918899189991909919199192991939919499195991969919799198991999920099201992029920399204992059920699207992089920999210992119921299213992149921599216992179921899219992209922199222992239922499225992269922799228992299923099231992329923399234992359923699237992389923999240992419924299243992449924599246992479924899249992509925199252992539925499255992569925799258992599926099261992629926399264992659926699267992689926999270992719927299273992749927599276992779927899279992809928199282992839928499285992869928799288992899929099291992929929399294992959929699297992989929999300993019930299303993049930599306993079930899309993109931199312993139931499315993169931799318993199932099321993229932399324993259932699327993289932999330993319933299333993349933599336993379933899339993409934199342993439934499345993469934799348993499935099351993529935399354993559935699357993589935999360993619936299363993649936599366993679936899369993709937199372993739937499375993769937799378993799938099381993829938399384993859938699387993889938999390993919939299393993949939599396993979939899399994009940199402994039940499405994069940799408994099941099411994129941399414994159941699417994189941999420994219942299423994249942599426994279942899429994309943199432994339943499435994369943799438994399944099441994429944399444994459944699447994489944999450994519945299453994549945599456994579945899459994609946199462994639946499465994669946799468994699947099471994729947399474994759947699477994789947999480994819948299483994849948599486994879948899489994909949199492994939949499495994969949799498994999950099501995029950399504995059950699507995089950999510995119951299513995149951599516995179951899519995209952199522995239952499525995269952799528995299953099531995329953399534995359953699537995389953999540995419954299543995449954599546995479954899549995509955199552995539955499555995569955799558995599956099561995629956399564995659956699567995689956999570995719957299573995749957599576995779957899579995809958199582995839958499585995869958799588995899959099591995929959399594995959959699597995989959999600996019960299603996049960599606996079960899609996109961199612996139961499615996169961799618996199962099621996229962399624996259962699627996289962999630996319963299633996349963599636996379963899639996409964199642996439964499645996469964799648996499965099651996529965399654996559965699657996589965999660996619966299663996649966599666996679966899669996709967199672996739967499675996769967799678996799968099681996829968399684996859968699687996889968999690996919969299693996949969599696996979969899699997009970199702997039970499705997069970799708997099971099711997129971399714997159971699717997189971999720997219972299723997249972599726997279972899729997309973199732997339973499735997369973799738997399974099741997429974399744997459974699747997489974999750997519975299753997549975599756997579975899759997609976199762997639976499765997669976799768997699977099771997729977399774997759977699777997789977999780997819978299783997849978599786997879978899789997909979199792997939979499795997969979799798997999980099801998029980399804998059980699807998089980999810998119981299813998149981599816998179981899819998209982199822998239982499825998269982799828998299983099831998329983399834998359983699837998389983999840998419984299843998449984599846998479984899849998509985199852998539985499855998569985799858998599986099861998629986399864998659986699867998689986999870998719987299873998749987599876998779987899879998809988199882998839988499885998869988799888998899989099891998929989399894998959989699897998989989999900999019990299903999049990599906999079990899909999109991199912999139991499915999169991799918999199992099921999229992399924999259992699927999289992999930999319993299933999349993599936999379993899939999409994199942999439994499945999469994799948999499995099951999529995399954999559995699957999589995999960999619996299963999649996599966999679996899969999709997199972999739997499975999769997799978999799998099981999829998399984999859998699987999889998999990999919999299993999949999599996999979999899999100000100001100002100003100004100005100006100007100008100009100010100011100012100013100014100015100016100017100018100019100020100021100022100023100024100025100026100027100028100029100030100031100032100033100034100035100036100037100038100039100040100041100042100043100044100045100046100047100048100049100050100051100052100053100054100055100056100057100058100059100060100061100062100063100064100065100066100067100068100069100070100071100072100073100074100075100076100077100078100079100080100081100082100083100084100085100086100087100088100089100090100091100092100093100094100095100096100097100098100099100100100101100102100103100104100105100106100107100108100109100110100111100112100113100114100115100116100117100118100119100120100121100122100123100124100125100126100127100128100129100130100131100132100133100134100135100136100137100138100139100140100141100142100143100144100145100146100147100148100149100150100151100152100153100154100155100156100157100158100159100160100161100162100163100164100165100166100167100168100169100170100171100172100173100174100175100176100177100178100179100180100181100182100183100184100185100186100187100188100189100190100191100192100193100194100195100196100197100198100199100200100201100202100203100204100205100206100207100208100209100210100211100212100213100214100215100216100217100218100219100220100221100222100223100224100225100226100227100228100229100230100231100232100233100234100235100236100237100238100239100240100241100242100243100244100245100246100247100248100249100250100251100252100253100254100255100256100257100258100259100260100261100262100263100264100265100266100267100268100269100270100271100272100273100274100275100276100277100278100279100280100281100282100283100284100285100286100287100288100289100290100291100292100293100294100295100296100297100298100299100300100301100302100303100304100305100306100307100308100309100310100311100312100313100314100315100316100317100318100319100320100321100322100323100324100325100326100327100328100329100330100331100332100333100334100335100336100337100338100339100340100341100342100343100344100345100346100347100348100349100350100351100352100353100354100355100356100357100358100359100360100361100362100363100364100365100366100367100368100369100370100371100372100373100374100375100376100377100378100379100380100381100382100383100384100385100386100387100388100389100390100391100392100393100394100395100396100397100398100399100400100401100402100403100404100405100406100407100408100409100410100411100412100413100414100415100416100417100418100419100420100421100422100423100424100425100426100427100428100429100430100431100432100433100434100435100436100437100438100439100440100441100442100443100444100445100446100447100448100449100450100451100452100453100454100455100456100457100458100459100460100461100462100463100464100465100466100467100468100469100470100471100472100473100474100475100476100477100478100479100480100481100482100483100484100485100486100487100488100489100490100491100492100493100494100495100496100497100498100499100500100501100502100503100504100505100506100507100508100509100510100511100512100513100514100515100516100517100518100519100520100521100522100523100524100525100526100527100528100529100530100531100532100533100534100535100536100537100538100539100540100541100542100543100544100545100546100547100548100549100550100551100552100553100554100555100556100557100558100559100560100561100562100563100564100565100566100567100568100569100570100571100572100573100574100575100576100577100578100579100580100581100582100583100584100585100586100587100588100589100590100591100592100593100594100595100596100597100598100599100600100601100602100603100604100605100606100607100608100609100610100611100612100613100614100615100616100617100618100619100620100621100622100623100624100625100626100627100628100629100630100631100632100633100634100635100636100637100638100639100640100641100642100643100644100645100646100647100648100649100650100651100652100653100654100655100656100657100658100659100660100661100662100663100664100665100666100667100668100669100670100671100672100673100674100675100676100677100678100679100680100681100682100683100684100685100686100687100688100689100690100691100692100693100694100695100696100697100698100699100700100701100702100703100704100705100706100707100708100709100710100711100712100713100714100715100716100717100718100719100720100721100722100723100724100725100726100727100728100729100730100731100732100733100734100735100736100737100738100739100740100741100742100743100744100745100746100747100748100749100750100751100752100753100754100755100756100757100758100759100760100761100762100763100764100765100766100767100768100769100770100771100772100773100774100775100776100777100778100779100780100781100782100783100784100785100786100787100788100789100790100791100792100793100794100795100796100797100798100799100800100801100802100803100804100805100806100807100808100809100810100811100812100813100814100815100816100817100818100819100820100821100822100823100824100825100826100827100828100829100830100831100832100833100834100835100836100837100838100839100840100841100842100843100844100845100846100847100848100849100850100851100852100853100854100855100856100857100858100859100860100861100862100863100864100865100866100867100868100869100870100871100872100873100874100875100876100877100878100879100880100881100882100883100884100885100886100887100888100889100890100891100892100893100894100895100896100897100898100899100900100901100902100903100904100905100906100907100908100909100910100911100912100913100914100915100916100917100918100919100920100921100922100923100924100925100926100927100928100929100930100931100932100933100934100935100936100937100938100939100940100941100942100943100944100945100946100947100948100949100950100951100952100953100954100955100956100957100958100959100960100961100962100963100964100965100966100967100968100969100970100971100972100973100974100975100976100977100978100979100980100981100982100983100984100985100986100987100988100989100990100991100992100993100994100995100996100997100998100999101000101001101002101003101004101005101006101007101008101009101010101011101012101013101014101015101016101017101018101019101020101021101022101023101024101025101026101027101028101029101030101031101032101033101034101035101036101037101038101039101040101041101042101043101044101045101046101047101048101049101050101051101052101053101054101055101056101057101058101059101060101061101062101063101064101065101066101067101068101069101070101071101072101073101074101075101076101077101078101079101080101081101082101083101084101085101086101087101088101089101090101091101092101093101094101095101096101097101098101099101100101101101102101103101104101105101106101107101108101109101110101111101112101113101114101115101116101117101118101119101120101121101122101123101124101125101126101127101128101129101130101131101132101133101134101135101136101137101138101139101140101141101142101143101144101145101146101147101148101149101150101151101152101153101154101155101156101157101158101159101160101161101162101163101164101165101166101167101168101169101170101171101172101173101174101175101176101177101178101179101180101181101182101183101184101185101186101187101188101189101190101191101192101193101194101195101196101197101198101199101200101201101202101203101204101205101206101207101208101209101210101211101212101213101214101215101216101217101218101219101220101221101222101223101224101225101226101227101228101229101230101231101232101233101234101235101236101237101238101239101240101241101242101243101244101245101246101247101248101249101250101251101252101253101254101255101256101257101258101259101260101261101262101263101264101265101266101267101268101269101270101271101272101273101274101275101276101277101278101279101280101281101282101283101284101285101286101287101288101289101290101291101292101293101294101295101296101297101298101299101300101301101302101303101304101305101306101307101308101309101310101311101312101313101314101315101316101317101318101319101320101321101322101323101324101325101326101327101328101329101330101331101332101333101334101335101336101337101338101339101340101341101342101343101344101345101346101347101348101349101350101351101352101353101354101355101356101357101358101359101360101361101362101363101364101365101366101367101368101369101370101371101372101373101374101375101376101377101378101379101380101381101382101383101384101385101386101387101388101389101390101391101392101393101394101395101396101397101398101399101400101401101402101403101404101405101406101407101408101409101410101411101412101413101414101415101416101417101418101419101420101421101422101423101424101425101426101427101428101429101430101431101432101433101434101435101436101437101438101439101440101441101442101443101444101445101446101447101448101449101450101451101452101453101454101455101456101457101458101459101460101461101462101463101464101465101466101467101468101469101470101471101472101473101474101475101476101477101478101479101480101481101482101483101484101485101486101487101488101489101490101491101492101493101494101495101496101497101498101499101500101501101502101503101504101505101506101507101508101509101510101511101512101513101514101515101516101517101518101519101520101521101522101523101524101525101526101527101528101529101530101531101532101533101534101535101536101537101538101539101540101541101542101543101544101545101546101547101548101549101550101551101552101553101554101555101556101557101558101559101560101561101562101563101564101565101566101567101568101569101570101571101572101573101574101575101576101577101578101579101580101581101582101583101584101585101586101587101588101589101590101591101592101593101594101595101596101597101598101599101600101601101602101603101604101605101606101607101608101609101610101611101612101613101614101615101616101617101618101619101620101621101622101623101624101625101626101627101628101629101630101631101632101633101634101635101636101637101638101639101640101641101642101643101644101645101646101647101648101649101650101651101652101653101654101655101656101657101658101659101660101661101662101663101664101665101666101667101668101669101670101671101672101673101674101675101676101677101678101679101680101681101682101683101684101685101686101687101688101689101690101691101692101693101694101695101696101697101698101699101700101701101702101703101704101705101706101707101708101709101710101711101712101713101714101715101716101717101718101719101720101721101722101723101724101725101726101727101728101729101730101731101732101733101734101735101736101737101738101739101740101741101742101743101744101745101746101747101748101749101750101751101752101753101754101755101756101757101758101759101760101761101762101763101764101765101766101767101768101769101770101771101772101773101774101775101776101777101778101779101780101781101782101783101784101785101786101787101788101789101790101791101792101793101794101795101796101797101798101799101800101801101802101803101804101805101806101807101808101809101810101811101812101813101814101815101816101817101818101819101820101821101822101823101824101825101826101827101828101829101830101831101832101833101834101835101836101837101838101839101840101841101842101843101844101845101846101847101848101849101850101851101852101853101854101855101856101857101858101859101860101861101862101863101864101865101866101867101868101869101870101871101872101873101874101875101876101877101878101879101880101881101882101883101884101885101886101887101888101889101890101891101892101893101894101895101896101897101898101899101900101901101902101903101904101905101906101907101908101909101910101911101912101913101914101915101916101917101918101919101920101921101922101923101924101925101926101927101928101929101930101931101932101933101934101935101936101937101938101939101940101941101942101943101944101945101946101947101948101949101950101951101952101953101954101955101956101957101958101959101960101961101962101963101964101965101966101967101968101969101970101971101972101973101974101975101976101977101978101979101980101981101982101983101984101985101986101987101988101989101990101991101992101993101994101995101996101997101998101999102000102001102002102003102004102005102006102007102008102009102010102011102012102013102014102015102016102017102018102019102020102021102022102023102024102025102026102027102028102029102030102031102032102033102034102035102036102037102038102039102040102041102042102043102044102045102046102047102048102049102050102051102052102053102054102055102056102057102058102059102060102061102062102063102064102065102066102067102068102069102070102071102072102073102074102075102076102077102078102079102080102081102082102083102084102085102086102087102088102089102090102091102092102093102094102095102096102097102098102099102100102101102102102103102104102105102106102107102108102109102110102111102112102113102114102115102116102117102118102119102120102121102122102123102124102125102126102127102128102129102130102131102132102133102134102135102136102137102138102139102140102141102142102143102144102145102146102147102148102149102150102151102152102153102154102155102156102157102158102159102160102161102162102163102164102165102166102167102168102169102170102171102172102173102174102175102176102177102178102179102180102181102182102183102184102185102186102187102188102189102190102191102192102193102194102195102196102197102198102199102200102201102202102203102204102205102206102207102208102209102210102211102212102213102214102215102216102217102218102219102220102221102222102223102224102225102226102227102228102229102230102231102232102233102234102235102236102237102238102239102240102241102242102243102244102245102246102247102248102249102250102251102252102253102254102255102256102257102258102259102260102261102262102263102264102265102266102267102268102269102270102271102272102273102274102275102276102277102278102279102280102281102282102283102284102285102286102287102288102289102290102291102292102293102294102295102296102297102298102299102300102301102302102303102304102305102306102307102308102309102310102311102312102313102314102315102316102317102318102319102320102321102322102323102324102325102326102327102328102329102330102331102332102333102334102335102336102337102338102339102340102341102342102343102344102345102346102347102348102349102350102351102352102353102354102355102356102357102358102359102360102361102362102363102364102365102366102367102368102369102370102371102372102373102374102375102376102377102378102379102380102381102382102383102384102385102386102387102388102389102390102391102392102393102394102395102396102397102398102399102400102401102402102403102404102405102406102407102408102409102410102411102412102413102414102415102416102417102418102419102420102421102422102423102424102425102426102427102428102429102430102431102432102433102434102435102436102437102438102439102440102441102442102443102444102445102446102447102448102449102450102451102452102453102454102455102456102457102458102459102460102461102462102463102464102465102466102467102468102469102470102471102472102473102474102475102476102477102478102479102480102481102482102483102484102485102486102487102488102489102490102491102492102493102494102495102496102497102498102499102500102501102502102503102504102505102506102507102508102509102510102511102512102513102514102515102516102517102518102519102520102521102522102523102524102525102526102527102528102529102530102531102532102533102534102535102536102537102538102539102540102541102542102543102544102545102546102547102548102549102550102551102552102553102554102555102556102557102558102559102560102561102562102563102564102565102566102567102568102569102570102571102572102573102574102575102576102577102578102579102580102581102582102583102584102585102586102587102588102589102590102591102592102593102594102595102596102597102598102599102600102601102602102603102604102605102606102607102608102609102610102611102612102613102614102615102616102617102618102619102620102621102622102623102624102625102626102627102628102629102630102631102632102633102634102635102636102637102638102639102640102641102642102643102644102645102646102647102648102649102650102651102652102653102654102655102656102657102658102659102660102661102662102663102664102665102666102667102668102669102670102671102672102673102674102675102676102677102678102679102680102681102682102683102684102685102686102687102688102689102690102691102692102693102694102695102696102697102698102699102700102701102702102703102704102705102706102707102708102709102710102711102712102713102714102715102716102717102718102719102720102721102722102723102724102725102726102727102728102729102730102731102732102733102734102735102736102737102738102739102740102741102742102743102744102745102746102747102748102749102750102751102752102753102754102755102756102757102758102759102760102761102762102763102764102765102766102767102768102769102770102771102772102773102774102775102776102777102778102779102780102781102782102783102784102785102786102787102788102789102790102791102792102793102794102795102796102797102798102799102800102801102802102803102804102805102806102807102808102809102810102811102812102813102814102815102816102817102818102819102820102821102822102823102824102825102826102827102828102829102830102831102832102833102834102835102836102837102838102839102840102841102842102843102844102845102846102847102848102849102850102851102852102853102854102855102856102857102858102859102860102861102862102863102864102865102866102867102868102869102870102871102872102873102874102875102876102877102878102879102880102881102882102883102884102885102886102887102888102889102890102891102892102893102894102895102896102897102898102899102900102901102902102903102904102905102906102907102908102909102910102911102912102913102914102915102916102917102918102919102920102921102922102923102924102925102926102927102928102929102930102931102932102933102934102935102936102937102938102939102940102941102942102943102944102945102946102947102948102949102950102951102952102953102954102955102956102957102958102959102960102961102962102963102964102965102966102967102968102969102970102971102972102973102974102975102976102977102978102979102980102981102982102983102984102985102986102987102988102989102990102991102992102993102994102995102996102997102998102999103000103001103002103003103004103005103006103007103008103009103010103011103012103013103014103015103016103017103018103019103020103021103022103023103024103025103026103027103028103029103030103031103032103033103034103035103036103037103038103039103040103041103042103043103044103045103046103047103048103049103050103051103052103053103054103055103056103057103058103059103060103061103062103063103064103065103066103067103068103069103070103071103072103073103074103075103076103077103078103079103080103081103082103083103084103085103086103087103088103089103090103091103092103093103094103095103096103097103098103099103100103101103102103103103104103105103106103107103108103109103110103111103112103113103114103115103116103117103118103119103120103121103122103123103124103125103126103127103128103129103130103131103132103133103134103135103136103137103138103139103140103141103142103143103144103145103146103147103148103149103150103151103152103153103154103155103156103157103158103159103160103161103162103163103164103165103166103167103168103169103170103171103172103173103174103175103176103177103178103179103180103181103182103183103184103185103186103187103188103189103190103191103192103193103194103195103196103197103198103199103200103201103202103203103204103205103206103207103208103209103210103211103212103213103214103215103216103217103218103219103220103221103222103223103224103225103226103227103228103229103230103231103232103233103234103235103236103237103238103239103240103241103242103243103244103245103246103247103248103249103250103251103252103253103254103255103256103257103258103259103260103261103262103263103264103265103266103267103268103269103270103271103272103273103274103275103276103277103278103279103280103281103282103283103284103285103286103287103288103289103290103291103292103293103294103295103296103297103298103299103300103301103302103303103304103305103306103307103308103309103310103311103312103313103314103315103316103317103318103319103320103321103322103323103324103325103326103327103328103329103330103331103332103333103334103335103336103337103338103339103340103341103342103343103344103345103346103347103348103349103350103351103352103353103354103355103356103357103358103359103360103361103362103363103364103365103366103367103368103369103370103371103372103373103374103375103376103377103378103379103380103381103382103383103384103385103386103387103388103389103390103391103392103393103394103395103396103397103398103399103400103401103402103403103404103405103406103407103408103409103410103411103412103413103414103415103416103417103418103419103420103421103422103423103424103425103426103427103428103429103430103431103432103433103434103435103436103437103438103439103440103441103442103443103444103445103446103447103448103449103450103451103452103453103454103455103456103457103458103459103460103461103462103463103464103465103466103467103468103469103470103471103472103473103474103475103476103477103478103479103480103481103482103483103484103485103486103487103488103489103490103491103492103493103494103495103496103497103498103499103500103501103502103503103504103505103506103507103508103509103510103511103512103513103514103515103516103517103518103519103520103521103522103523103524103525103526103527103528103529103530103531103532103533103534103535103536103537103538103539103540103541103542103543103544103545103546103547103548103549103550103551103552103553103554103555103556103557103558103559103560103561103562103563103564103565103566103567103568103569103570103571103572103573103574103575103576103577103578103579103580103581103582103583103584103585103586103587103588103589103590103591103592103593103594103595103596103597103598103599103600103601103602103603103604103605103606103607103608103609103610103611103612103613103614103615103616103617103618103619103620103621103622103623103624103625103626103627103628103629103630103631103632103633103634103635103636103637103638103639103640103641103642103643103644103645103646103647103648103649103650103651103652103653103654103655103656103657103658103659103660103661103662103663103664103665103666103667103668103669103670103671103672103673103674103675103676103677103678103679103680103681103682103683103684103685103686103687103688103689103690103691103692103693103694103695103696103697103698103699103700103701103702103703103704103705103706103707103708103709103710103711103712103713103714103715103716103717103718103719103720103721103722103723103724103725103726103727103728103729103730103731103732103733103734103735103736103737103738103739103740103741103742103743103744103745103746103747103748103749103750103751103752103753103754103755103756103757103758103759103760103761103762103763103764103765103766103767103768103769103770103771103772103773103774103775103776103777103778103779103780103781103782103783103784103785103786103787103788103789103790103791103792103793103794103795103796103797103798103799103800103801103802103803103804103805103806103807103808103809103810103811103812103813103814103815103816103817103818103819103820103821103822103823103824103825103826103827103828103829103830103831103832103833103834103835103836103837103838103839103840103841103842103843103844103845103846103847103848103849103850103851103852103853103854103855103856103857103858103859103860103861103862103863103864103865103866103867103868103869103870103871103872103873103874103875103876103877103878103879103880103881103882103883103884103885103886103887103888103889103890103891103892103893103894103895103896103897103898103899103900103901103902103903103904103905103906103907103908103909103910103911103912103913103914103915103916103917103918103919103920103921103922103923103924103925103926103927103928103929103930103931103932103933103934103935103936103937103938103939103940103941103942103943103944103945103946103947103948103949103950103951103952103953103954103955103956103957103958103959103960103961103962103963103964103965103966103967103968103969103970103971103972103973103974103975103976103977103978103979103980103981103982103983103984103985103986103987103988103989103990103991103992103993103994103995103996103997103998103999104000104001104002104003104004104005104006104007104008104009104010104011104012104013104014104015104016104017104018104019104020104021104022104023104024104025104026104027104028104029104030104031104032104033104034104035104036104037104038104039104040104041104042104043104044104045104046104047104048104049104050104051104052104053104054104055104056104057104058104059104060104061104062104063104064104065104066104067104068104069104070104071104072104073104074104075104076104077104078104079104080104081104082104083104084104085104086104087104088104089104090104091104092104093104094104095104096104097104098104099104100104101104102104103104104104105104106104107104108104109104110104111104112104113104114104115104116104117104118104119104120104121104122104123104124104125104126104127104128104129104130104131104132104133104134104135104136104137104138104139104140104141104142104143104144104145104146104147104148104149104150104151104152104153104154104155104156104157104158104159104160104161104162104163104164104165104166104167104168104169104170104171104172104173104174104175104176104177104178104179104180104181104182104183104184104185104186104187104188104189104190104191104192104193104194104195104196104197104198104199104200104201104202104203104204104205104206104207104208104209104210104211104212104213104214104215104216104217104218104219104220104221104222104223104224104225104226104227104228104229104230104231104232104233104234104235104236104237104238104239104240104241104242104243104244104245104246104247104248104249104250104251104252104253104254104255104256104257104258104259104260104261104262104263104264104265104266104267104268104269104270104271104272104273104274104275104276104277104278104279104280104281104282104283104284104285104286104287104288104289104290104291104292104293104294104295104296104297104298104299104300104301104302104303104304104305104306104307104308104309104310104311104312104313104314104315104316104317104318104319104320104321104322104323104324104325104326104327104328104329104330104331104332104333104334104335104336104337104338104339104340104341104342104343104344104345104346104347104348104349104350104351104352104353104354104355104356104357104358104359104360104361104362104363104364104365104366104367104368104369104370104371104372104373104374104375104376104377104378104379104380104381104382104383104384104385104386104387104388104389104390104391104392104393104394104395104396104397104398104399104400104401104402104403104404104405104406104407104408104409104410104411104412104413104414104415104416104417104418104419104420104421104422104423104424104425104426104427104428104429104430104431104432104433104434104435104436104437104438104439104440104441104442104443104444104445104446104447104448104449104450104451104452104453104454104455104456104457104458104459104460104461104462104463104464104465104466104467104468104469104470104471104472104473104474104475104476104477104478104479104480104481104482104483104484104485104486104487104488104489104490104491104492104493104494104495104496104497104498104499104500104501104502104503104504104505104506104507104508104509104510104511104512104513104514104515104516104517104518104519104520104521104522104523104524104525104526104527104528104529104530104531104532104533104534104535104536104537104538104539104540104541104542104543104544104545104546104547104548104549104550104551104552104553104554104555104556104557104558104559104560104561104562104563104564104565104566104567104568104569104570104571104572104573104574104575104576104577104578104579104580104581104582104583104584104585104586104587104588104589104590104591104592104593104594104595104596104597104598104599104600104601104602104603104604104605104606104607104608104609104610104611104612104613104614104615104616104617104618104619104620104621104622104623104624104625104626104627104628104629104630104631104632104633104634104635104636104637104638104639104640104641104642104643104644104645104646104647104648104649104650104651104652104653104654104655104656104657104658104659104660104661104662104663104664104665104666104667104668104669104670104671104672104673104674104675104676104677104678104679104680104681104682104683104684104685104686104687104688104689104690104691104692104693104694104695104696104697104698104699104700104701104702104703104704104705104706104707104708104709104710104711104712104713104714104715104716104717104718104719104720104721104722104723104724104725104726104727104728104729104730104731104732104733104734104735104736104737104738104739104740104741104742104743104744104745104746104747104748104749104750104751104752104753104754104755104756104757104758104759104760104761104762104763104764104765104766104767104768104769104770104771104772104773104774104775104776104777104778104779104780104781104782104783104784104785104786104787104788104789104790104791104792104793104794104795104796104797104798104799104800104801104802104803104804104805104806104807104808104809104810104811104812104813104814104815104816104817104818104819104820104821104822104823104824104825104826104827104828104829104830104831104832104833104834104835104836104837104838104839104840104841104842104843104844104845104846104847104848104849104850104851104852104853104854104855104856104857104858104859104860104861104862104863104864104865104866104867104868104869104870104871104872104873104874104875104876104877104878104879104880104881104882104883104884104885104886104887104888104889104890104891104892104893104894104895104896104897104898104899104900104901104902104903104904104905104906104907104908104909104910104911104912104913104914104915104916104917104918104919104920104921104922104923104924104925104926104927104928104929104930104931104932104933104934104935104936104937104938104939104940104941104942104943104944104945104946104947104948104949104950104951104952104953104954104955104956104957104958104959104960104961104962104963104964104965104966104967104968104969104970104971104972104973104974104975104976104977104978104979104980104981104982104983104984104985104986104987104988104989104990104991104992104993104994104995104996104997104998104999105000105001105002105003105004105005105006105007105008105009105010105011105012105013105014105015105016105017105018105019105020105021105022105023105024105025105026105027105028105029105030105031105032105033105034105035105036105037105038105039105040105041105042105043105044105045105046105047105048105049105050105051105052105053105054105055105056105057105058105059105060105061105062105063105064105065105066105067105068105069105070105071105072105073105074105075105076105077105078105079105080105081105082105083105084105085105086105087105088105089105090105091105092105093105094105095105096105097105098105099105100105101105102105103105104105105105106105107105108105109105110105111105112105113105114105115105116105117105118105119105120105121105122105123105124105125105126105127105128105129105130105131105132105133105134105135105136105137105138105139105140105141105142105143105144105145105146105147105148105149105150105151105152105153105154105155105156105157105158105159105160105161105162105163105164105165105166105167105168105169105170105171105172105173105174105175105176105177105178105179105180105181105182105183105184105185105186105187105188105189105190105191105192105193105194105195105196105197105198105199105200105201105202105203105204105205105206105207105208105209105210105211105212105213105214105215105216105217105218105219105220105221105222105223105224105225105226105227105228105229105230105231105232105233105234105235105236105237105238105239105240105241105242105243105244105245105246105247105248105249105250105251105252105253105254105255105256105257105258105259105260105261105262105263105264105265105266105267105268105269105270105271105272105273105274105275105276105277105278105279105280105281105282105283105284105285105286105287105288105289105290105291105292105293105294105295105296105297105298105299105300105301105302105303105304105305105306105307105308105309105310105311105312105313105314105315105316105317105318105319105320105321105322105323105324105325105326105327105328105329105330105331105332105333105334105335105336105337105338105339105340105341105342105343105344105345105346105347105348105349105350105351105352105353105354105355105356105357105358105359105360105361105362105363105364105365105366105367105368105369105370105371105372105373105374105375105376105377105378105379105380105381105382105383105384105385105386105387105388105389105390105391105392105393105394105395105396105397105398105399105400105401105402105403105404105405105406105407105408105409105410105411105412105413105414105415105416105417105418105419105420105421105422105423105424105425105426105427105428105429105430105431105432105433105434105435105436105437105438105439105440105441105442105443105444105445105446105447105448105449105450105451105452105453105454105455105456105457105458105459105460105461105462105463105464105465105466105467105468105469105470105471105472105473105474105475105476105477105478105479105480105481105482105483105484105485105486105487105488105489105490105491105492105493105494105495105496105497105498105499105500105501105502105503105504105505105506105507105508105509105510105511105512105513105514105515105516105517105518105519105520105521105522105523105524105525105526105527105528105529105530105531105532105533105534105535105536105537105538105539105540105541105542105543105544105545105546105547105548105549105550105551105552105553105554105555105556105557105558105559105560105561105562105563105564105565105566105567105568105569105570105571105572105573105574105575105576105577105578105579105580105581105582105583105584105585105586105587105588105589105590105591105592105593105594105595105596105597105598105599105600105601105602105603105604105605105606105607105608105609105610105611105612105613105614105615105616105617105618105619105620105621105622105623105624105625105626105627105628105629105630105631105632105633105634105635105636105637105638105639105640105641105642105643105644105645105646105647105648105649105650105651105652105653105654105655105656105657105658105659105660105661105662105663105664105665105666105667105668105669105670105671105672105673105674105675105676105677105678105679105680105681105682105683105684105685105686105687105688105689105690105691105692105693105694105695105696105697105698105699105700105701105702105703105704105705105706105707105708105709105710105711105712105713105714105715105716105717105718105719105720105721105722105723105724105725105726105727105728105729105730105731105732105733105734105735105736105737105738105739105740105741105742105743105744105745105746105747105748105749105750105751105752105753105754105755105756105757105758105759105760105761105762105763105764105765105766105767105768105769105770105771105772105773105774105775105776105777105778105779105780105781105782105783105784105785105786105787105788105789105790105791105792105793105794105795105796105797105798105799105800105801105802105803105804105805105806105807105808105809105810105811105812105813105814105815105816105817105818105819105820105821105822105823105824105825105826105827105828105829105830105831105832105833105834105835105836105837105838105839105840105841105842105843105844105845105846105847105848105849105850105851105852105853105854105855105856105857105858105859105860105861105862105863105864105865105866105867105868105869105870105871105872105873105874105875105876105877105878105879105880105881105882105883105884105885105886105887105888105889105890105891105892105893105894105895105896105897105898105899105900105901105902105903105904105905105906105907105908105909105910105911105912105913105914105915105916105917105918105919105920105921105922105923105924105925105926105927105928105929105930105931105932105933105934105935105936105937105938105939105940105941105942105943105944105945105946105947105948105949105950105951105952105953105954105955105956105957105958105959105960105961105962105963105964105965105966105967105968105969105970105971105972105973105974105975105976105977105978105979105980105981105982105983105984105985105986105987105988105989105990105991105992105993105994105995105996105997105998105999106000106001106002106003106004106005106006106007106008106009106010106011106012106013106014106015106016106017106018106019106020106021106022106023106024106025106026106027106028106029106030106031106032106033106034106035106036106037106038106039106040106041106042106043106044106045106046106047106048106049106050106051106052106053106054106055106056106057106058106059106060106061106062106063106064106065106066106067106068106069106070106071106072106073106074106075106076106077106078106079106080106081106082106083106084106085106086106087106088106089106090106091106092106093106094106095106096106097106098106099106100106101106102106103106104106105106106106107106108106109106110106111106112106113106114106115106116106117106118106119106120106121106122106123106124106125106126106127106128106129106130106131106132106133106134106135106136106137106138106139106140106141106142106143106144106145106146106147106148106149106150106151106152106153106154106155106156106157106158106159106160106161106162106163106164106165106166106167106168106169106170106171106172106173106174106175106176106177106178106179106180106181106182106183106184106185106186106187106188106189106190106191106192106193106194106195106196106197106198106199106200106201106202106203106204106205106206106207106208106209106210106211106212106213106214106215106216106217106218106219106220106221106222106223106224106225106226106227106228106229106230106231106232106233106234106235106236106237106238106239106240106241106242106243106244106245106246106247106248106249106250106251106252106253106254106255106256106257106258106259106260106261106262106263106264106265106266106267106268106269106270106271106272106273106274106275106276106277106278106279106280106281106282106283106284106285106286106287106288106289106290106291106292106293106294106295106296106297106298106299106300106301106302106303106304106305106306106307106308106309106310106311106312106313106314106315106316106317106318106319106320106321106322106323106324106325106326106327106328106329106330106331106332106333106334106335106336106337106338106339106340106341106342106343106344106345106346106347106348106349106350106351106352106353106354106355106356106357106358106359106360106361106362106363106364106365106366106367106368106369106370106371106372106373106374106375106376106377106378106379106380106381106382106383106384106385106386106387106388106389106390106391106392106393106394106395106396106397106398106399106400106401106402106403106404106405106406106407106408106409106410106411106412106413106414106415106416106417106418106419106420106421106422106423106424106425106426106427106428106429106430106431106432106433106434106435106436106437106438106439106440106441106442106443106444106445106446106447106448106449106450106451106452106453106454106455106456106457106458106459106460106461106462106463106464106465106466106467106468106469106470106471106472106473106474106475106476106477106478106479106480106481106482106483106484106485106486106487106488106489106490106491106492106493106494106495106496106497106498106499106500106501106502106503106504106505106506106507106508106509106510106511106512106513106514106515106516106517106518106519106520106521106522106523106524106525106526106527106528106529106530106531106532106533106534106535106536106537106538106539106540106541106542106543106544106545106546106547106548106549106550106551106552106553106554106555106556106557106558106559106560106561106562106563106564106565106566106567106568106569106570106571106572106573106574106575106576106577106578106579106580106581106582106583106584106585106586106587106588106589106590106591106592106593106594106595106596106597106598106599106600106601106602106603106604106605106606106607106608106609106610106611106612106613106614106615106616106617106618106619106620106621106622106623106624106625106626106627106628106629106630106631106632106633106634106635106636106637106638106639106640106641106642106643106644106645106646106647106648106649106650106651106652106653106654106655106656106657106658106659106660106661106662106663106664106665106666106667106668106669106670106671106672106673106674106675106676106677106678106679106680106681106682106683106684106685106686106687106688106689106690106691106692106693106694106695106696106697106698106699106700106701106702106703106704106705106706106707106708106709106710106711106712106713106714106715106716106717106718106719106720106721106722106723106724106725106726106727106728106729106730106731106732106733106734106735106736106737106738106739106740106741106742106743106744106745106746106747106748106749106750106751106752106753106754106755106756106757106758106759106760106761106762106763106764106765106766106767106768106769106770106771106772106773106774106775106776106777106778106779106780106781106782106783106784106785106786106787106788106789106790106791106792106793106794106795106796106797106798106799106800106801106802106803106804106805106806106807106808106809106810106811106812106813106814106815106816106817106818106819106820106821106822106823106824106825106826106827106828106829106830106831106832106833106834106835106836106837106838106839106840106841106842106843106844106845106846106847106848106849106850106851106852106853106854106855106856106857106858106859106860106861106862106863106864106865106866106867106868106869106870106871106872106873106874106875106876106877106878106879106880106881106882106883106884106885106886106887106888106889106890106891106892106893106894106895106896106897106898106899106900106901106902106903106904106905106906106907106908106909106910106911106912106913106914106915106916106917106918106919106920106921106922106923106924106925106926106927106928106929106930106931106932106933106934106935106936106937106938106939106940106941106942106943106944106945106946106947106948106949106950106951106952106953106954106955106956106957106958106959106960106961106962106963106964106965106966106967106968106969106970106971106972106973106974106975106976106977106978106979106980106981106982106983106984106985106986106987106988106989106990106991106992106993106994106995106996106997106998106999107000107001107002107003107004107005107006107007107008107009107010107011107012107013107014107015107016107017107018107019107020107021107022107023107024107025107026107027107028107029107030107031107032107033107034107035107036107037107038107039107040107041107042107043107044107045107046107047107048107049107050107051107052107053107054107055107056107057107058107059107060107061107062107063107064107065107066107067107068107069107070107071107072107073107074107075107076107077107078107079107080107081107082107083107084107085107086107087107088107089107090107091107092107093107094107095107096107097107098107099107100107101107102107103107104107105107106107107107108107109107110107111107112107113107114107115107116107117107118107119107120107121107122107123107124107125107126107127107128107129107130107131107132107133107134107135107136107137107138107139107140107141107142107143107144107145107146107147107148107149107150107151107152107153107154107155107156107157107158107159107160107161107162107163107164107165107166107167107168107169107170107171107172107173107174107175107176107177107178107179107180107181107182107183107184107185107186107187107188107189107190107191107192107193107194107195107196107197107198107199107200107201107202107203107204107205107206107207107208107209107210107211107212107213107214107215107216107217107218107219107220107221107222107223107224107225107226107227107228107229107230107231107232107233107234107235107236107237107238107239107240107241107242107243107244107245107246107247107248107249107250107251107252107253107254107255107256107257107258107259107260107261107262107263107264107265107266107267107268107269107270107271107272107273107274107275107276107277107278107279107280107281107282107283107284107285107286107287107288107289107290107291107292107293107294107295107296107297107298107299107300107301107302107303107304107305107306107307107308107309107310107311107312107313107314107315107316107317107318107319107320107321107322107323107324107325107326107327107328107329107330107331107332107333107334107335107336107337107338107339107340107341107342107343107344107345107346107347107348107349107350107351107352107353107354107355107356107357107358107359107360107361107362107363107364107365107366107367107368107369107370107371107372107373107374107375107376107377107378107379107380107381107382107383107384107385107386107387107388107389107390107391107392107393107394107395107396107397107398107399107400107401107402107403107404107405107406107407107408107409107410107411107412107413107414107415107416107417107418107419107420107421107422107423107424107425107426107427107428107429107430107431107432107433107434107435107436107437107438107439107440107441107442107443107444107445107446107447107448107449107450107451107452107453107454107455107456107457107458107459107460107461107462107463107464107465107466107467107468107469107470107471107472107473107474107475107476107477107478107479107480107481107482107483107484107485107486107487107488107489107490107491107492107493107494107495107496107497107498107499107500107501107502107503107504107505107506107507107508107509107510107511107512107513107514107515107516107517107518107519107520107521107522107523107524107525107526107527107528107529107530107531107532107533107534107535107536107537107538107539107540107541107542107543107544107545107546107547107548107549107550107551107552107553107554107555107556107557107558107559107560107561107562107563107564107565107566107567107568107569107570107571107572107573107574107575107576107577107578107579107580107581107582107583107584107585107586107587107588107589107590107591107592107593107594107595107596107597107598107599107600107601107602107603107604107605107606107607107608107609107610107611107612107613107614107615107616107617107618107619107620107621107622107623107624107625107626107627107628107629107630107631107632107633107634107635107636107637107638107639107640107641107642107643107644107645107646107647107648107649107650107651107652107653107654107655107656107657107658107659107660107661107662107663107664107665107666107667107668107669107670107671107672107673107674107675107676107677107678107679107680107681107682107683107684107685107686107687107688107689107690107691107692107693107694107695107696107697107698107699107700107701107702107703107704107705107706107707107708107709107710107711107712107713107714107715107716107717107718107719107720107721107722107723107724107725107726107727107728107729107730107731107732107733107734107735107736107737107738107739107740107741107742107743107744107745107746107747107748107749107750107751107752107753107754107755107756107757107758107759107760107761107762107763107764107765107766107767107768107769107770107771107772107773107774107775107776107777107778107779107780107781107782107783107784107785107786107787107788107789107790107791107792107793107794107795107796107797107798107799107800107801107802107803107804107805107806107807107808107809107810107811107812107813107814107815107816107817107818107819107820107821107822107823107824107825107826107827107828107829107830107831107832107833107834107835107836107837107838107839107840107841107842107843107844107845107846107847107848107849107850107851107852107853107854107855107856107857107858107859107860107861107862107863107864107865107866107867107868107869107870107871107872107873107874107875107876107877107878107879107880107881107882107883107884107885107886107887107888107889107890107891107892107893107894107895107896107897107898107899107900107901107902107903107904107905107906107907107908107909107910107911107912107913107914107915107916107917107918107919107920107921107922107923107924107925107926107927107928107929107930107931107932107933107934107935107936107937107938107939107940107941107942107943107944107945107946107947107948107949107950107951107952107953107954107955107956107957107958107959107960107961107962107963107964107965107966107967107968107969107970107971107972107973107974107975107976107977107978107979107980107981107982107983107984107985107986107987107988107989107990107991107992107993107994107995107996107997107998107999108000108001108002108003108004108005108006108007108008108009108010108011108012108013108014108015108016108017108018108019108020108021108022108023108024108025108026108027108028108029108030108031108032108033108034108035108036108037108038108039108040108041108042108043108044108045108046108047108048108049108050108051108052108053108054108055108056108057108058108059108060108061108062108063108064108065108066108067108068108069108070108071108072108073108074108075108076108077108078108079108080108081108082108083108084108085108086108087108088108089108090108091108092108093108094108095108096108097108098108099108100108101108102108103108104108105108106108107108108108109108110108111108112108113108114108115108116108117108118108119108120108121108122108123108124108125108126108127108128108129108130108131108132108133108134108135108136108137108138108139108140108141108142108143108144108145108146108147108148108149108150108151108152108153108154108155108156108157108158108159108160108161108162108163108164108165108166108167108168108169108170108171108172108173108174108175108176108177108178108179108180108181108182108183108184108185108186108187108188108189108190108191108192108193108194108195108196108197108198108199108200108201108202108203108204108205108206108207108208108209108210108211108212108213108214108215108216108217108218108219108220108221108222108223108224108225108226108227108228108229108230108231108232108233108234108235108236108237108238108239108240108241108242108243108244108245108246108247108248108249108250108251108252108253108254108255108256108257108258108259108260108261108262108263108264108265108266108267108268108269108270108271108272108273108274108275108276108277108278108279108280108281108282108283108284108285108286108287108288108289108290108291108292108293108294108295108296108297108298108299108300108301108302108303108304108305108306108307108308108309108310108311108312108313108314108315108316108317108318108319108320108321108322108323108324108325108326108327108328108329108330108331108332108333108334108335108336108337108338108339108340108341108342108343108344108345108346108347108348108349108350108351108352108353108354108355108356108357108358108359108360108361108362108363108364108365108366108367108368108369108370108371108372108373108374108375108376108377108378108379108380108381108382108383108384108385108386108387108388108389108390108391108392108393108394108395108396108397108398108399108400108401108402108403108404108405108406108407108408108409108410108411108412108413108414108415108416108417108418108419108420108421108422108423108424108425108426108427108428108429108430108431108432108433108434108435108436108437108438108439108440108441108442108443108444108445108446108447108448108449108450108451108452108453108454108455108456108457108458108459108460108461108462108463108464108465108466108467108468108469108470108471108472108473108474108475108476108477108478108479108480108481108482108483108484108485108486108487108488108489108490108491108492108493108494108495108496108497108498108499108500108501108502108503108504108505108506108507108508108509108510108511108512108513108514108515108516108517108518108519108520108521108522108523108524108525108526108527108528108529108530108531108532108533108534108535108536108537108538108539108540108541108542108543108544108545108546108547108548108549108550108551108552108553108554108555108556108557108558108559108560108561108562108563108564108565108566108567108568108569108570108571108572108573108574108575108576108577108578108579108580108581108582108583108584108585108586108587108588108589108590108591108592108593108594108595108596108597108598108599108600108601108602108603108604108605108606108607108608108609108610108611108612108613108614108615108616108617108618108619108620108621108622108623108624108625108626108627108628108629108630108631108632108633108634108635108636108637108638108639108640108641108642108643108644108645108646108647108648108649108650108651108652108653108654108655108656108657108658108659108660108661108662108663108664108665108666108667108668108669108670108671108672108673108674108675108676108677108678108679108680108681108682108683108684108685108686108687108688108689108690108691108692108693108694108695108696108697108698108699108700108701108702108703108704108705108706108707108708108709108710108711108712108713108714108715108716108717108718108719108720108721108722108723108724108725108726108727108728108729108730108731108732108733108734108735108736108737108738108739108740108741108742108743108744108745108746108747108748108749108750108751108752108753108754108755108756108757108758108759108760108761108762108763108764108765108766108767108768108769108770108771108772108773108774108775108776108777108778108779108780108781108782108783108784108785108786108787108788108789108790108791108792108793108794108795108796108797108798108799108800108801108802108803108804108805108806108807108808108809108810108811108812108813108814108815108816108817108818108819108820108821108822108823108824108825108826108827108828108829108830108831108832108833108834108835108836108837108838108839108840108841108842108843108844108845108846108847108848108849108850108851108852108853108854108855108856108857108858108859108860108861108862108863108864108865108866108867108868108869108870108871108872108873108874108875108876108877108878108879108880108881108882108883108884108885108886108887108888108889108890108891108892108893108894108895108896108897108898108899108900108901108902108903108904108905108906108907108908108909108910108911108912108913108914108915108916108917108918108919108920108921108922108923108924108925108926108927108928108929108930108931108932108933108934108935108936108937108938108939108940108941108942108943108944108945108946108947108948108949108950108951108952108953108954108955108956108957108958108959108960108961108962108963108964108965108966108967108968108969108970108971108972108973108974108975108976108977108978108979108980108981108982108983108984108985108986108987108988108989108990108991108992108993108994108995108996108997108998108999109000109001109002109003109004109005109006109007109008109009109010109011109012109013109014109015109016109017109018109019109020109021109022109023109024109025109026109027109028109029109030109031109032109033109034109035109036109037109038109039109040109041109042109043109044109045109046109047109048109049109050109051109052109053109054109055109056109057109058109059109060109061109062109063109064109065109066109067109068109069109070109071109072109073109074109075109076109077109078109079109080109081109082109083109084109085109086109087109088109089109090109091109092109093109094109095109096109097109098109099109100109101109102109103109104109105109106109107109108109109109110109111109112109113109114109115109116109117109118109119109120109121109122109123109124109125109126109127109128109129109130109131109132109133109134109135109136109137109138109139109140109141109142109143109144109145109146109147109148109149109150109151109152109153109154109155109156109157109158109159109160109161109162109163109164109165109166109167109168109169109170109171109172109173109174109175109176109177109178109179109180109181109182109183109184109185109186109187109188109189109190109191109192109193109194109195109196109197109198109199109200109201109202109203109204109205109206109207109208109209109210109211109212109213109214109215109216109217109218109219109220109221109222109223109224109225109226109227109228109229109230109231109232109233109234109235109236109237109238109239109240109241109242109243109244109245109246109247109248109249109250109251109252109253109254109255109256109257109258109259109260109261109262109263109264109265109266109267109268109269109270109271109272109273109274109275109276109277109278109279109280109281109282109283109284109285109286109287109288109289109290109291109292109293109294109295109296109297109298109299109300109301109302109303109304109305109306109307109308109309109310109311109312109313109314109315109316109317109318109319109320109321109322109323109324109325109326109327109328109329109330109331109332109333109334109335109336109337109338109339109340109341109342109343109344109345109346109347109348109349109350109351109352109353109354109355109356109357109358109359109360109361109362109363109364109365109366109367109368109369109370109371109372109373109374109375109376109377109378109379109380109381109382109383109384109385109386109387109388109389109390109391109392109393109394109395109396109397109398109399109400109401109402109403109404109405109406109407109408109409109410109411109412109413109414109415109416109417109418109419109420109421109422109423109424109425109426109427109428109429109430109431109432109433109434109435109436109437109438109439109440109441109442109443109444109445109446109447109448109449109450109451109452109453109454109455109456109457109458109459109460109461109462109463109464109465109466109467109468109469109470109471109472109473109474109475109476109477109478109479109480109481109482109483109484109485109486109487109488109489109490109491109492109493109494109495109496109497109498109499109500109501109502109503109504109505109506109507109508109509109510109511109512109513109514109515109516109517109518109519109520109521109522109523109524109525109526109527109528109529109530109531109532109533109534109535109536109537109538109539109540109541109542109543109544109545109546109547109548109549109550109551109552109553109554109555109556109557109558109559109560109561109562109563109564109565109566109567109568109569109570109571109572109573109574109575109576109577109578109579109580109581109582109583109584109585109586109587109588109589109590109591109592109593109594109595109596109597109598109599109600109601109602109603109604109605109606109607109608109609109610109611109612109613109614109615109616109617109618109619109620109621109622109623109624109625109626109627109628109629109630109631109632109633109634109635109636109637109638109639109640109641109642109643109644109645109646109647109648109649109650109651109652109653109654109655109656109657109658109659109660109661109662109663109664109665109666109667109668109669109670109671109672109673109674109675109676109677109678109679109680109681109682109683109684109685109686109687109688109689109690109691109692109693109694109695109696109697109698109699109700109701109702109703109704109705109706109707109708109709109710109711109712109713109714109715109716109717109718109719109720109721109722109723109724109725109726109727109728109729109730109731109732109733109734109735109736109737109738109739109740109741109742109743109744109745109746109747109748109749109750109751109752109753109754109755109756109757109758109759109760109761109762109763109764109765109766109767109768109769109770109771109772109773109774109775109776109777109778109779109780109781109782109783109784109785109786109787109788109789109790109791109792109793109794109795109796109797109798109799109800109801109802109803109804109805109806109807109808109809109810109811109812109813109814109815109816109817109818109819109820109821109822109823109824109825109826109827109828109829109830109831109832109833109834109835109836109837109838109839109840109841109842109843109844109845109846109847109848109849109850109851109852109853109854109855109856109857109858109859109860109861109862109863109864109865109866109867109868109869109870109871109872109873109874109875109876109877109878109879109880109881109882109883109884109885109886109887109888109889109890109891109892109893109894109895109896109897109898109899109900109901109902109903109904109905109906109907109908109909109910109911109912109913109914109915109916109917109918109919109920109921109922109923109924109925109926109927109928109929109930109931109932109933109934109935109936109937109938109939109940109941109942109943109944109945109946109947109948109949109950109951109952109953109954109955109956109957109958109959109960109961109962109963109964109965109966109967109968109969109970109971109972109973109974109975109976109977109978109979109980109981109982109983109984109985109986109987109988109989109990109991109992109993109994109995109996109997109998109999110000110001110002110003110004110005110006110007110008110009110010110011110012110013110014110015110016110017110018110019110020110021110022110023110024110025110026110027110028110029110030110031110032110033110034110035110036110037110038110039110040110041110042110043110044110045110046110047110048110049110050110051110052110053110054110055110056110057110058110059110060110061110062110063110064110065110066110067110068110069110070110071110072110073110074110075110076110077110078110079110080110081110082110083110084110085110086110087110088110089110090110091110092110093110094110095110096110097110098110099110100110101110102110103110104110105110106110107110108110109110110110111110112110113110114110115110116110117110118110119110120110121110122110123110124110125110126110127110128110129110130110131110132110133110134110135110136110137110138110139110140110141110142110143110144110145110146110147110148110149110150110151110152110153110154110155110156110157110158110159110160110161110162110163110164110165110166110167110168110169110170110171110172110173110174110175110176110177110178110179110180110181110182110183110184110185110186110187110188110189110190110191110192110193110194110195110196110197110198110199110200110201110202110203110204110205110206110207110208110209110210110211110212110213110214110215110216110217110218110219110220110221110222110223110224110225110226110227110228110229110230110231110232110233110234110235110236110237110238110239110240110241110242110243110244110245110246110247110248110249110250110251110252110253110254110255110256110257110258110259110260110261110262110263110264110265110266110267110268110269110270110271110272110273110274110275110276110277110278110279110280110281110282110283110284110285110286110287110288110289110290110291110292110293110294110295110296110297110298110299110300110301110302110303110304110305110306110307110308110309110310110311110312110313110314110315110316110317110318110319110320110321110322110323110324110325110326110327110328110329110330110331110332110333110334110335110336110337110338110339110340110341110342110343110344110345110346110347110348110349110350110351110352110353110354110355110356110357110358110359110360110361110362110363110364110365110366110367110368110369110370110371110372110373110374110375110376110377110378110379110380110381110382110383110384110385110386110387110388110389110390110391110392110393110394110395110396110397110398110399110400110401110402110403110404110405110406110407110408110409110410110411110412110413110414110415110416110417110418110419110420110421110422110423110424110425110426110427110428110429110430110431110432110433110434110435110436110437110438110439110440110441110442110443110444110445110446110447110448110449110450110451110452110453110454110455110456110457110458110459110460110461110462110463110464110465110466110467110468110469110470110471110472110473110474110475110476110477110478110479110480110481110482110483110484110485110486110487110488110489110490110491110492110493110494110495110496110497110498110499110500110501110502110503110504110505110506110507110508110509110510110511110512110513110514110515110516110517110518110519110520110521110522110523110524110525110526110527110528110529110530110531110532110533110534110535110536110537110538110539110540110541110542110543110544110545110546110547110548110549110550110551110552110553110554110555110556110557110558110559110560110561110562110563110564110565110566110567110568110569110570110571110572110573110574110575110576110577110578110579110580110581110582110583110584110585110586110587110588110589110590110591110592110593110594110595110596110597110598110599110600110601110602110603110604110605110606110607110608110609110610110611110612110613110614110615110616110617110618110619110620110621110622110623110624110625110626110627110628110629110630110631110632110633110634110635110636110637110638110639110640110641110642110643110644110645110646110647110648110649110650110651110652110653110654110655110656110657110658110659110660110661110662110663110664110665110666110667110668110669110670110671110672110673110674110675110676110677110678110679110680110681110682110683110684110685110686110687110688110689110690110691110692110693110694110695110696110697110698110699110700110701110702110703110704110705110706110707110708110709110710110711110712110713110714110715110716110717110718110719110720110721110722110723110724110725110726110727110728110729110730110731110732110733110734110735110736110737110738110739110740110741110742110743110744110745110746110747110748110749110750110751110752110753110754110755110756110757110758110759110760110761110762110763110764110765110766110767110768110769110770110771110772110773110774110775110776110777110778110779110780110781110782110783110784110785110786110787110788110789110790110791110792110793110794110795110796110797110798110799110800110801110802110803110804110805110806110807110808110809110810110811110812110813110814110815110816110817110818110819110820110821110822110823110824110825110826110827110828110829110830110831110832110833110834110835110836110837110838110839110840110841110842110843110844110845110846110847110848110849110850110851110852110853110854110855110856110857110858110859110860110861110862110863110864110865110866110867110868110869110870110871110872110873110874110875110876110877110878110879110880110881110882110883110884110885110886110887110888110889110890110891110892110893110894110895110896110897110898110899110900110901110902110903110904110905110906110907110908110909110910110911110912110913110914110915110916110917110918110919110920110921110922110923110924110925110926110927110928110929110930110931110932110933110934110935110936110937110938110939110940110941110942110943110944110945110946110947110948110949110950110951110952110953110954110955110956110957110958110959110960110961110962110963110964110965110966110967110968110969110970110971110972110973110974110975110976110977110978110979110980110981110982110983110984110985110986110987110988110989110990110991110992110993110994110995110996110997110998110999111000111001111002111003111004111005111006111007111008111009111010111011111012111013111014111015111016111017111018111019111020111021111022111023111024111025111026111027111028111029111030111031111032111033111034111035111036111037111038111039111040111041111042111043111044111045111046111047111048111049111050111051111052111053111054111055111056111057111058111059111060111061111062111063111064111065111066111067111068111069111070111071111072111073111074111075111076111077111078111079111080111081111082111083111084111085111086111087111088111089111090111091111092111093111094111095111096111097111098111099111100111101111102111103111104111105111106111107111108111109111110111111111112111113111114111115111116111117111118111119111120111121111122111123111124111125111126111127111128111129111130111131111132111133111134111135111136111137111138111139111140111141111142111143111144111145111146111147111148111149111150111151111152111153111154111155111156111157111158111159111160111161111162111163111164111165111166111167111168111169111170111171111172111173111174111175111176111177111178111179111180111181111182111183111184111185111186111187111188111189111190111191111192111193111194111195111196111197111198111199111200111201111202111203111204111205111206111207111208111209111210111211111212111213111214111215111216111217111218111219111220111221111222111223111224111225111226111227111228111229111230111231111232111233111234111235111236111237111238111239111240111241111242111243111244111245111246111247111248111249111250111251111252111253111254111255111256111257111258111259111260111261111262111263111264111265111266111267111268111269111270111271111272111273111274111275111276111277111278111279111280111281111282111283111284111285111286111287111288111289111290111291111292111293111294111295111296111297111298111299111300111301111302111303111304111305111306111307111308111309111310111311111312111313111314111315111316111317111318111319111320111321111322111323111324111325111326111327111328111329111330111331111332111333111334111335111336111337111338111339111340111341111342111343111344111345111346111347111348111349111350111351111352111353111354111355111356111357111358111359111360111361111362111363111364111365111366111367111368111369111370111371111372111373111374111375111376111377111378111379111380111381111382111383111384111385111386111387111388111389111390111391111392111393111394111395111396111397111398111399111400111401111402111403111404111405111406111407111408111409111410111411111412111413111414111415111416111417111418111419111420111421111422111423111424111425111426111427111428111429111430111431111432111433111434111435111436111437111438111439111440111441111442111443111444111445111446111447111448111449111450111451111452111453111454111455111456111457111458111459111460111461111462111463111464111465111466111467111468111469111470111471111472111473111474111475111476111477111478111479111480111481111482111483111484111485111486111487111488111489111490111491111492111493111494111495111496111497111498111499111500111501111502111503111504111505111506111507111508111509111510111511111512111513111514111515111516111517111518111519111520111521111522111523111524111525111526111527111528111529111530111531111532111533111534111535111536111537111538111539111540111541111542111543111544111545111546111547111548111549111550111551111552111553111554111555111556111557111558111559111560111561111562111563111564111565111566111567111568111569111570111571111572111573111574111575111576111577111578111579111580111581111582111583111584111585111586111587111588111589111590111591111592111593111594111595111596111597111598111599111600111601111602111603111604111605111606111607111608111609111610111611111612111613111614111615111616111617111618111619111620111621111622111623111624111625111626111627111628111629111630111631111632111633111634111635111636111637111638111639111640111641111642111643111644111645111646111647111648111649111650111651111652111653111654111655111656111657111658111659111660111661111662111663111664111665111666111667111668111669111670111671111672111673111674111675111676111677111678111679111680111681111682111683111684111685111686111687111688111689111690111691111692111693111694111695111696111697111698111699111700111701111702111703111704111705111706111707111708111709111710111711111712111713111714111715111716111717111718111719111720111721111722111723111724111725111726111727111728111729111730111731111732111733111734111735111736111737111738111739111740111741111742111743111744111745111746111747111748111749111750111751111752111753111754111755111756111757111758111759111760111761111762111763111764111765111766111767111768111769111770111771111772111773111774111775111776111777111778111779111780111781111782111783111784111785111786111787111788111789111790111791111792111793111794111795111796111797111798111799111800111801111802111803111804111805111806111807111808111809111810111811111812111813111814111815111816111817111818111819111820111821111822111823111824111825111826111827111828111829111830111831111832111833111834111835111836111837111838111839111840111841111842111843111844111845111846111847111848111849111850111851111852111853111854111855111856111857111858111859111860111861111862111863111864111865111866111867111868111869111870111871111872111873111874111875111876111877111878111879111880111881111882111883111884111885111886111887111888111889111890111891111892111893111894111895111896111897111898111899111900111901111902111903111904111905111906111907111908111909111910111911111912111913111914111915111916111917111918111919111920111921111922111923111924111925111926111927111928111929111930111931111932111933111934111935111936111937111938111939111940111941111942111943111944111945111946111947111948111949111950111951111952111953111954111955111956111957111958111959111960111961111962111963111964111965111966111967111968111969111970111971111972111973111974111975111976111977111978111979111980111981111982111983111984111985111986111987111988111989111990111991111992111993111994111995111996111997111998111999112000112001112002112003112004112005112006112007112008112009112010112011112012112013112014112015112016112017112018112019112020112021112022112023112024112025112026112027112028112029112030112031112032112033112034112035112036112037112038112039112040112041112042112043112044112045112046112047112048112049112050112051112052112053112054112055112056112057112058112059112060112061112062112063112064112065112066112067112068112069112070112071112072112073112074112075112076112077112078112079112080112081112082112083112084112085112086112087112088112089112090112091112092112093112094112095112096112097112098112099112100112101112102112103112104112105112106112107112108112109112110112111112112112113112114112115112116112117112118112119112120112121112122112123112124112125112126112127112128112129112130112131112132112133112134112135112136112137112138112139112140112141112142112143112144112145112146112147112148112149112150112151112152112153112154112155112156112157112158112159112160112161112162112163112164112165112166112167112168112169112170112171112172112173112174112175112176112177112178112179112180112181112182112183112184112185112186112187112188112189112190112191112192112193112194112195112196112197112198112199112200112201112202112203112204112205112206112207112208112209112210112211112212112213112214112215112216112217112218112219112220112221112222112223112224112225112226112227112228112229112230112231112232112233112234112235112236112237112238112239112240112241112242112243112244112245112246112247112248112249112250112251112252112253112254112255112256112257112258112259112260112261112262112263112264112265112266112267112268112269112270112271112272112273112274112275112276112277112278112279112280112281112282112283112284112285112286112287112288112289112290112291112292112293112294112295112296112297112298112299112300112301112302112303112304112305112306112307112308112309112310112311112312112313112314112315112316112317112318112319112320112321112322112323112324112325112326112327112328112329112330112331112332112333112334112335112336112337112338112339112340112341112342112343112344112345112346112347112348112349112350112351112352112353112354112355112356112357112358112359112360112361112362112363112364112365112366112367112368112369112370112371112372112373112374112375112376112377112378112379112380112381112382112383112384112385112386112387112388112389112390112391112392112393112394112395112396112397112398112399112400112401112402112403112404112405112406112407112408112409112410112411112412112413112414112415112416112417112418112419112420112421112422112423112424112425112426112427112428112429112430112431112432112433112434112435112436112437112438112439112440112441112442112443112444112445112446112447112448112449112450112451112452112453112454112455112456112457112458112459112460112461112462112463112464112465112466112467112468112469112470112471112472112473112474112475112476112477112478112479112480112481112482112483112484112485112486112487112488112489112490112491112492112493112494112495112496112497112498112499112500112501112502112503112504112505112506112507112508112509112510112511112512112513112514112515112516112517112518112519112520112521112522112523112524112525112526112527112528112529112530112531112532112533112534112535112536112537112538112539112540112541112542112543112544112545112546112547112548112549112550112551112552112553112554112555112556112557112558112559112560112561112562112563112564112565112566112567112568112569112570112571112572112573112574112575112576112577112578112579112580112581112582112583112584112585112586112587112588112589112590112591112592112593112594112595112596112597112598112599112600112601112602112603112604112605112606112607112608112609112610112611112612112613112614112615112616112617112618112619112620112621112622112623112624112625112626112627112628112629112630112631112632112633112634112635112636112637112638112639112640112641112642112643112644112645112646112647112648112649112650112651112652112653112654112655112656112657112658112659112660112661112662112663112664112665112666112667112668112669112670112671112672112673112674112675112676112677112678112679112680112681112682112683112684112685112686112687112688112689112690112691112692112693112694112695112696112697112698112699112700112701112702112703112704112705112706112707112708112709112710112711112712112713112714112715112716112717112718112719112720112721112722112723112724112725112726112727112728112729112730112731112732112733112734112735112736112737112738112739112740112741112742112743112744112745112746112747112748112749112750112751112752112753112754112755112756112757112758112759112760112761112762112763112764112765112766112767112768112769112770112771112772112773112774112775112776112777112778112779112780112781112782112783112784112785112786112787112788112789112790112791112792112793112794112795112796112797112798112799112800112801112802112803112804112805112806112807112808112809112810112811112812112813112814112815112816112817112818112819112820112821112822112823112824112825112826112827112828112829112830112831112832112833112834112835112836112837112838112839112840112841112842112843112844112845112846112847112848112849112850112851112852112853112854112855112856112857112858112859112860112861112862112863112864112865112866112867112868112869112870112871112872112873112874112875112876112877112878112879112880112881112882112883112884112885112886112887112888112889112890112891112892112893112894112895112896112897112898112899112900112901112902112903112904112905112906112907112908112909112910112911112912112913112914112915112916112917112918112919112920112921112922112923112924112925112926112927112928112929112930112931112932112933112934112935112936112937112938112939112940112941112942112943112944112945112946112947112948112949112950112951112952112953112954112955112956112957112958112959112960112961112962112963112964112965112966112967112968112969112970112971112972112973112974112975112976112977112978112979112980112981112982112983112984112985112986112987112988112989112990112991112992112993112994112995112996112997112998112999113000113001113002113003113004113005113006113007113008113009113010113011113012113013113014113015113016113017113018113019113020113021113022113023113024113025113026113027113028113029113030113031113032113033113034113035113036113037113038113039113040113041113042113043113044113045113046113047113048113049113050113051113052113053113054113055113056113057113058113059113060113061113062113063113064113065113066113067113068113069113070113071113072113073113074113075113076113077113078113079113080113081113082113083113084113085113086113087113088113089113090113091113092113093113094113095113096113097113098113099113100113101113102113103113104113105113106113107113108113109113110113111113112113113113114113115113116113117113118113119113120113121113122113123113124113125113126113127113128113129113130113131113132113133113134113135113136113137113138113139113140113141113142113143113144113145113146113147113148113149113150113151113152113153113154113155113156113157113158113159113160113161113162113163113164113165113166113167113168113169113170113171113172113173113174113175113176113177113178113179113180113181113182113183113184113185113186113187113188113189113190113191113192113193113194113195113196113197113198113199113200113201113202113203113204113205113206113207113208113209113210113211113212113213113214113215113216113217113218113219113220113221113222113223113224113225113226113227113228113229113230113231113232113233113234113235113236113237113238113239113240113241113242113243113244113245113246113247113248113249113250113251113252113253113254113255113256113257113258113259113260113261113262113263113264113265113266113267113268113269113270113271113272113273113274113275113276113277113278113279113280113281113282113283113284113285113286113287113288113289113290113291113292113293113294113295113296113297113298113299113300113301113302113303113304113305113306113307113308113309113310113311113312113313113314113315113316113317113318113319113320113321113322113323113324113325113326113327113328113329113330113331113332113333113334113335113336113337113338113339113340113341113342113343113344113345113346113347113348113349113350113351113352113353113354113355113356113357113358113359113360113361113362113363113364113365113366113367113368113369113370113371113372113373113374113375113376113377113378113379113380113381113382113383113384113385113386113387113388113389113390113391113392113393113394113395113396113397113398113399113400113401113402113403113404113405113406113407113408113409113410113411113412113413113414113415113416113417113418113419113420113421113422113423113424113425113426113427113428113429113430113431113432113433113434113435113436113437113438113439113440113441113442113443113444113445113446113447113448113449113450113451113452113453113454113455113456113457113458113459113460113461113462113463113464113465113466113467113468113469113470113471113472113473113474113475113476113477113478113479113480113481113482113483113484113485113486113487113488113489113490113491113492113493113494113495113496113497113498113499113500113501113502113503113504113505113506113507113508113509113510113511113512113513113514113515113516113517113518113519113520113521113522113523113524113525113526113527113528113529113530113531113532113533113534113535113536113537113538113539113540113541113542113543113544113545113546113547113548113549113550113551113552113553113554113555113556113557113558113559113560113561113562113563113564113565113566113567113568113569113570113571113572113573113574113575113576113577113578113579113580113581113582113583113584113585113586113587113588113589113590113591113592113593113594113595113596113597113598113599113600113601113602113603113604113605113606113607113608113609113610113611113612113613113614113615113616113617113618113619113620113621113622113623113624113625113626113627113628113629113630113631113632113633113634113635113636113637113638113639113640113641113642113643113644113645113646113647113648113649113650113651113652113653113654113655113656113657113658113659113660113661113662113663113664113665113666113667113668113669113670113671113672113673113674113675113676113677113678113679113680113681113682113683113684113685113686113687113688113689113690113691113692113693113694113695113696113697113698113699113700113701113702113703113704113705113706113707113708113709113710113711113712113713113714113715113716113717113718113719113720113721113722113723113724113725113726113727113728113729113730113731113732113733113734113735113736113737113738113739113740113741113742113743113744113745113746113747113748113749113750113751113752113753113754113755113756113757113758113759113760113761113762113763113764113765113766113767113768113769113770113771113772113773113774113775113776113777113778113779113780113781113782113783113784113785113786113787113788113789113790113791113792113793113794113795113796113797113798113799113800113801113802113803113804113805113806113807113808113809113810113811113812113813113814113815113816113817113818113819113820113821113822113823113824113825113826113827113828113829113830113831113832113833113834113835113836113837113838113839113840113841113842113843113844113845113846113847113848113849113850113851113852113853113854113855113856113857113858113859113860113861113862113863113864113865113866113867113868113869113870113871113872113873113874113875113876113877113878113879113880113881113882113883113884113885113886113887113888113889113890113891113892113893113894113895113896113897113898113899113900113901113902113903113904113905113906113907113908113909113910113911113912113913113914113915113916113917113918113919113920113921113922113923113924113925113926113927113928113929113930113931113932113933113934113935113936113937113938113939113940113941113942113943113944113945113946113947113948113949113950113951113952113953113954113955113956113957113958113959113960113961113962113963113964113965113966113967113968113969113970113971113972113973113974113975113976113977113978113979113980113981113982113983113984113985113986113987113988113989113990113991113992113993113994113995113996113997113998113999114000114001114002114003114004114005114006114007114008114009114010114011114012114013114014114015114016114017114018114019114020114021114022114023114024114025114026114027114028114029114030114031114032114033114034114035114036114037114038114039114040114041114042114043114044114045114046114047114048114049114050114051114052114053114054114055114056114057114058114059114060114061114062114063114064114065114066114067114068114069114070114071114072114073114074114075114076114077114078114079114080114081114082114083114084114085114086114087114088114089114090114091114092114093114094114095114096114097114098114099114100114101114102114103114104114105114106114107114108114109114110114111114112114113114114114115114116114117114118114119114120114121114122114123114124114125114126114127114128114129114130114131114132114133114134114135114136114137114138114139114140114141114142114143114144114145114146114147114148114149114150114151114152114153114154114155114156114157114158114159114160114161114162114163114164114165114166114167114168114169114170114171114172114173114174114175114176114177114178114179114180114181114182114183114184114185114186114187114188114189114190114191114192114193114194114195114196114197114198114199114200114201114202114203114204114205114206114207114208114209114210114211114212114213114214114215114216114217114218114219114220114221114222114223114224114225114226114227114228114229114230114231114232114233114234114235114236114237114238114239114240114241114242114243114244114245114246114247114248114249114250114251114252114253114254114255114256114257114258114259114260114261114262114263114264114265114266114267114268114269114270114271114272114273114274114275114276114277114278114279114280114281114282114283114284114285114286114287114288114289114290114291114292114293114294114295114296114297114298114299114300114301114302114303114304114305114306114307114308114309114310114311114312114313114314114315114316114317114318114319114320114321114322114323114324114325114326114327114328114329114330114331114332114333114334114335114336114337114338114339114340114341114342114343114344114345114346114347114348114349114350114351114352114353114354114355114356114357114358114359114360114361114362114363114364114365
  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. export function serializeAsMatrix(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30519. /**
  30520. * Decorator used to define property that can be serialized as reference to a camera
  30521. * @param sourceName defines the name of the property to decorate
  30522. */
  30523. export function serializeAsCameraReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30524. /**
  30525. * Class used to help serialization objects
  30526. */
  30527. export class SerializationHelper {
  30528. /** hidden */
  30529. static _ImageProcessingConfigurationParser: (sourceProperty: any) => import("babylonjs/Materials/imageProcessingConfiguration").ImageProcessingConfiguration;
  30530. /** hidden */
  30531. static _FresnelParametersParser: (sourceProperty: any) => import("babylonjs/Materials/fresnelParameters").FresnelParameters;
  30532. /** hidden */
  30533. static _ColorCurvesParser: (sourceProperty: any) => import("babylonjs/Materials/colorCurves").ColorCurves;
  30534. /** hidden */
  30535. static _TextureParser: (sourceProperty: any, scene: import("babylonjs/scene").Scene, rootUrl: string) => Nullable<import("babylonjs/Materials/Textures/baseTexture").BaseTexture>;
  30536. /**
  30537. * Appends the serialized animations from the source animations
  30538. * @param source Source containing the animations
  30539. * @param destination Target to store the animations
  30540. */
  30541. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  30542. /**
  30543. * Static function used to serialized a specific entity
  30544. * @param entity defines the entity to serialize
  30545. * @param serializationObject defines the optional target obecjt where serialization data will be stored
  30546. * @returns a JSON compatible object representing the serialization of the entity
  30547. */
  30548. static Serialize<T>(entity: T, serializationObject?: any): any;
  30549. /**
  30550. * Creates a new entity from a serialization data object
  30551. * @param creationFunction defines a function used to instanciated the new entity
  30552. * @param source defines the source serialization data
  30553. * @param scene defines the hosting scene
  30554. * @param rootUrl defines the root url for resources
  30555. * @returns a new entity
  30556. */
  30557. static Parse<T>(creationFunction: () => T, source: any, scene: Nullable<Scene>, rootUrl?: Nullable<string>): T;
  30558. /**
  30559. * Clones an object
  30560. * @param creationFunction defines the function used to instanciate the new object
  30561. * @param source defines the source object
  30562. * @returns the cloned object
  30563. */
  30564. static Clone<T>(creationFunction: () => T, source: T): T;
  30565. /**
  30566. * Instanciates a new object based on a source one (some data will be shared between both object)
  30567. * @param creationFunction defines the function used to instanciate the new object
  30568. * @param source defines the source object
  30569. * @returns the new object
  30570. */
  30571. static Instanciate<T>(creationFunction: () => T, source: T): T;
  30572. }
  30573. }
  30574. declare module "babylonjs/Cameras/camera" {
  30575. import { SmartArray } from "babylonjs/Misc/smartArray";
  30576. import { Observable } from "babylonjs/Misc/observable";
  30577. import { Nullable } from "babylonjs/types";
  30578. import { CameraInputsManager } from "babylonjs/Cameras/cameraInputsManager";
  30579. import { Scene } from "babylonjs/scene";
  30580. import { Matrix, Vector3, Viewport } from "babylonjs/Maths/math";
  30581. import { Node } from "babylonjs/node";
  30582. import { Mesh } from "babylonjs/Meshes/mesh";
  30583. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  30584. import { ICullable } from "babylonjs/Culling/boundingInfo";
  30585. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  30586. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  30587. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  30588. import { Ray } from "babylonjs/Culling/ray";
  30589. /**
  30590. * This is the base class of all the camera used in the application.
  30591. * @see http://doc.babylonjs.com/features/cameras
  30592. */
  30593. export class Camera extends Node {
  30594. /** @hidden */
  30595. static _createDefaultParsedCamera: (name: string, scene: Scene) => Camera;
  30596. /**
  30597. * This is the default projection mode used by the cameras.
  30598. * It helps recreating a feeling of perspective and better appreciate depth.
  30599. * This is the best way to simulate real life cameras.
  30600. */
  30601. static readonly PERSPECTIVE_CAMERA: number;
  30602. /**
  30603. * This helps creating camera with an orthographic mode.
  30604. * 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.
  30605. */
  30606. static readonly ORTHOGRAPHIC_CAMERA: number;
  30607. /**
  30608. * This is the default FOV mode for perspective cameras.
  30609. * This setting aligns the upper and lower bounds of the viewport to the upper and lower bounds of the camera frustum.
  30610. */
  30611. static readonly FOVMODE_VERTICAL_FIXED: number;
  30612. /**
  30613. * This setting aligns the left and right bounds of the viewport to the left and right bounds of the camera frustum.
  30614. */
  30615. static readonly FOVMODE_HORIZONTAL_FIXED: number;
  30616. /**
  30617. * This specifies ther is no need for a camera rig.
  30618. * Basically only one eye is rendered corresponding to the camera.
  30619. */
  30620. static readonly RIG_MODE_NONE: number;
  30621. /**
  30622. * Simulates a camera Rig with one blue eye and one red eye.
  30623. * This can be use with 3d blue and red glasses.
  30624. */
  30625. static readonly RIG_MODE_STEREOSCOPIC_ANAGLYPH: number;
  30626. /**
  30627. * Defines that both eyes of the camera will be rendered side by side with a parallel target.
  30628. */
  30629. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_PARALLEL: number;
  30630. /**
  30631. * Defines that both eyes of the camera will be rendered side by side with a none parallel target.
  30632. */
  30633. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_CROSSEYED: number;
  30634. /**
  30635. * Defines that both eyes of the camera will be rendered over under each other.
  30636. */
  30637. static readonly RIG_MODE_STEREOSCOPIC_OVERUNDER: number;
  30638. /**
  30639. * Defines that both eyes of the camera should be renderered in a VR mode (carbox).
  30640. */
  30641. static readonly RIG_MODE_VR: number;
  30642. /**
  30643. * Defines that both eyes of the camera should be renderered in a VR mode (webVR).
  30644. */
  30645. static readonly RIG_MODE_WEBVR: number;
  30646. /**
  30647. * Custom rig mode allowing rig cameras to be populated manually with any number of cameras
  30648. */
  30649. static readonly RIG_MODE_CUSTOM: number;
  30650. /**
  30651. * Defines if by default attaching controls should prevent the default javascript event to continue.
  30652. */
  30653. static ForceAttachControlToAlwaysPreventDefault: boolean;
  30654. /**
  30655. * @hidden
  30656. * Might be removed once multiview will be a thing
  30657. */
  30658. static UseAlternateWebVRRendering: boolean;
  30659. /**
  30660. * Define the input manager associated with the camera.
  30661. */
  30662. inputs: CameraInputsManager<Camera>;
  30663. /** @hidden */
  30664. _position: Vector3;
  30665. /**
  30666. * Define the current local position of the camera in the scene
  30667. */
  30668. position: Vector3;
  30669. /**
  30670. * The vector the camera should consider as up.
  30671. * (default is Vector3(0, 1, 0) aka Vector3.Up())
  30672. */
  30673. upVector: Vector3;
  30674. /**
  30675. * Define the current limit on the left side for an orthographic camera
  30676. * In scene unit
  30677. */
  30678. orthoLeft: Nullable<number>;
  30679. /**
  30680. * Define the current limit on the right side for an orthographic camera
  30681. * In scene unit
  30682. */
  30683. orthoRight: Nullable<number>;
  30684. /**
  30685. * Define the current limit on the bottom side for an orthographic camera
  30686. * In scene unit
  30687. */
  30688. orthoBottom: Nullable<number>;
  30689. /**
  30690. * Define the current limit on the top side for an orthographic camera
  30691. * In scene unit
  30692. */
  30693. orthoTop: Nullable<number>;
  30694. /**
  30695. * Field Of View is set in Radians. (default is 0.8)
  30696. */
  30697. fov: number;
  30698. /**
  30699. * Define the minimum distance the camera can see from.
  30700. * This is important to note that the depth buffer are not infinite and the closer it starts
  30701. * the more your scene might encounter depth fighting issue.
  30702. */
  30703. minZ: number;
  30704. /**
  30705. * Define the maximum distance the camera can see to.
  30706. * This is important to note that the depth buffer are not infinite and the further it end
  30707. * the more your scene might encounter depth fighting issue.
  30708. */
  30709. maxZ: number;
  30710. /**
  30711. * Define the default inertia of the camera.
  30712. * This helps giving a smooth feeling to the camera movement.
  30713. */
  30714. inertia: number;
  30715. /**
  30716. * Define the mode of the camera (Camera.PERSPECTIVE_CAMERA or Camera.PERSPECTIVE_ORTHOGRAPHIC)
  30717. */
  30718. mode: number;
  30719. /**
  30720. * Define wether the camera is intermediate.
  30721. * This is useful to not present the output directly to the screen in case of rig without post process for instance
  30722. */
  30723. isIntermediate: boolean;
  30724. /**
  30725. * Define the viewport of the camera.
  30726. * This correspond to the portion of the screen the camera will render to in normalized 0 to 1 unit.
  30727. */
  30728. viewport: Viewport;
  30729. /**
  30730. * Restricts the camera to viewing objects with the same layerMask.
  30731. * A camera with a layerMask of 1 will render mesh.layerMask & camera.layerMask!== 0
  30732. */
  30733. layerMask: number;
  30734. /**
  30735. * fovMode sets the camera frustum bounds to the viewport bounds. (default is FOVMODE_VERTICAL_FIXED)
  30736. */
  30737. fovMode: number;
  30738. /**
  30739. * Rig mode of the camera.
  30740. * This is useful to create the camera with two "eyes" instead of one to create VR or stereoscopic scenes.
  30741. * This is normally controlled byt the camera themselves as internal use.
  30742. */
  30743. cameraRigMode: number;
  30744. /**
  30745. * Defines the distance between both "eyes" in case of a RIG
  30746. */
  30747. interaxialDistance: number;
  30748. /**
  30749. * Defines if stereoscopic rendering is done side by side or over under.
  30750. */
  30751. isStereoscopicSideBySide: boolean;
  30752. /**
  30753. * 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
  30754. * This is pretty helpfull if you wish to make a camera render to a texture you could reuse somewhere
  30755. * else in the scene.
  30756. */
  30757. customRenderTargets: import("babylonjs/Materials/Textures/renderTargetTexture").RenderTargetTexture[];
  30758. /**
  30759. * When set, the camera will render to this render target instead of the default canvas
  30760. */
  30761. outputRenderTarget: Nullable<RenderTargetTexture>;
  30762. /**
  30763. * Observable triggered when the camera view matrix has changed.
  30764. */
  30765. onViewMatrixChangedObservable: Observable<Camera>;
  30766. /**
  30767. * Observable triggered when the camera Projection matrix has changed.
  30768. */
  30769. onProjectionMatrixChangedObservable: Observable<Camera>;
  30770. /**
  30771. * Observable triggered when the inputs have been processed.
  30772. */
  30773. onAfterCheckInputsObservable: Observable<Camera>;
  30774. /**
  30775. * Observable triggered when reset has been called and applied to the camera.
  30776. */
  30777. onRestoreStateObservable: Observable<Camera>;
  30778. /** @hidden */
  30779. _cameraRigParams: any;
  30780. /** @hidden */
  30781. _rigCameras: Camera[];
  30782. /** @hidden */
  30783. _rigPostProcess: Nullable<PostProcess>;
  30784. protected _webvrViewMatrix: Matrix;
  30785. /** @hidden */
  30786. _skipRendering: boolean;
  30787. /** @hidden */
  30788. _alternateCamera: Camera;
  30789. /** @hidden */
  30790. _projectionMatrix: Matrix;
  30791. /** @hidden */
  30792. _postProcesses: Nullable<import("babylonjs/PostProcesses/postProcess").PostProcess>[];
  30793. /** @hidden */
  30794. _activeMeshes: SmartArray<AbstractMesh>;
  30795. protected _globalPosition: Vector3;
  30796. /** hidden */
  30797. _computedViewMatrix: Matrix;
  30798. private _doNotComputeProjectionMatrix;
  30799. private _transformMatrix;
  30800. private _frustumPlanes;
  30801. private _refreshFrustumPlanes;
  30802. private _storedFov;
  30803. private _stateStored;
  30804. /**
  30805. * Instantiates a new camera object.
  30806. * This should not be used directly but through the inherited cameras: ArcRotate, Free...
  30807. * @see http://doc.babylonjs.com/features/cameras
  30808. * @param name Defines the name of the camera in the scene
  30809. * @param position Defines the position of the camera
  30810. * @param scene Defines the scene the camera belongs too
  30811. * @param setActiveOnSceneIfNoneActive Defines if the camera should be set as active after creation if no other camera have been defined in the scene
  30812. */
  30813. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  30814. /**
  30815. * Store current camera state (fov, position, etc..)
  30816. * @returns the camera
  30817. */
  30818. storeState(): Camera;
  30819. /**
  30820. * Restores the camera state values if it has been stored. You must call storeState() first
  30821. */
  30822. protected _restoreStateValues(): boolean;
  30823. /**
  30824. * Restored camera state. You must call storeState() first.
  30825. * @returns true if restored and false otherwise
  30826. */
  30827. restoreState(): boolean;
  30828. /**
  30829. * Gets the class name of the camera.
  30830. * @returns the class name
  30831. */
  30832. getClassName(): string;
  30833. /** @hidden */
  30834. readonly _isCamera: boolean;
  30835. /**
  30836. * Gets a string representation of the camera useful for debug purpose.
  30837. * @param fullDetails Defines that a more verboe level of logging is required
  30838. * @returns the string representation
  30839. */
  30840. toString(fullDetails?: boolean): string;
  30841. /**
  30842. * Gets the current world space position of the camera.
  30843. */
  30844. readonly globalPosition: Vector3;
  30845. /**
  30846. * Gets the list of active meshes this frame (meshes no culled or excluded by lod s in the frame)
  30847. * @returns the active meshe list
  30848. */
  30849. getActiveMeshes(): SmartArray<AbstractMesh>;
  30850. /**
  30851. * Check wether a mesh is part of the current active mesh list of the camera
  30852. * @param mesh Defines the mesh to check
  30853. * @returns true if active, false otherwise
  30854. */
  30855. isActiveMesh(mesh: Mesh): boolean;
  30856. /**
  30857. * Is this camera ready to be used/rendered
  30858. * @param completeCheck defines if a complete check (including post processes) has to be done (false by default)
  30859. * @return true if the camera is ready
  30860. */
  30861. isReady(completeCheck?: boolean): boolean;
  30862. /** @hidden */
  30863. _initCache(): void;
  30864. /** @hidden */
  30865. _updateCache(ignoreParentClass?: boolean): void;
  30866. /** @hidden */
  30867. _isSynchronized(): boolean;
  30868. /** @hidden */
  30869. _isSynchronizedViewMatrix(): boolean;
  30870. /** @hidden */
  30871. _isSynchronizedProjectionMatrix(): boolean;
  30872. /**
  30873. * Attach the input controls to a specific dom element to get the input from.
  30874. * @param element Defines the element the controls should be listened from
  30875. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  30876. */
  30877. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  30878. /**
  30879. * Detach the current controls from the specified dom element.
  30880. * @param element Defines the element to stop listening the inputs from
  30881. */
  30882. detachControl(element: HTMLElement): void;
  30883. /**
  30884. * Update the camera state according to the different inputs gathered during the frame.
  30885. */
  30886. update(): void;
  30887. /** @hidden */
  30888. _checkInputs(): void;
  30889. /** @hidden */
  30890. readonly rigCameras: Camera[];
  30891. /**
  30892. * Gets the post process used by the rig cameras
  30893. */
  30894. readonly rigPostProcess: Nullable<PostProcess>;
  30895. /**
  30896. * Internal, gets the first post proces.
  30897. * @returns the first post process to be run on this camera.
  30898. */
  30899. _getFirstPostProcess(): Nullable<PostProcess>;
  30900. private _cascadePostProcessesToRigCams;
  30901. /**
  30902. * Attach a post process to the camera.
  30903. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  30904. * @param postProcess The post process to attach to the camera
  30905. * @param insertAt The position of the post process in case several of them are in use in the scene
  30906. * @returns the position the post process has been inserted at
  30907. */
  30908. attachPostProcess(postProcess: PostProcess, insertAt?: Nullable<number>): number;
  30909. /**
  30910. * Detach a post process to the camera.
  30911. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  30912. * @param postProcess The post process to detach from the camera
  30913. */
  30914. detachPostProcess(postProcess: PostProcess): void;
  30915. /**
  30916. * Gets the current world matrix of the camera
  30917. */
  30918. getWorldMatrix(): Matrix;
  30919. /** @hidden */
  30920. _getViewMatrix(): Matrix;
  30921. /**
  30922. * Gets the current view matrix of the camera.
  30923. * @param force forces the camera to recompute the matrix without looking at the cached state
  30924. * @returns the view matrix
  30925. */
  30926. getViewMatrix(force?: boolean): Matrix;
  30927. /**
  30928. * Freeze the projection matrix.
  30929. * It will prevent the cache check of the camera projection compute and can speed up perf
  30930. * if no parameter of the camera are meant to change
  30931. * @param projection Defines manually a projection if necessary
  30932. */
  30933. freezeProjectionMatrix(projection?: Matrix): void;
  30934. /**
  30935. * Unfreeze the projection matrix if it has previously been freezed by freezeProjectionMatrix.
  30936. */
  30937. unfreezeProjectionMatrix(): void;
  30938. /**
  30939. * Gets the current projection matrix of the camera.
  30940. * @param force forces the camera to recompute the matrix without looking at the cached state
  30941. * @returns the projection matrix
  30942. */
  30943. getProjectionMatrix(force?: boolean): Matrix;
  30944. /**
  30945. * Gets the transformation matrix (ie. the multiplication of view by projection matrices)
  30946. * @returns a Matrix
  30947. */
  30948. getTransformationMatrix(): Matrix;
  30949. private _updateFrustumPlanes;
  30950. /**
  30951. * Checks if a cullable object (mesh...) is in the camera frustum
  30952. * This checks the bounding box center. See isCompletelyInFrustum for a full bounding check
  30953. * @param target The object to check
  30954. * @returns true if the object is in frustum otherwise false
  30955. */
  30956. isInFrustum(target: ICullable): boolean;
  30957. /**
  30958. * Checks if a cullable object (mesh...) is in the camera frustum
  30959. * Unlike isInFrustum this cheks the full bounding box
  30960. * @param target The object to check
  30961. * @returns true if the object is in frustum otherwise false
  30962. */
  30963. isCompletelyInFrustum(target: ICullable): boolean;
  30964. /**
  30965. * Gets a ray in the forward direction from the camera.
  30966. * @param length Defines the length of the ray to create
  30967. * @param transform Defines the transform to apply to the ray, by default the world matrx is used to create a workd space ray
  30968. * @param origin Defines the start point of the ray which defaults to the camera position
  30969. * @returns the forward ray
  30970. */
  30971. getForwardRay(length?: number, transform?: Matrix, origin?: Vector3): Ray;
  30972. /**
  30973. * Releases resources associated with this node.
  30974. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  30975. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  30976. */
  30977. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  30978. /** @hidden */
  30979. _isLeftCamera: boolean;
  30980. /**
  30981. * Gets the left camera of a rig setup in case of Rigged Camera
  30982. */
  30983. readonly isLeftCamera: boolean;
  30984. /** @hidden */
  30985. _isRightCamera: boolean;
  30986. /**
  30987. * Gets the right camera of a rig setup in case of Rigged Camera
  30988. */
  30989. readonly isRightCamera: boolean;
  30990. /**
  30991. * Gets the left camera of a rig setup in case of Rigged Camera
  30992. */
  30993. readonly leftCamera: Nullable<FreeCamera>;
  30994. /**
  30995. * Gets the right camera of a rig setup in case of Rigged Camera
  30996. */
  30997. readonly rightCamera: Nullable<FreeCamera>;
  30998. /**
  30999. * Gets the left camera target of a rig setup in case of Rigged Camera
  31000. * @returns the target position
  31001. */
  31002. getLeftTarget(): Nullable<Vector3>;
  31003. /**
  31004. * Gets the right camera target of a rig setup in case of Rigged Camera
  31005. * @returns the target position
  31006. */
  31007. getRightTarget(): Nullable<Vector3>;
  31008. /**
  31009. * @hidden
  31010. */
  31011. setCameraRigMode(mode: number, rigParams: any): void;
  31012. /** @hidden */
  31013. static _setStereoscopicRigMode(camera: Camera): void;
  31014. /** @hidden */
  31015. static _setStereoscopicAnaglyphRigMode(camera: Camera): void;
  31016. /** @hidden */
  31017. static _setVRRigMode(camera: Camera, rigParams: any): void;
  31018. /** @hidden */
  31019. static _setWebVRRigMode(camera: Camera, rigParams: any): void;
  31020. /** @hidden */
  31021. _getVRProjectionMatrix(): Matrix;
  31022. protected _updateCameraRotationMatrix(): void;
  31023. protected _updateWebVRCameraRotationMatrix(): void;
  31024. /**
  31025. * This function MUST be overwritten by the different WebVR cameras available.
  31026. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  31027. * @hidden
  31028. */
  31029. _getWebVRProjectionMatrix(): Matrix;
  31030. /**
  31031. * This function MUST be overwritten by the different WebVR cameras available.
  31032. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  31033. * @hidden
  31034. */
  31035. _getWebVRViewMatrix(): Matrix;
  31036. /** @hidden */
  31037. setCameraRigParameter(name: string, value: any): void;
  31038. /**
  31039. * needs to be overridden by children so sub has required properties to be copied
  31040. * @hidden
  31041. */
  31042. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  31043. /**
  31044. * May need to be overridden by children
  31045. * @hidden
  31046. */
  31047. _updateRigCameras(): void;
  31048. /** @hidden */
  31049. _setupInputs(): void;
  31050. /**
  31051. * Serialiaze the camera setup to a json represention
  31052. * @returns the JSON representation
  31053. */
  31054. serialize(): any;
  31055. /**
  31056. * Clones the current camera.
  31057. * @param name The cloned camera name
  31058. * @returns the cloned camera
  31059. */
  31060. clone(name: string): Camera;
  31061. /**
  31062. * Gets the direction of the camera relative to a given local axis.
  31063. * @param localAxis Defines the reference axis to provide a relative direction.
  31064. * @return the direction
  31065. */
  31066. getDirection(localAxis: Vector3): Vector3;
  31067. /**
  31068. * Gets the direction of the camera relative to a given local axis into a passed vector.
  31069. * @param localAxis Defines the reference axis to provide a relative direction.
  31070. * @param result Defines the vector to store the result in
  31071. */
  31072. getDirectionToRef(localAxis: Vector3, result: Vector3): void;
  31073. /**
  31074. * Gets a camera constructor for a given camera type
  31075. * @param type The type of the camera to construct (should be equal to one of the camera class name)
  31076. * @param name The name of the camera the result will be able to instantiate
  31077. * @param scene The scene the result will construct the camera in
  31078. * @param interaxial_distance In case of stereoscopic setup, the distance between both eyes
  31079. * @param isStereoscopicSideBySide In case of stereoscopic setup, should the sereo be side b side
  31080. * @returns a factory method to construc the camera
  31081. */
  31082. static GetConstructorFromName(type: string, name: string, scene: Scene, interaxial_distance?: number, isStereoscopicSideBySide?: boolean): () => Camera;
  31083. /**
  31084. * Compute the world matrix of the camera.
  31085. * @returns the camera workd matrix
  31086. */
  31087. computeWorldMatrix(): Matrix;
  31088. /**
  31089. * Parse a JSON and creates the camera from the parsed information
  31090. * @param parsedCamera The JSON to parse
  31091. * @param scene The scene to instantiate the camera in
  31092. * @returns the newly constructed camera
  31093. */
  31094. static Parse(parsedCamera: any, scene: Scene): Camera;
  31095. }
  31096. }
  31097. declare module "babylonjs/Misc/tools" {
  31098. import { FloatArray, IndicesArray, Nullable } from "babylonjs/types";
  31099. import { Color4, Color3, Vector2, Vector3 } from "babylonjs/Maths/math";
  31100. import { IOfflineProvider } from "babylonjs/Offline/IOfflineProvider";
  31101. import { Observable } from "babylonjs/Misc/observable";
  31102. import { DomManagement } from "babylonjs/Misc/domManagement";
  31103. import { WebRequest } from "babylonjs/Misc/webRequest";
  31104. import { Camera } from "babylonjs/Cameras/camera";
  31105. import { Engine } from "babylonjs/Engines/engine";
  31106. import { Animation } from "babylonjs/Animations/animation";
  31107. /**
  31108. * Interface for any object that can request an animation frame
  31109. */
  31110. export interface ICustomAnimationFrameRequester {
  31111. /**
  31112. * This function will be called when the render loop is ready. If this is not populated, the engine's renderloop function will be called
  31113. */
  31114. renderFunction?: Function;
  31115. /**
  31116. * Called to request the next frame to render to
  31117. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame
  31118. */
  31119. requestAnimationFrame: Function;
  31120. /**
  31121. * You can pass this value to cancelAnimationFrame() to cancel the refresh callback request
  31122. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame#Return_value
  31123. */
  31124. requestID?: number;
  31125. }
  31126. /**
  31127. * Interface containing an array of animations
  31128. */
  31129. export interface IAnimatable {
  31130. /**
  31131. * Array of animations
  31132. */
  31133. animations: Array<Animation>;
  31134. }
  31135. /** Interface used by value gradients (color, factor, ...) */
  31136. export interface IValueGradient {
  31137. /**
  31138. * Gets or sets the gradient value (between 0 and 1)
  31139. */
  31140. gradient: number;
  31141. }
  31142. /** Class used to store color4 gradient */
  31143. export class ColorGradient implements IValueGradient {
  31144. /**
  31145. * Gets or sets the gradient value (between 0 and 1)
  31146. */
  31147. gradient: number;
  31148. /**
  31149. * Gets or sets first associated color
  31150. */
  31151. color1: Color4;
  31152. /**
  31153. * Gets or sets second associated color
  31154. */
  31155. color2?: Color4;
  31156. /**
  31157. * Will get a color picked randomly between color1 and color2.
  31158. * If color2 is undefined then color1 will be used
  31159. * @param result defines the target Color4 to store the result in
  31160. */
  31161. getColorToRef(result: Color4): void;
  31162. }
  31163. /** Class used to store color 3 gradient */
  31164. export class Color3Gradient implements IValueGradient {
  31165. /**
  31166. * Gets or sets the gradient value (between 0 and 1)
  31167. */
  31168. gradient: number;
  31169. /**
  31170. * Gets or sets the associated color
  31171. */
  31172. color: Color3;
  31173. }
  31174. /** Class used to store factor gradient */
  31175. export class FactorGradient implements IValueGradient {
  31176. /**
  31177. * Gets or sets the gradient value (between 0 and 1)
  31178. */
  31179. gradient: number;
  31180. /**
  31181. * Gets or sets first associated factor
  31182. */
  31183. factor1: number;
  31184. /**
  31185. * Gets or sets second associated factor
  31186. */
  31187. factor2?: number;
  31188. /**
  31189. * Will get a number picked randomly between factor1 and factor2.
  31190. * If factor2 is undefined then factor1 will be used
  31191. * @returns the picked number
  31192. */
  31193. getFactor(): number;
  31194. }
  31195. /**
  31196. * @ignore
  31197. * Application error to support additional information when loading a file
  31198. */
  31199. export class LoadFileError extends Error {
  31200. /** defines the optional web request */
  31201. request?: WebRequest | undefined;
  31202. private static _setPrototypeOf;
  31203. /**
  31204. * Creates a new LoadFileError
  31205. * @param message defines the message of the error
  31206. * @param request defines the optional web request
  31207. */
  31208. constructor(message: string,
  31209. /** defines the optional web request */
  31210. request?: WebRequest | undefined);
  31211. }
  31212. /**
  31213. * Class used to define a retry strategy when error happens while loading assets
  31214. */
  31215. export class RetryStrategy {
  31216. /**
  31217. * Function used to defines an exponential back off strategy
  31218. * @param maxRetries defines the maximum number of retries (3 by default)
  31219. * @param baseInterval defines the interval between retries
  31220. * @returns the strategy function to use
  31221. */
  31222. static ExponentialBackoff(maxRetries?: number, baseInterval?: number): (url: string, request: WebRequest, retryIndex: number) => number;
  31223. }
  31224. /**
  31225. * File request interface
  31226. */
  31227. export interface IFileRequest {
  31228. /**
  31229. * Raised when the request is complete (success or error).
  31230. */
  31231. onCompleteObservable: Observable<IFileRequest>;
  31232. /**
  31233. * Aborts the request for a file.
  31234. */
  31235. abort: () => void;
  31236. }
  31237. /**
  31238. * Class containing a set of static utilities functions
  31239. */
  31240. export class Tools {
  31241. /**
  31242. * Gets or sets the base URL to use to load assets
  31243. */
  31244. static BaseUrl: string;
  31245. /**
  31246. * Enable/Disable Custom HTTP Request Headers globally.
  31247. * default = false
  31248. * @see CustomRequestHeaders
  31249. */
  31250. static UseCustomRequestHeaders: boolean;
  31251. /**
  31252. * Custom HTTP Request Headers to be sent with XMLHttpRequests
  31253. * i.e. when loading files, where the server/service expects an Authorization header
  31254. */
  31255. static CustomRequestHeaders: {
  31256. [key: string]: string;
  31257. };
  31258. /**
  31259. * Gets or sets the retry strategy to apply when an error happens while loading an asset
  31260. */
  31261. static DefaultRetryStrategy: (url: string, request: WebRequest, retryIndex: number) => number;
  31262. /**
  31263. * Default behaviour for cors in the application.
  31264. * It can be a string if the expected behavior is identical in the entire app.
  31265. * Or a callback to be able to set it per url or on a group of them (in case of Video source for instance)
  31266. */
  31267. static CorsBehavior: string | ((url: string | string[]) => string);
  31268. /**
  31269. * Gets or sets a global variable indicating if fallback texture must be used when a texture cannot be loaded
  31270. * @ignorenaming
  31271. */
  31272. static UseFallbackTexture: boolean;
  31273. /**
  31274. * Use this object to register external classes like custom textures or material
  31275. * to allow the laoders to instantiate them
  31276. */
  31277. static RegisteredExternalClasses: {
  31278. [key: string]: Object;
  31279. };
  31280. /**
  31281. * Texture content used if a texture cannot loaded
  31282. * @ignorenaming
  31283. */
  31284. static fallbackTexture: string;
  31285. /**
  31286. * Read the content of a byte array at a specified coordinates (taking in account wrapping)
  31287. * @param u defines the coordinate on X axis
  31288. * @param v defines the coordinate on Y axis
  31289. * @param width defines the width of the source data
  31290. * @param height defines the height of the source data
  31291. * @param pixels defines the source byte array
  31292. * @param color defines the output color
  31293. */
  31294. static FetchToRef(u: number, v: number, width: number, height: number, pixels: Uint8Array, color: Color4): void;
  31295. /**
  31296. * Interpolates between a and b via alpha
  31297. * @param a The lower value (returned when alpha = 0)
  31298. * @param b The upper value (returned when alpha = 1)
  31299. * @param alpha The interpolation-factor
  31300. * @return The mixed value
  31301. */
  31302. static Mix(a: number, b: number, alpha: number): number;
  31303. /**
  31304. * Tries to instantiate a new object from a given class name
  31305. * @param className defines the class name to instantiate
  31306. * @returns the new object or null if the system was not able to do the instantiation
  31307. */
  31308. static Instantiate(className: string): any;
  31309. /**
  31310. * Provides a slice function that will work even on IE
  31311. * @param data defines the array to slice
  31312. * @param start defines the start of the data (optional)
  31313. * @param end defines the end of the data (optional)
  31314. * @returns the new sliced array
  31315. */
  31316. static Slice<T>(data: T, start?: number, end?: number): T;
  31317. /**
  31318. * Polyfill for setImmediate
  31319. * @param action defines the action to execute after the current execution block
  31320. */
  31321. static SetImmediate(action: () => void): void;
  31322. /**
  31323. * Function indicating if a number is an exponent of 2
  31324. * @param value defines the value to test
  31325. * @returns true if the value is an exponent of 2
  31326. */
  31327. static IsExponentOfTwo(value: number): boolean;
  31328. private static _tmpFloatArray;
  31329. /**
  31330. * Returns the nearest 32-bit single precision float representation of a Number
  31331. * @param value A Number. If the parameter is of a different type, it will get converted
  31332. * to a number or to NaN if it cannot be converted
  31333. * @returns number
  31334. */
  31335. static FloatRound(value: number): number;
  31336. /**
  31337. * Find the next highest power of two.
  31338. * @param x Number to start search from.
  31339. * @return Next highest power of two.
  31340. */
  31341. static CeilingPOT(x: number): number;
  31342. /**
  31343. * Find the next lowest power of two.
  31344. * @param x Number to start search from.
  31345. * @return Next lowest power of two.
  31346. */
  31347. static FloorPOT(x: number): number;
  31348. /**
  31349. * Find the nearest power of two.
  31350. * @param x Number to start search from.
  31351. * @return Next nearest power of two.
  31352. */
  31353. static NearestPOT(x: number): number;
  31354. /**
  31355. * Get the closest exponent of two
  31356. * @param value defines the value to approximate
  31357. * @param max defines the maximum value to return
  31358. * @param mode defines how to define the closest value
  31359. * @returns closest exponent of two of the given value
  31360. */
  31361. static GetExponentOfTwo(value: number, max: number, mode?: number): number;
  31362. /**
  31363. * Extracts the filename from a path
  31364. * @param path defines the path to use
  31365. * @returns the filename
  31366. */
  31367. static GetFilename(path: string): string;
  31368. /**
  31369. * Extracts the "folder" part of a path (everything before the filename).
  31370. * @param uri The URI to extract the info from
  31371. * @param returnUnchangedIfNoSlash Do not touch the URI if no slashes are present
  31372. * @returns The "folder" part of the path
  31373. */
  31374. static GetFolderPath(uri: string, returnUnchangedIfNoSlash?: boolean): string;
  31375. /**
  31376. * Extracts text content from a DOM element hierarchy
  31377. * Back Compat only, please use DomManagement.GetDOMTextContent instead.
  31378. */
  31379. static GetDOMTextContent: typeof DomManagement.GetDOMTextContent;
  31380. /**
  31381. * Convert an angle in radians to degrees
  31382. * @param angle defines the angle to convert
  31383. * @returns the angle in degrees
  31384. */
  31385. static ToDegrees(angle: number): number;
  31386. /**
  31387. * Convert an angle in degrees to radians
  31388. * @param angle defines the angle to convert
  31389. * @returns the angle in radians
  31390. */
  31391. static ToRadians(angle: number): number;
  31392. /**
  31393. * Encode a buffer to a base64 string
  31394. * @param buffer defines the buffer to encode
  31395. * @returns the encoded string
  31396. */
  31397. static EncodeArrayBufferTobase64(buffer: ArrayBuffer): string;
  31398. /**
  31399. * Extracts minimum and maximum values from a list of indexed positions
  31400. * @param positions defines the positions to use
  31401. * @param indices defines the indices to the positions
  31402. * @param indexStart defines the start index
  31403. * @param indexCount defines the end index
  31404. * @param bias defines bias value to add to the result
  31405. * @return minimum and maximum values
  31406. */
  31407. static ExtractMinAndMaxIndexed(positions: FloatArray, indices: IndicesArray, indexStart: number, indexCount: number, bias?: Nullable<Vector2>): {
  31408. minimum: Vector3;
  31409. maximum: Vector3;
  31410. };
  31411. /**
  31412. * Extracts minimum and maximum values from a list of positions
  31413. * @param positions defines the positions to use
  31414. * @param start defines the start index in the positions array
  31415. * @param count defines the number of positions to handle
  31416. * @param bias defines bias value to add to the result
  31417. * @param stride defines the stride size to use (distance between two positions in the positions array)
  31418. * @return minimum and maximum values
  31419. */
  31420. static ExtractMinAndMax(positions: FloatArray, start: number, count: number, bias?: Nullable<Vector2>, stride?: number): {
  31421. minimum: Vector3;
  31422. maximum: Vector3;
  31423. };
  31424. /**
  31425. * Returns an array if obj is not an array
  31426. * @param obj defines the object to evaluate as an array
  31427. * @param allowsNullUndefined defines a boolean indicating if obj is allowed to be null or undefined
  31428. * @returns either obj directly if obj is an array or a new array containing obj
  31429. */
  31430. static MakeArray(obj: any, allowsNullUndefined?: boolean): Nullable<Array<any>>;
  31431. /**
  31432. * Gets the pointer prefix to use
  31433. * @returns "pointer" if touch is enabled. Else returns "mouse"
  31434. */
  31435. static GetPointerPrefix(): string;
  31436. /**
  31437. * Queue a new function into the requested animation frame pool (ie. this function will be executed byt the browser for the next frame)
  31438. * @param func - the function to be called
  31439. * @param requester - the object that will request the next frame. Falls back to window.
  31440. * @returns frame number
  31441. */
  31442. static QueueNewFrame(func: () => void, requester?: any): number;
  31443. /**
  31444. * Ask the browser to promote the current element to fullscreen rendering mode
  31445. * @param element defines the DOM element to promote
  31446. */
  31447. static RequestFullscreen(element: HTMLElement): void;
  31448. /**
  31449. * Asks the browser to exit fullscreen mode
  31450. */
  31451. static ExitFullscreen(): void;
  31452. /**
  31453. * Sets the cors behavior on a dom element. This will add the required Tools.CorsBehavior to the element.
  31454. * @param url define the url we are trying
  31455. * @param element define the dom element where to configure the cors policy
  31456. */
  31457. static SetCorsBehavior(url: string | string[], element: {
  31458. crossOrigin: string | null;
  31459. }): void;
  31460. /**
  31461. * Removes unwanted characters from an url
  31462. * @param url defines the url to clean
  31463. * @returns the cleaned url
  31464. */
  31465. static CleanUrl(url: string): string;
  31466. /**
  31467. * Gets or sets a function used to pre-process url before using them to load assets
  31468. */
  31469. static PreprocessUrl: (url: string) => string;
  31470. /**
  31471. * Loads an image as an HTMLImageElement.
  31472. * @param input url string, ArrayBuffer, or Blob to load
  31473. * @param onLoad callback called when the image successfully loads
  31474. * @param onError callback called when the image fails to load
  31475. * @param offlineProvider offline provider for caching
  31476. * @returns the HTMLImageElement of the loaded image
  31477. */
  31478. static LoadImage(input: string | ArrayBuffer | Blob, onLoad: (img: HTMLImageElement) => void, onError: (message?: string, exception?: any) => void, offlineProvider: Nullable<IOfflineProvider>): HTMLImageElement;
  31479. /**
  31480. * Loads a file
  31481. * @param url url string, ArrayBuffer, or Blob to load
  31482. * @param onSuccess callback called when the file successfully loads
  31483. * @param onProgress callback called while file is loading (if the server supports this mode)
  31484. * @param offlineProvider defines the offline provider for caching
  31485. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  31486. * @param onError callback called when the file fails to load
  31487. * @returns a file request object
  31488. */
  31489. 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;
  31490. /**
  31491. * Load a script (identified by an url). When the url returns, the
  31492. * content of this file is added into a new script element, attached to the DOM (body element)
  31493. * @param scriptUrl defines the url of the script to laod
  31494. * @param onSuccess defines the callback called when the script is loaded
  31495. * @param onError defines the callback to call if an error occurs
  31496. */
  31497. static LoadScript(scriptUrl: string, onSuccess: () => void, onError?: (message?: string, exception?: any) => void): void;
  31498. /**
  31499. * Loads a file from a blob
  31500. * @param fileToLoad defines the blob to use
  31501. * @param callback defines the callback to call when data is loaded
  31502. * @param progressCallback defines the callback to call during loading process
  31503. * @returns a file request object
  31504. */
  31505. static ReadFileAsDataURL(fileToLoad: Blob, callback: (data: any) => void, progressCallback: (ev: ProgressEvent) => any): IFileRequest;
  31506. /**
  31507. * Loads a file
  31508. * @param fileToLoad defines the file to load
  31509. * @param callback defines the callback to call when data is loaded
  31510. * @param progressCallBack defines the callback to call during loading process
  31511. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  31512. * @returns a file request object
  31513. */
  31514. static ReadFile(fileToLoad: File, callback: (data: any) => void, progressCallBack?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean): IFileRequest;
  31515. /**
  31516. * Creates a data url from a given string content
  31517. * @param content defines the content to convert
  31518. * @returns the new data url link
  31519. */
  31520. static FileAsURL(content: string): string;
  31521. /**
  31522. * Format the given number to a specific decimal format
  31523. * @param value defines the number to format
  31524. * @param decimals defines the number of decimals to use
  31525. * @returns the formatted string
  31526. */
  31527. static Format(value: number, decimals?: number): string;
  31528. /**
  31529. * Checks if a given vector is inside a specific range
  31530. * @param v defines the vector to test
  31531. * @param min defines the minimum range
  31532. * @param max defines the maximum range
  31533. */
  31534. static CheckExtends(v: Vector3, min: Vector3, max: Vector3): void;
  31535. /**
  31536. * Tries to copy an object by duplicating every property
  31537. * @param source defines the source object
  31538. * @param destination defines the target object
  31539. * @param doNotCopyList defines a list of properties to avoid
  31540. * @param mustCopyList defines a list of properties to copy (even if they start with _)
  31541. */
  31542. static DeepCopy(source: any, destination: any, doNotCopyList?: string[], mustCopyList?: string[]): void;
  31543. /**
  31544. * Gets a boolean indicating if the given object has no own property
  31545. * @param obj defines the object to test
  31546. * @returns true if object has no own property
  31547. */
  31548. static IsEmpty(obj: any): boolean;
  31549. /**
  31550. * Function used to register events at window level
  31551. * @param events defines the events to register
  31552. */
  31553. static RegisterTopRootEvents(events: {
  31554. name: string;
  31555. handler: Nullable<(e: FocusEvent) => any>;
  31556. }[]): void;
  31557. /**
  31558. * Function used to unregister events from window level
  31559. * @param events defines the events to unregister
  31560. */
  31561. static UnregisterTopRootEvents(events: {
  31562. name: string;
  31563. handler: Nullable<(e: FocusEvent) => any>;
  31564. }[]): void;
  31565. /**
  31566. * @ignore
  31567. */
  31568. static _ScreenshotCanvas: HTMLCanvasElement;
  31569. /**
  31570. * Dumps the current bound framebuffer
  31571. * @param width defines the rendering width
  31572. * @param height defines the rendering height
  31573. * @param engine defines the hosting engine
  31574. * @param successCallback defines the callback triggered once the data are available
  31575. * @param mimeType defines the mime type of the result
  31576. * @param fileName defines the filename to download. If present, the result will automatically be downloaded
  31577. */
  31578. static DumpFramebuffer(width: number, height: number, engine: Engine, successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  31579. /**
  31580. * Converts the canvas data to blob.
  31581. * This acts as a polyfill for browsers not supporting the to blob function.
  31582. * @param canvas Defines the canvas to extract the data from
  31583. * @param successCallback Defines the callback triggered once the data are available
  31584. * @param mimeType Defines the mime type of the result
  31585. */
  31586. static ToBlob(canvas: HTMLCanvasElement, successCallback: (blob: Nullable<Blob>) => void, mimeType?: string): void;
  31587. /**
  31588. * Encodes the canvas data to base 64 or automatically download the result if filename is defined
  31589. * @param successCallback defines the callback triggered once the data are available
  31590. * @param mimeType defines the mime type of the result
  31591. * @param fileName defines he filename to download. If present, the result will automatically be downloaded
  31592. */
  31593. static EncodeScreenshotCanvasData(successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  31594. /**
  31595. * Downloads a blob in the browser
  31596. * @param blob defines the blob to download
  31597. * @param fileName defines the name of the downloaded file
  31598. */
  31599. static Download(blob: Blob, fileName: string): void;
  31600. /**
  31601. * Captures a screenshot of the current rendering
  31602. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  31603. * @param engine defines the rendering engine
  31604. * @param camera defines the source camera
  31605. * @param size This parameter can be set to a single number or to an object with the
  31606. * following (optional) properties: precision, width, height. If a single number is passed,
  31607. * it will be used for both width and height. If an object is passed, the screenshot size
  31608. * will be derived from the parameters. The precision property is a multiplier allowing
  31609. * rendering at a higher or lower resolution
  31610. * @param successCallback defines the callback receives a single parameter which contains the
  31611. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  31612. * src parameter of an <img> to display it
  31613. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  31614. * Check your browser for supported MIME types
  31615. */
  31616. static CreateScreenshot(engine: Engine, camera: Camera, size: any, successCallback?: (data: string) => void, mimeType?: string): void;
  31617. /**
  31618. * Generates an image screenshot from the specified camera.
  31619. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  31620. * @param engine The engine to use for rendering
  31621. * @param camera The camera to use for rendering
  31622. * @param size This parameter can be set to a single number or to an object with the
  31623. * following (optional) properties: precision, width, height. If a single number is passed,
  31624. * it will be used for both width and height. If an object is passed, the screenshot size
  31625. * will be derived from the parameters. The precision property is a multiplier allowing
  31626. * rendering at a higher or lower resolution
  31627. * @param successCallback The callback receives a single parameter which contains the
  31628. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  31629. * src parameter of an <img> to display it
  31630. * @param mimeType The MIME type of the screenshot image (default: image/png).
  31631. * Check your browser for supported MIME types
  31632. * @param samples Texture samples (default: 1)
  31633. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  31634. * @param fileName A name for for the downloaded file.
  31635. */
  31636. static CreateScreenshotUsingRenderTarget(engine: Engine, camera: Camera, size: any, successCallback?: (data: string) => void, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): void;
  31637. /**
  31638. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  31639. * Be aware Math.random() could cause collisions, but:
  31640. * "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"
  31641. * @returns a pseudo random id
  31642. */
  31643. static RandomId(): string;
  31644. /**
  31645. * Test if the given uri is a base64 string
  31646. * @param uri The uri to test
  31647. * @return True if the uri is a base64 string or false otherwise
  31648. */
  31649. static IsBase64(uri: string): boolean;
  31650. /**
  31651. * Decode the given base64 uri.
  31652. * @param uri The uri to decode
  31653. * @return The decoded base64 data.
  31654. */
  31655. static DecodeBase64(uri: string): ArrayBuffer;
  31656. /**
  31657. * No log
  31658. */
  31659. static readonly NoneLogLevel: number;
  31660. /**
  31661. * Only message logs
  31662. */
  31663. static readonly MessageLogLevel: number;
  31664. /**
  31665. * Only warning logs
  31666. */
  31667. static readonly WarningLogLevel: number;
  31668. /**
  31669. * Only error logs
  31670. */
  31671. static readonly ErrorLogLevel: number;
  31672. /**
  31673. * All logs
  31674. */
  31675. static readonly AllLogLevel: number;
  31676. /**
  31677. * Gets a value indicating the number of loading errors
  31678. * @ignorenaming
  31679. */
  31680. static readonly errorsCount: number;
  31681. /**
  31682. * Callback called when a new log is added
  31683. */
  31684. static OnNewCacheEntry: (entry: string) => void;
  31685. /**
  31686. * Log a message to the console
  31687. * @param message defines the message to log
  31688. */
  31689. static Log(message: string): void;
  31690. /**
  31691. * Write a warning message to the console
  31692. * @param message defines the message to log
  31693. */
  31694. static Warn(message: string): void;
  31695. /**
  31696. * Write an error message to the console
  31697. * @param message defines the message to log
  31698. */
  31699. static Error(message: string): void;
  31700. /**
  31701. * Gets current log cache (list of logs)
  31702. */
  31703. static readonly LogCache: string;
  31704. /**
  31705. * Clears the log cache
  31706. */
  31707. static ClearLogCache(): void;
  31708. /**
  31709. * Sets the current log level (MessageLogLevel / WarningLogLevel / ErrorLogLevel)
  31710. */
  31711. static LogLevels: number;
  31712. /**
  31713. * Checks if the loaded document was accessed via `file:`-Protocol.
  31714. * @returns boolean
  31715. */
  31716. static IsFileURL(): boolean;
  31717. /**
  31718. * Checks if the window object exists
  31719. * Back Compat only, please use DomManagement.IsWindowObjectExist instead.
  31720. */
  31721. static IsWindowObjectExist: typeof DomManagement.IsWindowObjectExist;
  31722. /**
  31723. * No performance log
  31724. */
  31725. static readonly PerformanceNoneLogLevel: number;
  31726. /**
  31727. * Use user marks to log performance
  31728. */
  31729. static readonly PerformanceUserMarkLogLevel: number;
  31730. /**
  31731. * Log performance to the console
  31732. */
  31733. static readonly PerformanceConsoleLogLevel: number;
  31734. private static _performance;
  31735. /**
  31736. * Sets the current performance log level
  31737. */
  31738. static PerformanceLogLevel: number;
  31739. private static _StartPerformanceCounterDisabled;
  31740. private static _EndPerformanceCounterDisabled;
  31741. private static _StartUserMark;
  31742. private static _EndUserMark;
  31743. private static _StartPerformanceConsole;
  31744. private static _EndPerformanceConsole;
  31745. /**
  31746. * Starts a performance counter
  31747. */
  31748. static StartPerformanceCounter: (counterName: string, condition?: boolean) => void;
  31749. /**
  31750. * Ends a specific performance coutner
  31751. */
  31752. static EndPerformanceCounter: (counterName: string, condition?: boolean) => void;
  31753. /**
  31754. * Gets either window.performance.now() if supported or Date.now() else
  31755. */
  31756. static readonly Now: number;
  31757. /**
  31758. * This method will return the name of the class used to create the instance of the given object.
  31759. * It will works only on Javascript basic data types (number, string, ...) and instance of class declared with the @className decorator.
  31760. * @param object the object to get the class name from
  31761. * @param isType defines if the object is actually a type
  31762. * @returns the name of the class, will be "object" for a custom data type not using the @className decorator
  31763. */
  31764. static GetClassName(object: any, isType?: boolean): string;
  31765. /**
  31766. * Gets the first element of an array satisfying a given predicate
  31767. * @param array defines the array to browse
  31768. * @param predicate defines the predicate to use
  31769. * @returns null if not found or the element
  31770. */
  31771. static First<T>(array: Array<T>, predicate: (item: T) => boolean): Nullable<T>;
  31772. /**
  31773. * This method will return the name of the full name of the class, including its owning module (if any).
  31774. * 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).
  31775. * @param object the object to get the class name from
  31776. * @param isType defines if the object is actually a type
  31777. * @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.
  31778. * @ignorenaming
  31779. */
  31780. static getFullClassName(object: any, isType?: boolean): Nullable<string>;
  31781. /**
  31782. * Returns a promise that resolves after the given amount of time.
  31783. * @param delay Number of milliseconds to delay
  31784. * @returns Promise that resolves after the given amount of time
  31785. */
  31786. static DelayAsync(delay: number): Promise<void>;
  31787. /**
  31788. * Gets the current gradient from an array of IValueGradient
  31789. * @param ratio defines the current ratio to get
  31790. * @param gradients defines the array of IValueGradient
  31791. * @param updateFunc defines the callback function used to get the final value from the selected gradients
  31792. */
  31793. static GetCurrentGradient(ratio: number, gradients: IValueGradient[], updateFunc: (current: IValueGradient, next: IValueGradient, scale: number) => void): void;
  31794. }
  31795. /**
  31796. * This class is used to track a performance counter which is number based.
  31797. * The user has access to many properties which give statistics of different nature.
  31798. *
  31799. * The implementer can track two kinds of Performance Counter: time and count.
  31800. * 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.
  31801. * 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.
  31802. */
  31803. export class PerfCounter {
  31804. /**
  31805. * Gets or sets a global boolean to turn on and off all the counters
  31806. */
  31807. static Enabled: boolean;
  31808. /**
  31809. * Returns the smallest value ever
  31810. */
  31811. readonly min: number;
  31812. /**
  31813. * Returns the biggest value ever
  31814. */
  31815. readonly max: number;
  31816. /**
  31817. * Returns the average value since the performance counter is running
  31818. */
  31819. readonly average: number;
  31820. /**
  31821. * Returns the average value of the last second the counter was monitored
  31822. */
  31823. readonly lastSecAverage: number;
  31824. /**
  31825. * Returns the current value
  31826. */
  31827. readonly current: number;
  31828. /**
  31829. * Gets the accumulated total
  31830. */
  31831. readonly total: number;
  31832. /**
  31833. * Gets the total value count
  31834. */
  31835. readonly count: number;
  31836. /**
  31837. * Creates a new counter
  31838. */
  31839. constructor();
  31840. /**
  31841. * Call this method to start monitoring a new frame.
  31842. * 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.
  31843. */
  31844. fetchNewFrame(): void;
  31845. /**
  31846. * Call this method to monitor a count of something (e.g. mesh drawn in viewport count)
  31847. * @param newCount the count value to add to the monitored count
  31848. * @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.
  31849. */
  31850. addCount(newCount: number, fetchResult: boolean): void;
  31851. /**
  31852. * Start monitoring this performance counter
  31853. */
  31854. beginMonitoring(): void;
  31855. /**
  31856. * Compute the time lapsed since the previous beginMonitoring() call.
  31857. * @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
  31858. */
  31859. endMonitoring(newFrame?: boolean): void;
  31860. private _fetchResult;
  31861. private _startMonitoringTime;
  31862. private _min;
  31863. private _max;
  31864. private _average;
  31865. private _current;
  31866. private _totalValueCount;
  31867. private _totalAccumulated;
  31868. private _lastSecAverage;
  31869. private _lastSecAccumulated;
  31870. private _lastSecTime;
  31871. private _lastSecValueCount;
  31872. }
  31873. /**
  31874. * Use this className as a decorator on a given class definition to add it a name and optionally its module.
  31875. * You can then use the Tools.getClassName(obj) on an instance to retrieve its class name.
  31876. * This method is the only way to get it done in all cases, even if the .js file declaring the class is minified
  31877. * @param name The name of the class, case should be preserved
  31878. * @param module The name of the Module hosting the class, optional, but strongly recommended to specify if possible. Case should be preserved.
  31879. */
  31880. export function className(name: string, module?: string): (target: Object) => void;
  31881. /**
  31882. * An implementation of a loop for asynchronous functions.
  31883. */
  31884. export class AsyncLoop {
  31885. /**
  31886. * Defines the number of iterations for the loop
  31887. */
  31888. iterations: number;
  31889. /**
  31890. * Defines the current index of the loop.
  31891. */
  31892. index: number;
  31893. private _done;
  31894. private _fn;
  31895. private _successCallback;
  31896. /**
  31897. * Constructor.
  31898. * @param iterations the number of iterations.
  31899. * @param func the function to run each iteration
  31900. * @param successCallback the callback that will be called upon succesful execution
  31901. * @param offset starting offset.
  31902. */
  31903. constructor(
  31904. /**
  31905. * Defines the number of iterations for the loop
  31906. */
  31907. iterations: number, func: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number);
  31908. /**
  31909. * Execute the next iteration. Must be called after the last iteration was finished.
  31910. */
  31911. executeNext(): void;
  31912. /**
  31913. * Break the loop and run the success callback.
  31914. */
  31915. breakLoop(): void;
  31916. /**
  31917. * Create and run an async loop.
  31918. * @param iterations the number of iterations.
  31919. * @param fn the function to run each iteration
  31920. * @param successCallback the callback that will be called upon succesful execution
  31921. * @param offset starting offset.
  31922. * @returns the created async loop object
  31923. */
  31924. static Run(iterations: number, fn: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number): AsyncLoop;
  31925. /**
  31926. * A for-loop that will run a given number of iterations synchronous and the rest async.
  31927. * @param iterations total number of iterations
  31928. * @param syncedIterations number of synchronous iterations in each async iteration.
  31929. * @param fn the function to call each iteration.
  31930. * @param callback a success call back that will be called when iterating stops.
  31931. * @param breakFunction a break condition (optional)
  31932. * @param timeout timeout settings for the setTimeout function. default - 0.
  31933. * @returns the created async loop object
  31934. */
  31935. static SyncAsyncForLoop(iterations: number, syncedIterations: number, fn: (iteration: number) => void, callback: () => void, breakFunction?: () => boolean, timeout?: number): AsyncLoop;
  31936. }
  31937. }
  31938. declare module "babylonjs/Collisions/collisionCoordinator" {
  31939. import { Nullable } from "babylonjs/types";
  31940. import { Scene } from "babylonjs/scene";
  31941. import { Vector3 } from "babylonjs/Maths/math";
  31942. import { Collider } from "babylonjs/Collisions/collider";
  31943. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  31944. /** @hidden */
  31945. export interface ICollisionCoordinator {
  31946. createCollider(): Collider;
  31947. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: Nullable<AbstractMesh>, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  31948. init(scene: Scene): void;
  31949. }
  31950. /** @hidden */
  31951. export class DefaultCollisionCoordinator implements ICollisionCoordinator {
  31952. private _scene;
  31953. private _scaledPosition;
  31954. private _scaledVelocity;
  31955. private _finalPosition;
  31956. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: AbstractMesh, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  31957. createCollider(): Collider;
  31958. init(scene: Scene): void;
  31959. private _collideWithWorld;
  31960. }
  31961. }
  31962. declare module "babylonjs/Animations/animationGroup" {
  31963. import { Animatable } from "babylonjs/Animations/animatable";
  31964. import { Animation } from "babylonjs/Animations/animation";
  31965. import { Scene, IDisposable } from "babylonjs/scene";
  31966. import { Observable } from "babylonjs/Misc/observable";
  31967. import { Nullable } from "babylonjs/types";
  31968. /**
  31969. * This class defines the direct association between an animation and a target
  31970. */
  31971. export class TargetedAnimation {
  31972. /**
  31973. * Animation to perform
  31974. */
  31975. animation: Animation;
  31976. /**
  31977. * Target to animate
  31978. */
  31979. target: any;
  31980. }
  31981. /**
  31982. * Use this class to create coordinated animations on multiple targets
  31983. */
  31984. export class AnimationGroup implements IDisposable {
  31985. /** The name of the animation group */
  31986. name: string;
  31987. private _scene;
  31988. private _targetedAnimations;
  31989. private _animatables;
  31990. private _from;
  31991. private _to;
  31992. private _isStarted;
  31993. private _isPaused;
  31994. private _speedRatio;
  31995. /**
  31996. * Gets or sets the unique id of the node
  31997. */
  31998. uniqueId: number;
  31999. /**
  32000. * This observable will notify when one animation have ended
  32001. */
  32002. onAnimationEndObservable: Observable<TargetedAnimation>;
  32003. /**
  32004. * Observer raised when one animation loops
  32005. */
  32006. onAnimationLoopObservable: Observable<TargetedAnimation>;
  32007. /**
  32008. * This observable will notify when all animations have ended.
  32009. */
  32010. onAnimationGroupEndObservable: Observable<AnimationGroup>;
  32011. /**
  32012. * This observable will notify when all animations have paused.
  32013. */
  32014. onAnimationGroupPauseObservable: Observable<AnimationGroup>;
  32015. /**
  32016. * This observable will notify when all animations are playing.
  32017. */
  32018. onAnimationGroupPlayObservable: Observable<AnimationGroup>;
  32019. /**
  32020. * Gets the first frame
  32021. */
  32022. readonly from: number;
  32023. /**
  32024. * Gets the last frame
  32025. */
  32026. readonly to: number;
  32027. /**
  32028. * Define if the animations are started
  32029. */
  32030. readonly isStarted: boolean;
  32031. /**
  32032. * Gets a value indicating that the current group is playing
  32033. */
  32034. readonly isPlaying: boolean;
  32035. /**
  32036. * Gets or sets the speed ratio to use for all animations
  32037. */
  32038. /**
  32039. * Gets or sets the speed ratio to use for all animations
  32040. */
  32041. speedRatio: number;
  32042. /**
  32043. * Gets the targeted animations for this animation group
  32044. */
  32045. readonly targetedAnimations: Array<TargetedAnimation>;
  32046. /**
  32047. * returning the list of animatables controlled by this animation group.
  32048. */
  32049. readonly animatables: Array<Animatable>;
  32050. /**
  32051. * Instantiates a new Animation Group.
  32052. * This helps managing several animations at once.
  32053. * @see http://doc.babylonjs.com/how_to/group
  32054. * @param name Defines the name of the group
  32055. * @param scene Defines the scene the group belongs to
  32056. */
  32057. constructor(
  32058. /** The name of the animation group */
  32059. name: string, scene?: Nullable<Scene>);
  32060. /**
  32061. * Add an animation (with its target) in the group
  32062. * @param animation defines the animation we want to add
  32063. * @param target defines the target of the animation
  32064. * @returns the TargetedAnimation object
  32065. */
  32066. addTargetedAnimation(animation: Animation, target: any): TargetedAnimation;
  32067. /**
  32068. * This function will normalize every animation in the group to make sure they all go from beginFrame to endFrame
  32069. * It can add constant keys at begin or end
  32070. * @param beginFrame defines the new begin frame for all animations or the smallest begin frame of all animations if null (defaults to null)
  32071. * @param endFrame defines the new end frame for all animations or the largest end frame of all animations if null (defaults to null)
  32072. * @returns the animation group
  32073. */
  32074. normalize(beginFrame?: Nullable<number>, endFrame?: Nullable<number>): AnimationGroup;
  32075. /**
  32076. * Start all animations on given targets
  32077. * @param loop defines if animations must loop
  32078. * @param speedRatio defines the ratio to apply to animation speed (1 by default)
  32079. * @param from defines the from key (optional)
  32080. * @param to defines the to key (optional)
  32081. * @returns the current animation group
  32082. */
  32083. start(loop?: boolean, speedRatio?: number, from?: number, to?: number): AnimationGroup;
  32084. /**
  32085. * Pause all animations
  32086. * @returns the animation group
  32087. */
  32088. pause(): AnimationGroup;
  32089. /**
  32090. * Play all animations to initial state
  32091. * This function will start() the animations if they were not started or will restart() them if they were paused
  32092. * @param loop defines if animations must loop
  32093. * @returns the animation group
  32094. */
  32095. play(loop?: boolean): AnimationGroup;
  32096. /**
  32097. * Reset all animations to initial state
  32098. * @returns the animation group
  32099. */
  32100. reset(): AnimationGroup;
  32101. /**
  32102. * Restart animations from key 0
  32103. * @returns the animation group
  32104. */
  32105. restart(): AnimationGroup;
  32106. /**
  32107. * Stop all animations
  32108. * @returns the animation group
  32109. */
  32110. stop(): AnimationGroup;
  32111. /**
  32112. * Set animation weight for all animatables
  32113. * @param weight defines the weight to use
  32114. * @return the animationGroup
  32115. * @see http://doc.babylonjs.com/babylon101/animations#animation-weights
  32116. */
  32117. setWeightForAllAnimatables(weight: number): AnimationGroup;
  32118. /**
  32119. * Synchronize and normalize all animatables with a source animatable
  32120. * @param root defines the root animatable to synchronize with
  32121. * @return the animationGroup
  32122. * @see http://doc.babylonjs.com/babylon101/animations#animation-weights
  32123. */
  32124. syncAllAnimationsWith(root: Animatable): AnimationGroup;
  32125. /**
  32126. * Goes to a specific frame in this animation group
  32127. * @param frame the frame number to go to
  32128. * @return the animationGroup
  32129. */
  32130. goToFrame(frame: number): AnimationGroup;
  32131. /**
  32132. * Dispose all associated resources
  32133. */
  32134. dispose(): void;
  32135. private _checkAnimationGroupEnded;
  32136. /**
  32137. * Clone the current animation group and returns a copy
  32138. * @param newName defines the name of the new group
  32139. * @param targetConverter defines an optional function used to convert current animation targets to new ones
  32140. * @returns the new aniamtion group
  32141. */
  32142. clone(newName: string, targetConverter?: (oldTarget: any) => any): AnimationGroup;
  32143. /**
  32144. * Returns a new AnimationGroup object parsed from the source provided.
  32145. * @param parsedAnimationGroup defines the source
  32146. * @param scene defines the scene that will receive the animationGroup
  32147. * @returns a new AnimationGroup
  32148. */
  32149. static Parse(parsedAnimationGroup: any, scene: Scene): AnimationGroup;
  32150. /**
  32151. * Returns the string "AnimationGroup"
  32152. * @returns "AnimationGroup"
  32153. */
  32154. getClassName(): string;
  32155. /**
  32156. * Creates a detailled string about the object
  32157. * @param fullDetails defines if the output string will support multiple levels of logging within scene loading
  32158. * @returns a string representing the object
  32159. */
  32160. toString(fullDetails?: boolean): string;
  32161. }
  32162. }
  32163. declare module "babylonjs/scene" {
  32164. import { Nullable } from "babylonjs/types";
  32165. import { IAnimatable, IFileRequest, PerfCounter } from "babylonjs/Misc/tools";
  32166. import { Observable } from "babylonjs/Misc/observable";
  32167. import { SmartArrayNoDuplicate, SmartArray, ISmartArrayLike } from "babylonjs/Misc/smartArray";
  32168. import { Color4, Color3, Plane, Vector2, Vector3, Matrix } from "babylonjs/Maths/math";
  32169. import { Geometry } from "babylonjs/Meshes/geometry";
  32170. import { TransformNode } from "babylonjs/Meshes/transformNode";
  32171. import { SubMesh } from "babylonjs/Meshes/subMesh";
  32172. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  32173. import { Mesh } from "babylonjs/Meshes/mesh";
  32174. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  32175. import { Bone } from "babylonjs/Bones/bone";
  32176. import { Skeleton } from "babylonjs/Bones/skeleton";
  32177. import { MorphTargetManager } from "babylonjs/Morph/morphTargetManager";
  32178. import { Camera } from "babylonjs/Cameras/camera";
  32179. import { AbstractScene } from "babylonjs/abstractScene";
  32180. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  32181. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  32182. import { Material } from "babylonjs/Materials/material";
  32183. import { ImageProcessingConfiguration } from "babylonjs/Materials/imageProcessingConfiguration";
  32184. import { Effect } from "babylonjs/Materials/effect";
  32185. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  32186. import { MultiMaterial } from "babylonjs/Materials/multiMaterial";
  32187. import { Light } from "babylonjs/Lights/light";
  32188. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  32189. import { ICollisionCoordinator } from "babylonjs/Collisions/collisionCoordinator";
  32190. import { PointerEventTypes, PointerInfoPre, PointerInfo } from "babylonjs/Events/pointerEvents";
  32191. import { KeyboardInfoPre, KeyboardInfo } from "babylonjs/Events/keyboardEvents";
  32192. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  32193. import { PostProcessManager } from "babylonjs/PostProcesses/postProcessManager";
  32194. import { IOfflineProvider } from "babylonjs/Offline/IOfflineProvider";
  32195. import { RenderingGroupInfo, IRenderingManagerAutoClearSetup } from "babylonjs/Rendering/renderingManager";
  32196. import { ISceneComponent, ISceneSerializableComponent, Stage, SimpleStageAction, RenderTargetsStageAction, RenderTargetStageAction, MeshStageAction, EvaluateSubMeshStageAction, ActiveMeshStageAction, CameraStageAction, RenderingGroupStageAction, RenderingMeshStageAction, PointerMoveStageAction, PointerUpDownStageAction } from "babylonjs/sceneComponent";
  32197. import { Engine } from "babylonjs/Engines/engine";
  32198. import { Node } from "babylonjs/node";
  32199. import { MorphTarget } from "babylonjs/Morph/morphTarget";
  32200. import { AbstractActionManager } from "babylonjs/Actions/abstractActionManager";
  32201. import { WebRequest } from "babylonjs/Misc/webRequest";
  32202. import { Ray } from "babylonjs/Culling/ray";
  32203. import { TrianglePickingPredicate } from "babylonjs/Culling/ray";
  32204. import { Animation } from "babylonjs/Animations/animation";
  32205. import { Animatable } from "babylonjs/Animations/animatable";
  32206. import { AnimationGroup } from "babylonjs/Animations/animationGroup";
  32207. import { AnimationPropertiesOverride } from "babylonjs/Animations/animationPropertiesOverride";
  32208. import { Collider } from "babylonjs/Collisions/collider";
  32209. /**
  32210. * Define an interface for all classes that will hold resources
  32211. */
  32212. export interface IDisposable {
  32213. /**
  32214. * Releases all held resources
  32215. */
  32216. dispose(): void;
  32217. }
  32218. /** Interface defining initialization parameters for Scene class */
  32219. export interface SceneOptions {
  32220. /**
  32221. * Defines that scene should keep up-to-date a map of geometry to enable fast look-up by uniqueId
  32222. * It will improve performance when the number of geometries becomes important.
  32223. */
  32224. useGeometryUniqueIdsMap?: boolean;
  32225. /**
  32226. * Defines that each material of the scene should keep up-to-date a map of referencing meshes for fast diposing
  32227. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  32228. */
  32229. useMaterialMeshMap?: boolean;
  32230. /**
  32231. * Defines that each mesh of the scene should keep up-to-date a map of referencing cloned meshes for fast diposing
  32232. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  32233. */
  32234. useClonedMeshhMap?: boolean;
  32235. }
  32236. /**
  32237. * Represents a scene to be rendered by the engine.
  32238. * @see http://doc.babylonjs.com/features/scene
  32239. */
  32240. export class Scene extends AbstractScene implements IAnimatable {
  32241. private static _uniqueIdCounter;
  32242. /** The fog is deactivated */
  32243. static readonly FOGMODE_NONE: number;
  32244. /** The fog density is following an exponential function */
  32245. static readonly FOGMODE_EXP: number;
  32246. /** The fog density is following an exponential function faster than FOGMODE_EXP */
  32247. static readonly FOGMODE_EXP2: number;
  32248. /** The fog density is following a linear function. */
  32249. static readonly FOGMODE_LINEAR: number;
  32250. /**
  32251. * Gets or sets the minimum deltatime when deterministic lock step is enabled
  32252. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  32253. */
  32254. static MinDeltaTime: number;
  32255. /**
  32256. * Gets or sets the maximum deltatime when deterministic lock step is enabled
  32257. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  32258. */
  32259. static MaxDeltaTime: number;
  32260. /**
  32261. * Factory used to create the default material.
  32262. * @param name The name of the material to create
  32263. * @param scene The scene to create the material for
  32264. * @returns The default material
  32265. */
  32266. static DefaultMaterialFactory(scene: Scene): Material;
  32267. /**
  32268. * Factory used to create the a collision coordinator.
  32269. * @returns The collision coordinator
  32270. */
  32271. static CollisionCoordinatorFactory(): ICollisionCoordinator;
  32272. /** @hidden */
  32273. readonly _isScene: boolean;
  32274. /**
  32275. * Gets or sets a boolean that indicates if the scene must clear the render buffer before rendering a frame
  32276. */
  32277. autoClear: boolean;
  32278. /**
  32279. * Gets or sets a boolean that indicates if the scene must clear the depth and stencil buffers before rendering a frame
  32280. */
  32281. autoClearDepthAndStencil: boolean;
  32282. /**
  32283. * Defines the color used to clear the render buffer (Default is (0.2, 0.2, 0.3, 1.0))
  32284. */
  32285. clearColor: Color4;
  32286. /**
  32287. * Defines the color used to simulate the ambient color (Default is (0, 0, 0))
  32288. */
  32289. ambientColor: Color3;
  32290. /** @hidden */
  32291. _environmentBRDFTexture: BaseTexture;
  32292. /** @hidden */
  32293. protected _environmentTexture: Nullable<BaseTexture>;
  32294. /**
  32295. * Texture used in all pbr material as the reflection texture.
  32296. * As in the majority of the scene they are the same (exception for multi room and so on),
  32297. * this is easier to reference from here than from all the materials.
  32298. */
  32299. /**
  32300. * Texture used in all pbr material as the reflection texture.
  32301. * As in the majority of the scene they are the same (exception for multi room and so on),
  32302. * this is easier to set here than in all the materials.
  32303. */
  32304. environmentTexture: Nullable<BaseTexture>;
  32305. /** @hidden */
  32306. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  32307. /**
  32308. * Default image processing configuration used either in the rendering
  32309. * Forward main pass or through the imageProcessingPostProcess if present.
  32310. * As in the majority of the scene they are the same (exception for multi camera),
  32311. * this is easier to reference from here than from all the materials and post process.
  32312. *
  32313. * No setter as we it is a shared configuration, you can set the values instead.
  32314. */
  32315. readonly imageProcessingConfiguration: ImageProcessingConfiguration;
  32316. private _forceWireframe;
  32317. /**
  32318. * Gets or sets a boolean indicating if all rendering must be done in wireframe
  32319. */
  32320. forceWireframe: boolean;
  32321. private _forcePointsCloud;
  32322. /**
  32323. * Gets or sets a boolean indicating if all rendering must be done in point cloud
  32324. */
  32325. forcePointsCloud: boolean;
  32326. /**
  32327. * Gets or sets the active clipplane 1
  32328. */
  32329. clipPlane: Nullable<Plane>;
  32330. /**
  32331. * Gets or sets the active clipplane 2
  32332. */
  32333. clipPlane2: Nullable<Plane>;
  32334. /**
  32335. * Gets or sets the active clipplane 3
  32336. */
  32337. clipPlane3: Nullable<Plane>;
  32338. /**
  32339. * Gets or sets the active clipplane 4
  32340. */
  32341. clipPlane4: Nullable<Plane>;
  32342. /**
  32343. * Gets or sets a boolean indicating if animations are enabled
  32344. */
  32345. animationsEnabled: boolean;
  32346. private _animationPropertiesOverride;
  32347. /**
  32348. * Gets or sets the animation properties override
  32349. */
  32350. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  32351. /**
  32352. * Gets or sets a boolean indicating if a constant deltatime has to be used
  32353. * This is mostly useful for testing purposes when you do not want the animations to scale with the framerate
  32354. */
  32355. useConstantAnimationDeltaTime: boolean;
  32356. /**
  32357. * Gets or sets a boolean indicating if the scene must keep the meshUnderPointer property updated
  32358. * Please note that it requires to run a ray cast through the scene on every frame
  32359. */
  32360. constantlyUpdateMeshUnderPointer: boolean;
  32361. /**
  32362. * Defines the HTML cursor to use when hovering over interactive elements
  32363. */
  32364. hoverCursor: string;
  32365. /**
  32366. * Defines the HTML default cursor to use (empty by default)
  32367. */
  32368. defaultCursor: string;
  32369. /**
  32370. * This is used to call preventDefault() on pointer down
  32371. * in order to block unwanted artifacts like system double clicks
  32372. */
  32373. preventDefaultOnPointerDown: boolean;
  32374. /**
  32375. * This is used to call preventDefault() on pointer up
  32376. * in order to block unwanted artifacts like system double clicks
  32377. */
  32378. preventDefaultOnPointerUp: boolean;
  32379. /**
  32380. * Gets or sets user defined metadata
  32381. */
  32382. metadata: any;
  32383. /**
  32384. * For internal use only. Please do not use.
  32385. */
  32386. reservedDataStore: any;
  32387. /**
  32388. * Gets the name of the plugin used to load this scene (null by default)
  32389. */
  32390. loadingPluginName: string;
  32391. /**
  32392. * Use this array to add regular expressions used to disable offline support for specific urls
  32393. */
  32394. disableOfflineSupportExceptionRules: RegExp[];
  32395. /**
  32396. * An event triggered when the scene is disposed.
  32397. */
  32398. onDisposeObservable: Observable<Scene>;
  32399. private _onDisposeObserver;
  32400. /** Sets a function to be executed when this scene is disposed. */
  32401. onDispose: () => void;
  32402. /**
  32403. * An event triggered before rendering the scene (right after animations and physics)
  32404. */
  32405. onBeforeRenderObservable: Observable<Scene>;
  32406. private _onBeforeRenderObserver;
  32407. /** Sets a function to be executed before rendering this scene */
  32408. beforeRender: Nullable<() => void>;
  32409. /**
  32410. * An event triggered after rendering the scene
  32411. */
  32412. onAfterRenderObservable: Observable<Scene>;
  32413. private _onAfterRenderObserver;
  32414. /** Sets a function to be executed after rendering this scene */
  32415. afterRender: Nullable<() => void>;
  32416. /**
  32417. * An event triggered before animating the scene
  32418. */
  32419. onBeforeAnimationsObservable: Observable<Scene>;
  32420. /**
  32421. * An event triggered after animations processing
  32422. */
  32423. onAfterAnimationsObservable: Observable<Scene>;
  32424. /**
  32425. * An event triggered before draw calls are ready to be sent
  32426. */
  32427. onBeforeDrawPhaseObservable: Observable<Scene>;
  32428. /**
  32429. * An event triggered after draw calls have been sent
  32430. */
  32431. onAfterDrawPhaseObservable: Observable<Scene>;
  32432. /**
  32433. * An event triggered when the scene is ready
  32434. */
  32435. onReadyObservable: Observable<Scene>;
  32436. /**
  32437. * An event triggered before rendering a camera
  32438. */
  32439. onBeforeCameraRenderObservable: Observable<Camera>;
  32440. private _onBeforeCameraRenderObserver;
  32441. /** Sets a function to be executed before rendering a camera*/
  32442. beforeCameraRender: () => void;
  32443. /**
  32444. * An event triggered after rendering a camera
  32445. */
  32446. onAfterCameraRenderObservable: Observable<Camera>;
  32447. private _onAfterCameraRenderObserver;
  32448. /** Sets a function to be executed after rendering a camera*/
  32449. afterCameraRender: () => void;
  32450. /**
  32451. * An event triggered when active meshes evaluation is about to start
  32452. */
  32453. onBeforeActiveMeshesEvaluationObservable: Observable<Scene>;
  32454. /**
  32455. * An event triggered when active meshes evaluation is done
  32456. */
  32457. onAfterActiveMeshesEvaluationObservable: Observable<Scene>;
  32458. /**
  32459. * An event triggered when particles rendering is about to start
  32460. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  32461. */
  32462. onBeforeParticlesRenderingObservable: Observable<Scene>;
  32463. /**
  32464. * An event triggered when particles rendering is done
  32465. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  32466. */
  32467. onAfterParticlesRenderingObservable: Observable<Scene>;
  32468. /**
  32469. * An event triggered when SceneLoader.Append or SceneLoader.Load or SceneLoader.ImportMesh were successfully executed
  32470. */
  32471. onDataLoadedObservable: Observable<Scene>;
  32472. /**
  32473. * An event triggered when a camera is created
  32474. */
  32475. onNewCameraAddedObservable: Observable<Camera>;
  32476. /**
  32477. * An event triggered when a camera is removed
  32478. */
  32479. onCameraRemovedObservable: Observable<Camera>;
  32480. /**
  32481. * An event triggered when a light is created
  32482. */
  32483. onNewLightAddedObservable: Observable<Light>;
  32484. /**
  32485. * An event triggered when a light is removed
  32486. */
  32487. onLightRemovedObservable: Observable<Light>;
  32488. /**
  32489. * An event triggered when a geometry is created
  32490. */
  32491. onNewGeometryAddedObservable: Observable<Geometry>;
  32492. /**
  32493. * An event triggered when a geometry is removed
  32494. */
  32495. onGeometryRemovedObservable: Observable<Geometry>;
  32496. /**
  32497. * An event triggered when a transform node is created
  32498. */
  32499. onNewTransformNodeAddedObservable: Observable<TransformNode>;
  32500. /**
  32501. * An event triggered when a transform node is removed
  32502. */
  32503. onTransformNodeRemovedObservable: Observable<TransformNode>;
  32504. /**
  32505. * An event triggered when a mesh is created
  32506. */
  32507. onNewMeshAddedObservable: Observable<AbstractMesh>;
  32508. /**
  32509. * An event triggered when a mesh is removed
  32510. */
  32511. onMeshRemovedObservable: Observable<AbstractMesh>;
  32512. /**
  32513. * An event triggered when a skeleton is created
  32514. */
  32515. onNewSkeletonAddedObservable: Observable<Skeleton>;
  32516. /**
  32517. * An event triggered when a skeleton is removed
  32518. */
  32519. onSkeletonRemovedObservable: Observable<Skeleton>;
  32520. /**
  32521. * An event triggered when a material is created
  32522. */
  32523. onNewMaterialAddedObservable: Observable<Material>;
  32524. /**
  32525. * An event triggered when a material is removed
  32526. */
  32527. onMaterialRemovedObservable: Observable<Material>;
  32528. /**
  32529. * An event triggered when a texture is created
  32530. */
  32531. onNewTextureAddedObservable: Observable<BaseTexture>;
  32532. /**
  32533. * An event triggered when a texture is removed
  32534. */
  32535. onTextureRemovedObservable: Observable<BaseTexture>;
  32536. /**
  32537. * An event triggered when render targets are about to be rendered
  32538. * Can happen multiple times per frame.
  32539. */
  32540. onBeforeRenderTargetsRenderObservable: Observable<Scene>;
  32541. /**
  32542. * An event triggered when render targets were rendered.
  32543. * Can happen multiple times per frame.
  32544. */
  32545. onAfterRenderTargetsRenderObservable: Observable<Scene>;
  32546. /**
  32547. * An event triggered before calculating deterministic simulation step
  32548. */
  32549. onBeforeStepObservable: Observable<Scene>;
  32550. /**
  32551. * An event triggered after calculating deterministic simulation step
  32552. */
  32553. onAfterStepObservable: Observable<Scene>;
  32554. /**
  32555. * An event triggered when the activeCamera property is updated
  32556. */
  32557. onActiveCameraChanged: Observable<Scene>;
  32558. /**
  32559. * This Observable will be triggered before rendering each renderingGroup of each rendered camera.
  32560. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  32561. * 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)
  32562. */
  32563. onBeforeRenderingGroupObservable: Observable<RenderingGroupInfo>;
  32564. /**
  32565. * This Observable will be triggered after rendering each renderingGroup of each rendered camera.
  32566. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  32567. * 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)
  32568. */
  32569. onAfterRenderingGroupObservable: Observable<RenderingGroupInfo>;
  32570. /**
  32571. * This Observable will when a mesh has been imported into the scene.
  32572. */
  32573. onMeshImportedObservable: Observable<AbstractMesh>;
  32574. /**
  32575. * Gets or sets a user defined funtion to select LOD from a mesh and a camera.
  32576. * By default this function is undefined and Babylon.js will select LOD based on distance to camera
  32577. */
  32578. customLODSelector: (mesh: AbstractMesh, camera: Camera) => Nullable<AbstractMesh>;
  32579. /** @hidden */
  32580. _registeredForLateAnimationBindings: SmartArrayNoDuplicate<any>;
  32581. /**
  32582. * Gets or sets a predicate used to select candidate meshes for a pointer down event
  32583. */
  32584. pointerDownPredicate: (Mesh: AbstractMesh) => boolean;
  32585. /**
  32586. * Gets or sets a predicate used to select candidate meshes for a pointer up event
  32587. */
  32588. pointerUpPredicate: (Mesh: AbstractMesh) => boolean;
  32589. /**
  32590. * Gets or sets a predicate used to select candidate meshes for a pointer move event
  32591. */
  32592. pointerMovePredicate: (Mesh: AbstractMesh) => boolean;
  32593. private _onPointerMove;
  32594. private _onPointerDown;
  32595. private _onPointerUp;
  32596. /** Callback called when a pointer move is detected */
  32597. onPointerMove: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  32598. /** Callback called when a pointer down is detected */
  32599. onPointerDown: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  32600. /** Callback called when a pointer up is detected */
  32601. onPointerUp: (evt: PointerEvent, pickInfo: Nullable<PickingInfo>, type: PointerEventTypes) => void;
  32602. /** Callback called when a pointer pick is detected */
  32603. onPointerPick: (evt: PointerEvent, pickInfo: PickingInfo) => void;
  32604. /**
  32605. * 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).
  32606. * You have the possibility to skip the process and the call to onPointerObservable by setting PointerInfoPre.skipOnPointerObservable to true
  32607. */
  32608. onPrePointerObservable: Observable<PointerInfoPre>;
  32609. /**
  32610. * Observable event triggered each time an input event is received from the rendering canvas
  32611. */
  32612. onPointerObservable: Observable<PointerInfo>;
  32613. /**
  32614. * Gets the pointer coordinates without any translation (ie. straight out of the pointer event)
  32615. */
  32616. readonly unTranslatedPointer: Vector2;
  32617. /** The distance in pixel that you have to move to prevent some events */
  32618. static DragMovementThreshold: number;
  32619. /** Time in milliseconds to wait to raise long press events if button is still pressed */
  32620. static LongPressDelay: number;
  32621. /** Time in milliseconds with two consecutive clicks will be considered as a double click */
  32622. static DoubleClickDelay: number;
  32623. /** If you need to check double click without raising a single click at first click, enable this flag */
  32624. static ExclusiveDoubleClickMode: boolean;
  32625. private _initClickEvent;
  32626. private _initActionManager;
  32627. private _delayedSimpleClick;
  32628. private _delayedSimpleClickTimeout;
  32629. private _previousDelayedSimpleClickTimeout;
  32630. private _meshPickProceed;
  32631. private _previousButtonPressed;
  32632. private _currentPickResult;
  32633. private _previousPickResult;
  32634. private _totalPointersPressed;
  32635. private _doubleClickOccured;
  32636. /** Define this parameter if you are using multiple cameras and you want to specify which one should be used for pointer position */
  32637. cameraToUseForPointers: Nullable<Camera>;
  32638. private _pointerX;
  32639. private _pointerY;
  32640. private _unTranslatedPointerX;
  32641. private _unTranslatedPointerY;
  32642. private _startingPointerPosition;
  32643. private _previousStartingPointerPosition;
  32644. private _startingPointerTime;
  32645. private _previousStartingPointerTime;
  32646. private _pointerCaptures;
  32647. private _timeAccumulator;
  32648. private _currentStepId;
  32649. private _currentInternalStep;
  32650. /** @hidden */
  32651. _mirroredCameraPosition: Nullable<Vector3>;
  32652. /**
  32653. * This observable event is triggered when any keyboard event si raised and registered during Scene.attachControl()
  32654. * You have the possibility to skip the process and the call to onKeyboardObservable by setting KeyboardInfoPre.skipOnPointerObservable to true
  32655. */
  32656. onPreKeyboardObservable: Observable<KeyboardInfoPre>;
  32657. /**
  32658. * Observable event triggered each time an keyboard event is received from the hosting window
  32659. */
  32660. onKeyboardObservable: Observable<KeyboardInfo>;
  32661. private _onKeyDown;
  32662. private _onKeyUp;
  32663. private _onCanvasFocusObserver;
  32664. private _onCanvasBlurObserver;
  32665. private _useRightHandedSystem;
  32666. /**
  32667. * Gets or sets a boolean indicating if the scene must use right-handed coordinates system
  32668. */
  32669. useRightHandedSystem: boolean;
  32670. /**
  32671. * Sets the step Id used by deterministic lock step
  32672. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  32673. * @param newStepId defines the step Id
  32674. */
  32675. setStepId(newStepId: number): void;
  32676. /**
  32677. * Gets the step Id used by deterministic lock step
  32678. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  32679. * @returns the step Id
  32680. */
  32681. getStepId(): number;
  32682. /**
  32683. * Gets the internal step used by deterministic lock step
  32684. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  32685. * @returns the internal step
  32686. */
  32687. getInternalStep(): number;
  32688. private _fogEnabled;
  32689. /**
  32690. * Gets or sets a boolean indicating if fog is enabled on this scene
  32691. * @see http://doc.babylonjs.com/babylon101/environment#fog
  32692. * (Default is true)
  32693. */
  32694. fogEnabled: boolean;
  32695. private _fogMode;
  32696. /**
  32697. * Gets or sets the fog mode to use
  32698. * @see http://doc.babylonjs.com/babylon101/environment#fog
  32699. * | mode | value |
  32700. * | --- | --- |
  32701. * | FOGMODE_NONE | 0 |
  32702. * | FOGMODE_EXP | 1 |
  32703. * | FOGMODE_EXP2 | 2 |
  32704. * | FOGMODE_LINEAR | 3 |
  32705. */
  32706. fogMode: number;
  32707. /**
  32708. * Gets or sets the fog color to use
  32709. * @see http://doc.babylonjs.com/babylon101/environment#fog
  32710. * (Default is Color3(0.2, 0.2, 0.3))
  32711. */
  32712. fogColor: Color3;
  32713. /**
  32714. * Gets or sets the fog density to use
  32715. * @see http://doc.babylonjs.com/babylon101/environment#fog
  32716. * (Default is 0.1)
  32717. */
  32718. fogDensity: number;
  32719. /**
  32720. * Gets or sets the fog start distance to use
  32721. * @see http://doc.babylonjs.com/babylon101/environment#fog
  32722. * (Default is 0)
  32723. */
  32724. fogStart: number;
  32725. /**
  32726. * Gets or sets the fog end distance to use
  32727. * @see http://doc.babylonjs.com/babylon101/environment#fog
  32728. * (Default is 1000)
  32729. */
  32730. fogEnd: number;
  32731. private _shadowsEnabled;
  32732. /**
  32733. * Gets or sets a boolean indicating if shadows are enabled on this scene
  32734. */
  32735. shadowsEnabled: boolean;
  32736. private _lightsEnabled;
  32737. /**
  32738. * Gets or sets a boolean indicating if lights are enabled on this scene
  32739. */
  32740. lightsEnabled: boolean;
  32741. /** All of the active cameras added to this scene. */
  32742. activeCameras: Camera[];
  32743. private _activeCamera;
  32744. /** Gets or sets the current active camera */
  32745. activeCamera: Nullable<Camera>;
  32746. private _defaultMaterial;
  32747. /** The default material used on meshes when no material is affected */
  32748. /** The default material used on meshes when no material is affected */
  32749. defaultMaterial: Material;
  32750. private _texturesEnabled;
  32751. /**
  32752. * Gets or sets a boolean indicating if textures are enabled on this scene
  32753. */
  32754. texturesEnabled: boolean;
  32755. /**
  32756. * Gets or sets a boolean indicating if particles are enabled on this scene
  32757. */
  32758. particlesEnabled: boolean;
  32759. /**
  32760. * Gets or sets a boolean indicating if sprites are enabled on this scene
  32761. */
  32762. spritesEnabled: boolean;
  32763. private _skeletonsEnabled;
  32764. /**
  32765. * Gets or sets a boolean indicating if skeletons are enabled on this scene
  32766. */
  32767. skeletonsEnabled: boolean;
  32768. /**
  32769. * Gets or sets a boolean indicating if lens flares are enabled on this scene
  32770. */
  32771. lensFlaresEnabled: boolean;
  32772. /**
  32773. * Gets or sets a boolean indicating if collisions are enabled on this scene
  32774. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  32775. */
  32776. collisionsEnabled: boolean;
  32777. private _collisionCoordinator;
  32778. /** @hidden */
  32779. readonly collisionCoordinator: ICollisionCoordinator;
  32780. /**
  32781. * Defines the gravity applied to this scene (used only for collisions)
  32782. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  32783. */
  32784. gravity: Vector3;
  32785. /**
  32786. * Gets or sets a boolean indicating if postprocesses are enabled on this scene
  32787. */
  32788. postProcessesEnabled: boolean;
  32789. /**
  32790. * The list of postprocesses added to the scene
  32791. */
  32792. postProcesses: PostProcess[];
  32793. /**
  32794. * Gets the current postprocess manager
  32795. */
  32796. postProcessManager: PostProcessManager;
  32797. /**
  32798. * Gets or sets a boolean indicating if render targets are enabled on this scene
  32799. */
  32800. renderTargetsEnabled: boolean;
  32801. /**
  32802. * Gets or sets a boolean indicating if next render targets must be dumped as image for debugging purposes
  32803. * We recommend not using it and instead rely on Spector.js: http://spector.babylonjs.com
  32804. */
  32805. dumpNextRenderTargets: boolean;
  32806. /**
  32807. * The list of user defined render targets added to the scene
  32808. */
  32809. customRenderTargets: RenderTargetTexture[];
  32810. /**
  32811. * Defines if texture loading must be delayed
  32812. * If true, textures will only be loaded when they need to be rendered
  32813. */
  32814. useDelayedTextureLoading: boolean;
  32815. /**
  32816. * Gets the list of meshes imported to the scene through SceneLoader
  32817. */
  32818. importedMeshesFiles: String[];
  32819. /**
  32820. * Gets or sets a boolean indicating if probes are enabled on this scene
  32821. */
  32822. probesEnabled: boolean;
  32823. /**
  32824. * Gets or sets the current offline provider to use to store scene data
  32825. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  32826. */
  32827. offlineProvider: IOfflineProvider;
  32828. /**
  32829. * Gets or sets the action manager associated with the scene
  32830. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  32831. */
  32832. actionManager: AbstractActionManager;
  32833. private _meshesForIntersections;
  32834. /**
  32835. * Gets or sets a boolean indicating if procedural textures are enabled on this scene
  32836. */
  32837. proceduralTexturesEnabled: boolean;
  32838. private _engine;
  32839. private _totalVertices;
  32840. /** @hidden */
  32841. _activeIndices: PerfCounter;
  32842. /** @hidden */
  32843. _activeParticles: PerfCounter;
  32844. /** @hidden */
  32845. _activeBones: PerfCounter;
  32846. private _animationRatio;
  32847. /** @hidden */
  32848. _animationTimeLast: number;
  32849. /** @hidden */
  32850. _animationTime: number;
  32851. /**
  32852. * Gets or sets a general scale for animation speed
  32853. * @see https://www.babylonjs-playground.com/#IBU2W7#3
  32854. */
  32855. animationTimeScale: number;
  32856. /** @hidden */
  32857. _cachedMaterial: Nullable<Material>;
  32858. /** @hidden */
  32859. _cachedEffect: Nullable<Effect>;
  32860. /** @hidden */
  32861. _cachedVisibility: Nullable<number>;
  32862. private _renderId;
  32863. private _frameId;
  32864. private _executeWhenReadyTimeoutId;
  32865. private _intermediateRendering;
  32866. private _viewUpdateFlag;
  32867. private _projectionUpdateFlag;
  32868. private _alternateViewUpdateFlag;
  32869. private _alternateProjectionUpdateFlag;
  32870. /** @hidden */
  32871. _toBeDisposed: Nullable<IDisposable>[];
  32872. private _activeRequests;
  32873. /** @hidden */
  32874. _pendingData: any[];
  32875. private _isDisposed;
  32876. /**
  32877. * Gets or sets a boolean indicating that all submeshes of active meshes must be rendered
  32878. * Use this boolean to avoid computing frustum clipping on submeshes (This could help when you are CPU bound)
  32879. */
  32880. dispatchAllSubMeshesOfActiveMeshes: boolean;
  32881. private _activeMeshes;
  32882. private _processedMaterials;
  32883. private _renderTargets;
  32884. /** @hidden */
  32885. _activeParticleSystems: SmartArray<IParticleSystem>;
  32886. private _activeSkeletons;
  32887. private _softwareSkinnedMeshes;
  32888. private _renderingManager;
  32889. /** @hidden */
  32890. _activeAnimatables: import("babylonjs/Animations/animatable").Animatable[];
  32891. private _transformMatrix;
  32892. private _sceneUbo;
  32893. private _alternateSceneUbo;
  32894. private _viewMatrix;
  32895. private _projectionMatrix;
  32896. private _alternateViewMatrix;
  32897. private _alternateProjectionMatrix;
  32898. private _alternateTransformMatrix;
  32899. private _useAlternateCameraConfiguration;
  32900. private _alternateRendering;
  32901. private _wheelEventName;
  32902. /** @hidden */
  32903. _forcedViewPosition: Nullable<Vector3>;
  32904. /** @hidden */
  32905. readonly _isAlternateRenderingEnabled: boolean;
  32906. private _frustumPlanes;
  32907. /**
  32908. * Gets the list of frustum planes (built from the active camera)
  32909. */
  32910. readonly frustumPlanes: Plane[];
  32911. /**
  32912. * Gets or sets a boolean indicating if lights must be sorted by priority (off by default)
  32913. * This is useful if there are more lights that the maximum simulteanous authorized
  32914. */
  32915. requireLightSorting: boolean;
  32916. /** @hidden */
  32917. readonly useMaterialMeshMap: boolean;
  32918. /** @hidden */
  32919. readonly useClonedMeshhMap: boolean;
  32920. private _pointerOverMesh;
  32921. private _pickedDownMesh;
  32922. private _pickedUpMesh;
  32923. private _externalData;
  32924. private _uid;
  32925. /**
  32926. * @hidden
  32927. * Backing store of defined scene components.
  32928. */
  32929. _components: ISceneComponent[];
  32930. /**
  32931. * @hidden
  32932. * Backing store of defined scene components.
  32933. */
  32934. _serializableComponents: ISceneSerializableComponent[];
  32935. /**
  32936. * List of components to register on the next registration step.
  32937. */
  32938. private _transientComponents;
  32939. /**
  32940. * Registers the transient components if needed.
  32941. */
  32942. private _registerTransientComponents;
  32943. /**
  32944. * @hidden
  32945. * Add a component to the scene.
  32946. * Note that the ccomponent could be registered on th next frame if this is called after
  32947. * the register component stage.
  32948. * @param component Defines the component to add to the scene
  32949. */
  32950. _addComponent(component: ISceneComponent): void;
  32951. /**
  32952. * @hidden
  32953. * Gets a component from the scene.
  32954. * @param name defines the name of the component to retrieve
  32955. * @returns the component or null if not present
  32956. */
  32957. _getComponent(name: string): Nullable<ISceneComponent>;
  32958. /**
  32959. * @hidden
  32960. * Defines the actions happening before camera updates.
  32961. */
  32962. _beforeCameraUpdateStage: Stage<SimpleStageAction>;
  32963. /**
  32964. * @hidden
  32965. * Defines the actions happening before clear the canvas.
  32966. */
  32967. _beforeClearStage: Stage<SimpleStageAction>;
  32968. /**
  32969. * @hidden
  32970. * Defines the actions when collecting render targets for the frame.
  32971. */
  32972. _gatherRenderTargetsStage: Stage<RenderTargetsStageAction>;
  32973. /**
  32974. * @hidden
  32975. * Defines the actions happening for one camera in the frame.
  32976. */
  32977. _gatherActiveCameraRenderTargetsStage: Stage<RenderTargetsStageAction>;
  32978. /**
  32979. * @hidden
  32980. * Defines the actions happening during the per mesh ready checks.
  32981. */
  32982. _isReadyForMeshStage: Stage<MeshStageAction>;
  32983. /**
  32984. * @hidden
  32985. * Defines the actions happening before evaluate active mesh checks.
  32986. */
  32987. _beforeEvaluateActiveMeshStage: Stage<SimpleStageAction>;
  32988. /**
  32989. * @hidden
  32990. * Defines the actions happening during the evaluate sub mesh checks.
  32991. */
  32992. _evaluateSubMeshStage: Stage<EvaluateSubMeshStageAction>;
  32993. /**
  32994. * @hidden
  32995. * Defines the actions happening during the active mesh stage.
  32996. */
  32997. _activeMeshStage: Stage<ActiveMeshStageAction>;
  32998. /**
  32999. * @hidden
  33000. * Defines the actions happening during the per camera render target step.
  33001. */
  33002. _cameraDrawRenderTargetStage: Stage<CameraStageAction>;
  33003. /**
  33004. * @hidden
  33005. * Defines the actions happening just before the active camera is drawing.
  33006. */
  33007. _beforeCameraDrawStage: Stage<CameraStageAction>;
  33008. /**
  33009. * @hidden
  33010. * Defines the actions happening just before a render target is drawing.
  33011. */
  33012. _beforeRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  33013. /**
  33014. * @hidden
  33015. * Defines the actions happening just before a rendering group is drawing.
  33016. */
  33017. _beforeRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  33018. /**
  33019. * @hidden
  33020. * Defines the actions happening just before a mesh is drawing.
  33021. */
  33022. _beforeRenderingMeshStage: Stage<RenderingMeshStageAction>;
  33023. /**
  33024. * @hidden
  33025. * Defines the actions happening just after a mesh has been drawn.
  33026. */
  33027. _afterRenderingMeshStage: Stage<RenderingMeshStageAction>;
  33028. /**
  33029. * @hidden
  33030. * Defines the actions happening just after a rendering group has been drawn.
  33031. */
  33032. _afterRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  33033. /**
  33034. * @hidden
  33035. * Defines the actions happening just after the active camera has been drawn.
  33036. */
  33037. _afterCameraDrawStage: Stage<CameraStageAction>;
  33038. /**
  33039. * @hidden
  33040. * Defines the actions happening just after a render target has been drawn.
  33041. */
  33042. _afterRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  33043. /**
  33044. * @hidden
  33045. * Defines the actions happening just after rendering all cameras and computing intersections.
  33046. */
  33047. _afterRenderStage: Stage<SimpleStageAction>;
  33048. /**
  33049. * @hidden
  33050. * Defines the actions happening when a pointer move event happens.
  33051. */
  33052. _pointerMoveStage: Stage<PointerMoveStageAction>;
  33053. /**
  33054. * @hidden
  33055. * Defines the actions happening when a pointer down event happens.
  33056. */
  33057. _pointerDownStage: Stage<PointerUpDownStageAction>;
  33058. /**
  33059. * @hidden
  33060. * Defines the actions happening when a pointer up event happens.
  33061. */
  33062. _pointerUpStage: Stage<PointerUpDownStageAction>;
  33063. /**
  33064. * an optional map from Geometry Id to Geometry index in the 'geometries' array
  33065. */
  33066. private geometriesByUniqueId;
  33067. /**
  33068. * Creates a new Scene
  33069. * @param engine defines the engine to use to render this scene
  33070. * @param options defines the scene options
  33071. */
  33072. constructor(engine: Engine, options?: SceneOptions);
  33073. private _defaultMeshCandidates;
  33074. /**
  33075. * @hidden
  33076. */
  33077. _getDefaultMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  33078. private _defaultSubMeshCandidates;
  33079. /**
  33080. * @hidden
  33081. */
  33082. _getDefaultSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  33083. /**
  33084. * Sets the default candidate providers for the scene.
  33085. * This sets the getActiveMeshCandidates, getActiveSubMeshCandidates, getIntersectingSubMeshCandidates
  33086. * and getCollidingSubMeshCandidates to their default function
  33087. */
  33088. setDefaultCandidateProviders(): void;
  33089. /**
  33090. * Gets the mesh that is currently under the pointer
  33091. */
  33092. readonly meshUnderPointer: Nullable<AbstractMesh>;
  33093. /**
  33094. * Gets or sets the current on-screen X position of the pointer
  33095. */
  33096. pointerX: number;
  33097. /**
  33098. * Gets or sets the current on-screen Y position of the pointer
  33099. */
  33100. pointerY: number;
  33101. /**
  33102. * Gets the cached material (ie. the latest rendered one)
  33103. * @returns the cached material
  33104. */
  33105. getCachedMaterial(): Nullable<Material>;
  33106. /**
  33107. * Gets the cached effect (ie. the latest rendered one)
  33108. * @returns the cached effect
  33109. */
  33110. getCachedEffect(): Nullable<Effect>;
  33111. /**
  33112. * Gets the cached visibility state (ie. the latest rendered one)
  33113. * @returns the cached visibility state
  33114. */
  33115. getCachedVisibility(): Nullable<number>;
  33116. /**
  33117. * Gets a boolean indicating if the current material / effect / visibility must be bind again
  33118. * @param material defines the current material
  33119. * @param effect defines the current effect
  33120. * @param visibility defines the current visibility state
  33121. * @returns true if one parameter is not cached
  33122. */
  33123. isCachedMaterialInvalid(material: Material, effect: Effect, visibility?: number): boolean;
  33124. /**
  33125. * Gets the engine associated with the scene
  33126. * @returns an Engine
  33127. */
  33128. getEngine(): Engine;
  33129. /**
  33130. * Gets the total number of vertices rendered per frame
  33131. * @returns the total number of vertices rendered per frame
  33132. */
  33133. getTotalVertices(): number;
  33134. /**
  33135. * Gets the performance counter for total vertices
  33136. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  33137. */
  33138. readonly totalVerticesPerfCounter: PerfCounter;
  33139. /**
  33140. * Gets the total number of active indices rendered per frame (You can deduce the number of rendered triangles by dividing this number by 3)
  33141. * @returns the total number of active indices rendered per frame
  33142. */
  33143. getActiveIndices(): number;
  33144. /**
  33145. * Gets the performance counter for active indices
  33146. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  33147. */
  33148. readonly totalActiveIndicesPerfCounter: PerfCounter;
  33149. /**
  33150. * Gets the total number of active particles rendered per frame
  33151. * @returns the total number of active particles rendered per frame
  33152. */
  33153. getActiveParticles(): number;
  33154. /**
  33155. * Gets the performance counter for active particles
  33156. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  33157. */
  33158. readonly activeParticlesPerfCounter: PerfCounter;
  33159. /**
  33160. * Gets the total number of active bones rendered per frame
  33161. * @returns the total number of active bones rendered per frame
  33162. */
  33163. getActiveBones(): number;
  33164. /**
  33165. * Gets the performance counter for active bones
  33166. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  33167. */
  33168. readonly activeBonesPerfCounter: PerfCounter;
  33169. /**
  33170. * Gets the array of active meshes
  33171. * @returns an array of AbstractMesh
  33172. */
  33173. getActiveMeshes(): SmartArray<AbstractMesh>;
  33174. /**
  33175. * Gets the animation ratio (which is 1.0 is the scene renders at 60fps and 2 if the scene renders at 30fps, etc.)
  33176. * @returns a number
  33177. */
  33178. getAnimationRatio(): number;
  33179. /**
  33180. * Gets an unique Id for the current render phase
  33181. * @returns a number
  33182. */
  33183. getRenderId(): number;
  33184. /**
  33185. * Gets an unique Id for the current frame
  33186. * @returns a number
  33187. */
  33188. getFrameId(): number;
  33189. /** Call this function if you want to manually increment the render Id*/
  33190. incrementRenderId(): void;
  33191. private _updatePointerPosition;
  33192. private _createUbo;
  33193. private _createAlternateUbo;
  33194. private _setRayOnPointerInfo;
  33195. /**
  33196. * Use this method to simulate a pointer move on a mesh
  33197. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  33198. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  33199. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  33200. * @returns the current scene
  33201. */
  33202. simulatePointerMove(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  33203. private _processPointerMove;
  33204. private _checkPrePointerObservable;
  33205. /**
  33206. * Use this method to simulate a pointer down on a mesh
  33207. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  33208. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  33209. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  33210. * @returns the current scene
  33211. */
  33212. simulatePointerDown(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  33213. private _processPointerDown;
  33214. /**
  33215. * Use this method to simulate a pointer up on a mesh
  33216. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  33217. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  33218. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  33219. * @param doubleTap indicates that the pointer up event should be considered as part of a double click (false by default)
  33220. * @returns the current scene
  33221. */
  33222. simulatePointerUp(pickResult: PickingInfo, pointerEventInit?: PointerEventInit, doubleTap?: boolean): Scene;
  33223. private _processPointerUp;
  33224. /**
  33225. * Gets a boolean indicating if the current pointer event is captured (meaning that the scene has already handled the pointer down)
  33226. * @param pointerId defines the pointer id to use in a multi-touch scenario (0 by default)
  33227. * @returns true if the pointer was captured
  33228. */
  33229. isPointerCaptured(pointerId?: number): boolean;
  33230. /** @hidden */
  33231. _isPointerSwiping(): boolean;
  33232. /**
  33233. * Attach events to the canvas (To handle actionManagers triggers and raise onPointerMove, onPointerDown and onPointerUp
  33234. * @param attachUp defines if you want to attach events to pointerup
  33235. * @param attachDown defines if you want to attach events to pointerdown
  33236. * @param attachMove defines if you want to attach events to pointermove
  33237. */
  33238. attachControl(attachUp?: boolean, attachDown?: boolean, attachMove?: boolean): void;
  33239. /** Detaches all event handlers*/
  33240. detachControl(): void;
  33241. /**
  33242. * This function will check if the scene can be rendered (textures are loaded, shaders are compiled)
  33243. * Delay loaded resources are not taking in account
  33244. * @return true if all required resources are ready
  33245. */
  33246. isReady(): boolean;
  33247. /** Resets all cached information relative to material (including effect and visibility) */
  33248. resetCachedMaterial(): void;
  33249. /**
  33250. * Registers a function to be called before every frame render
  33251. * @param func defines the function to register
  33252. */
  33253. registerBeforeRender(func: () => void): void;
  33254. /**
  33255. * Unregisters a function called before every frame render
  33256. * @param func defines the function to unregister
  33257. */
  33258. unregisterBeforeRender(func: () => void): void;
  33259. /**
  33260. * Registers a function to be called after every frame render
  33261. * @param func defines the function to register
  33262. */
  33263. registerAfterRender(func: () => void): void;
  33264. /**
  33265. * Unregisters a function called after every frame render
  33266. * @param func defines the function to unregister
  33267. */
  33268. unregisterAfterRender(func: () => void): void;
  33269. private _executeOnceBeforeRender;
  33270. /**
  33271. * The provided function will run before render once and will be disposed afterwards.
  33272. * A timeout delay can be provided so that the function will be executed in N ms.
  33273. * The timeout is using the browser's native setTimeout so time percision cannot be guaranteed.
  33274. * @param func The function to be executed.
  33275. * @param timeout optional delay in ms
  33276. */
  33277. executeOnceBeforeRender(func: () => void, timeout?: number): void;
  33278. /** @hidden */
  33279. _addPendingData(data: any): void;
  33280. /** @hidden */
  33281. _removePendingData(data: any): void;
  33282. /**
  33283. * Returns the number of items waiting to be loaded
  33284. * @returns the number of items waiting to be loaded
  33285. */
  33286. getWaitingItemsCount(): number;
  33287. /**
  33288. * Returns a boolean indicating if the scene is still loading data
  33289. */
  33290. readonly isLoading: boolean;
  33291. /**
  33292. * Registers a function to be executed when the scene is ready
  33293. * @param {Function} func - the function to be executed
  33294. */
  33295. executeWhenReady(func: () => void): void;
  33296. /**
  33297. * Returns a promise that resolves when the scene is ready
  33298. * @returns A promise that resolves when the scene is ready
  33299. */
  33300. whenReadyAsync(): Promise<void>;
  33301. /** @hidden */
  33302. _checkIsReady(): void;
  33303. /**
  33304. * Gets all animatable attached to the scene
  33305. */
  33306. readonly animatables: Animatable[];
  33307. /**
  33308. * Resets the last animation time frame.
  33309. * Useful to override when animations start running when loading a scene for the first time.
  33310. */
  33311. resetLastAnimationTimeFrame(): void;
  33312. /** @hidden */
  33313. _switchToAlternateCameraConfiguration(active: boolean): void;
  33314. /**
  33315. * Gets the current view matrix
  33316. * @returns a Matrix
  33317. */
  33318. getViewMatrix(): Matrix;
  33319. /**
  33320. * Gets the current projection matrix
  33321. * @returns a Matrix
  33322. */
  33323. getProjectionMatrix(): Matrix;
  33324. /**
  33325. * Gets the current transform matrix
  33326. * @returns a Matrix made of View * Projection
  33327. */
  33328. getTransformMatrix(): Matrix;
  33329. /**
  33330. * Sets the current transform matrix
  33331. * @param view defines the View matrix to use
  33332. * @param projection defines the Projection matrix to use
  33333. */
  33334. setTransformMatrix(view: Matrix, projection: Matrix): void;
  33335. /** @hidden */
  33336. _setAlternateTransformMatrix(view: Matrix, projection: Matrix): void;
  33337. /**
  33338. * Gets the uniform buffer used to store scene data
  33339. * @returns a UniformBuffer
  33340. */
  33341. getSceneUniformBuffer(): UniformBuffer;
  33342. /**
  33343. * Gets an unique (relatively to the current scene) Id
  33344. * @returns an unique number for the scene
  33345. */
  33346. getUniqueId(): number;
  33347. /**
  33348. * Add a mesh to the list of scene's meshes
  33349. * @param newMesh defines the mesh to add
  33350. * @param recursive if all child meshes should also be added to the scene
  33351. */
  33352. addMesh(newMesh: AbstractMesh, recursive?: boolean): void;
  33353. /**
  33354. * Remove a mesh for the list of scene's meshes
  33355. * @param toRemove defines the mesh to remove
  33356. * @param recursive if all child meshes should also be removed from the scene
  33357. * @returns the index where the mesh was in the mesh list
  33358. */
  33359. removeMesh(toRemove: AbstractMesh, recursive?: boolean): number;
  33360. /**
  33361. * Add a transform node to the list of scene's transform nodes
  33362. * @param newTransformNode defines the transform node to add
  33363. */
  33364. addTransformNode(newTransformNode: TransformNode): void;
  33365. /**
  33366. * Remove a transform node for the list of scene's transform nodes
  33367. * @param toRemove defines the transform node to remove
  33368. * @returns the index where the transform node was in the transform node list
  33369. */
  33370. removeTransformNode(toRemove: TransformNode): number;
  33371. /**
  33372. * Remove a skeleton for the list of scene's skeletons
  33373. * @param toRemove defines the skeleton to remove
  33374. * @returns the index where the skeleton was in the skeleton list
  33375. */
  33376. removeSkeleton(toRemove: Skeleton): number;
  33377. /**
  33378. * Remove a morph target for the list of scene's morph targets
  33379. * @param toRemove defines the morph target to remove
  33380. * @returns the index where the morph target was in the morph target list
  33381. */
  33382. removeMorphTargetManager(toRemove: MorphTargetManager): number;
  33383. /**
  33384. * Remove a light for the list of scene's lights
  33385. * @param toRemove defines the light to remove
  33386. * @returns the index where the light was in the light list
  33387. */
  33388. removeLight(toRemove: Light): number;
  33389. /**
  33390. * Remove a camera for the list of scene's cameras
  33391. * @param toRemove defines the camera to remove
  33392. * @returns the index where the camera was in the camera list
  33393. */
  33394. removeCamera(toRemove: Camera): number;
  33395. /**
  33396. * Remove a particle system for the list of scene's particle systems
  33397. * @param toRemove defines the particle system to remove
  33398. * @returns the index where the particle system was in the particle system list
  33399. */
  33400. removeParticleSystem(toRemove: IParticleSystem): number;
  33401. /**
  33402. * Remove a animation for the list of scene's animations
  33403. * @param toRemove defines the animation to remove
  33404. * @returns the index where the animation was in the animation list
  33405. */
  33406. removeAnimation(toRemove: Animation): number;
  33407. /**
  33408. * Removes the given animation group from this scene.
  33409. * @param toRemove The animation group to remove
  33410. * @returns The index of the removed animation group
  33411. */
  33412. removeAnimationGroup(toRemove: AnimationGroup): number;
  33413. /**
  33414. * Removes the given multi-material from this scene.
  33415. * @param toRemove The multi-material to remove
  33416. * @returns The index of the removed multi-material
  33417. */
  33418. removeMultiMaterial(toRemove: MultiMaterial): number;
  33419. /**
  33420. * Removes the given material from this scene.
  33421. * @param toRemove The material to remove
  33422. * @returns The index of the removed material
  33423. */
  33424. removeMaterial(toRemove: Material): number;
  33425. /**
  33426. * Removes the given action manager from this scene.
  33427. * @param toRemove The action manager to remove
  33428. * @returns The index of the removed action manager
  33429. */
  33430. removeActionManager(toRemove: AbstractActionManager): number;
  33431. /**
  33432. * Removes the given texture from this scene.
  33433. * @param toRemove The texture to remove
  33434. * @returns The index of the removed texture
  33435. */
  33436. removeTexture(toRemove: BaseTexture): number;
  33437. /**
  33438. * Adds the given light to this scene
  33439. * @param newLight The light to add
  33440. */
  33441. addLight(newLight: Light): void;
  33442. /**
  33443. * Sorts the list list based on light priorities
  33444. */
  33445. sortLightsByPriority(): void;
  33446. /**
  33447. * Adds the given camera to this scene
  33448. * @param newCamera The camera to add
  33449. */
  33450. addCamera(newCamera: Camera): void;
  33451. /**
  33452. * Adds the given skeleton to this scene
  33453. * @param newSkeleton The skeleton to add
  33454. */
  33455. addSkeleton(newSkeleton: Skeleton): void;
  33456. /**
  33457. * Adds the given particle system to this scene
  33458. * @param newParticleSystem The particle system to add
  33459. */
  33460. addParticleSystem(newParticleSystem: IParticleSystem): void;
  33461. /**
  33462. * Adds the given animation to this scene
  33463. * @param newAnimation The animation to add
  33464. */
  33465. addAnimation(newAnimation: Animation): void;
  33466. /**
  33467. * Adds the given animation group to this scene.
  33468. * @param newAnimationGroup The animation group to add
  33469. */
  33470. addAnimationGroup(newAnimationGroup: AnimationGroup): void;
  33471. /**
  33472. * Adds the given multi-material to this scene
  33473. * @param newMultiMaterial The multi-material to add
  33474. */
  33475. addMultiMaterial(newMultiMaterial: MultiMaterial): void;
  33476. /**
  33477. * Adds the given material to this scene
  33478. * @param newMaterial The material to add
  33479. */
  33480. addMaterial(newMaterial: Material): void;
  33481. /**
  33482. * Adds the given morph target to this scene
  33483. * @param newMorphTargetManager The morph target to add
  33484. */
  33485. addMorphTargetManager(newMorphTargetManager: MorphTargetManager): void;
  33486. /**
  33487. * Adds the given geometry to this scene
  33488. * @param newGeometry The geometry to add
  33489. */
  33490. addGeometry(newGeometry: Geometry): void;
  33491. /**
  33492. * Adds the given action manager to this scene
  33493. * @param newActionManager The action manager to add
  33494. */
  33495. addActionManager(newActionManager: AbstractActionManager): void;
  33496. /**
  33497. * Adds the given texture to this scene.
  33498. * @param newTexture The texture to add
  33499. */
  33500. addTexture(newTexture: BaseTexture): void;
  33501. /**
  33502. * Switch active camera
  33503. * @param newCamera defines the new active camera
  33504. * @param attachControl defines if attachControl must be called for the new active camera (default: true)
  33505. */
  33506. switchActiveCamera(newCamera: Camera, attachControl?: boolean): void;
  33507. /**
  33508. * sets the active camera of the scene using its ID
  33509. * @param id defines the camera's ID
  33510. * @return the new active camera or null if none found.
  33511. */
  33512. setActiveCameraByID(id: string): Nullable<Camera>;
  33513. /**
  33514. * sets the active camera of the scene using its name
  33515. * @param name defines the camera's name
  33516. * @returns the new active camera or null if none found.
  33517. */
  33518. setActiveCameraByName(name: string): Nullable<Camera>;
  33519. /**
  33520. * get an animation group using its name
  33521. * @param name defines the material's name
  33522. * @return the animation group or null if none found.
  33523. */
  33524. getAnimationGroupByName(name: string): Nullable<AnimationGroup>;
  33525. /**
  33526. * Get a material using its unique id
  33527. * @param uniqueId defines the material's unique id
  33528. * @return the material or null if none found.
  33529. */
  33530. getMaterialByUniqueID(uniqueId: number): Nullable<Material>;
  33531. /**
  33532. * get a material using its id
  33533. * @param id defines the material's ID
  33534. * @return the material or null if none found.
  33535. */
  33536. getMaterialByID(id: string): Nullable<Material>;
  33537. /**
  33538. * Gets a material using its name
  33539. * @param name defines the material's name
  33540. * @return the material or null if none found.
  33541. */
  33542. getMaterialByName(name: string): Nullable<Material>;
  33543. /**
  33544. * Gets a camera using its id
  33545. * @param id defines the id to look for
  33546. * @returns the camera or null if not found
  33547. */
  33548. getCameraByID(id: string): Nullable<Camera>;
  33549. /**
  33550. * Gets a camera using its unique id
  33551. * @param uniqueId defines the unique id to look for
  33552. * @returns the camera or null if not found
  33553. */
  33554. getCameraByUniqueID(uniqueId: number): Nullable<Camera>;
  33555. /**
  33556. * Gets a camera using its name
  33557. * @param name defines the camera's name
  33558. * @return the camera or null if none found.
  33559. */
  33560. getCameraByName(name: string): Nullable<Camera>;
  33561. /**
  33562. * Gets a bone using its id
  33563. * @param id defines the bone's id
  33564. * @return the bone or null if not found
  33565. */
  33566. getBoneByID(id: string): Nullable<Bone>;
  33567. /**
  33568. * Gets a bone using its id
  33569. * @param name defines the bone's name
  33570. * @return the bone or null if not found
  33571. */
  33572. getBoneByName(name: string): Nullable<Bone>;
  33573. /**
  33574. * Gets a light node using its name
  33575. * @param name defines the the light's name
  33576. * @return the light or null if none found.
  33577. */
  33578. getLightByName(name: string): Nullable<Light>;
  33579. /**
  33580. * Gets a light node using its id
  33581. * @param id defines the light's id
  33582. * @return the light or null if none found.
  33583. */
  33584. getLightByID(id: string): Nullable<Light>;
  33585. /**
  33586. * Gets a light node using its scene-generated unique ID
  33587. * @param uniqueId defines the light's unique id
  33588. * @return the light or null if none found.
  33589. */
  33590. getLightByUniqueID(uniqueId: number): Nullable<Light>;
  33591. /**
  33592. * Gets a particle system by id
  33593. * @param id defines the particle system id
  33594. * @return the corresponding system or null if none found
  33595. */
  33596. getParticleSystemByID(id: string): Nullable<IParticleSystem>;
  33597. /**
  33598. * Gets a geometry using its ID
  33599. * @param id defines the geometry's id
  33600. * @return the geometry or null if none found.
  33601. */
  33602. getGeometryByID(id: string): Nullable<Geometry>;
  33603. private _getGeometryByUniqueID;
  33604. /**
  33605. * Add a new geometry to this scene
  33606. * @param geometry defines the geometry to be added to the scene.
  33607. * @param force defines if the geometry must be pushed even if a geometry with this id already exists
  33608. * @return a boolean defining if the geometry was added or not
  33609. */
  33610. pushGeometry(geometry: Geometry, force?: boolean): boolean;
  33611. /**
  33612. * Removes an existing geometry
  33613. * @param geometry defines the geometry to be removed from the scene
  33614. * @return a boolean defining if the geometry was removed or not
  33615. */
  33616. removeGeometry(geometry: Geometry): boolean;
  33617. /**
  33618. * Gets the list of geometries attached to the scene
  33619. * @returns an array of Geometry
  33620. */
  33621. getGeometries(): Geometry[];
  33622. /**
  33623. * Gets the first added mesh found of a given ID
  33624. * @param id defines the id to search for
  33625. * @return the mesh found or null if not found at all
  33626. */
  33627. getMeshByID(id: string): Nullable<AbstractMesh>;
  33628. /**
  33629. * Gets a list of meshes using their id
  33630. * @param id defines the id to search for
  33631. * @returns a list of meshes
  33632. */
  33633. getMeshesByID(id: string): Array<AbstractMesh>;
  33634. /**
  33635. * Gets the first added transform node found of a given ID
  33636. * @param id defines the id to search for
  33637. * @return the found transform node or null if not found at all.
  33638. */
  33639. getTransformNodeByID(id: string): Nullable<TransformNode>;
  33640. /**
  33641. * Gets a transform node with its auto-generated unique id
  33642. * @param uniqueId efines the unique id to search for
  33643. * @return the found transform node or null if not found at all.
  33644. */
  33645. getTransformNodeByUniqueID(uniqueId: number): Nullable<TransformNode>;
  33646. /**
  33647. * Gets a list of transform nodes using their id
  33648. * @param id defines the id to search for
  33649. * @returns a list of transform nodes
  33650. */
  33651. getTransformNodesByID(id: string): Array<TransformNode>;
  33652. /**
  33653. * Gets a mesh with its auto-generated unique id
  33654. * @param uniqueId defines the unique id to search for
  33655. * @return the found mesh or null if not found at all.
  33656. */
  33657. getMeshByUniqueID(uniqueId: number): Nullable<AbstractMesh>;
  33658. /**
  33659. * Gets a the last added mesh using a given id
  33660. * @param id defines the id to search for
  33661. * @return the found mesh or null if not found at all.
  33662. */
  33663. getLastMeshByID(id: string): Nullable<AbstractMesh>;
  33664. /**
  33665. * Gets a the last added node (Mesh, Camera, Light) using a given id
  33666. * @param id defines the id to search for
  33667. * @return the found node or null if not found at all
  33668. */
  33669. getLastEntryByID(id: string): Nullable<Node>;
  33670. /**
  33671. * Gets a node (Mesh, Camera, Light) using a given id
  33672. * @param id defines the id to search for
  33673. * @return the found node or null if not found at all
  33674. */
  33675. getNodeByID(id: string): Nullable<Node>;
  33676. /**
  33677. * Gets a node (Mesh, Camera, Light) using a given name
  33678. * @param name defines the name to search for
  33679. * @return the found node or null if not found at all.
  33680. */
  33681. getNodeByName(name: string): Nullable<Node>;
  33682. /**
  33683. * Gets a mesh using a given name
  33684. * @param name defines the name to search for
  33685. * @return the found mesh or null if not found at all.
  33686. */
  33687. getMeshByName(name: string): Nullable<AbstractMesh>;
  33688. /**
  33689. * Gets a transform node using a given name
  33690. * @param name defines the name to search for
  33691. * @return the found transform node or null if not found at all.
  33692. */
  33693. getTransformNodeByName(name: string): Nullable<TransformNode>;
  33694. /**
  33695. * Gets a skeleton using a given id (if many are found, this function will pick the last one)
  33696. * @param id defines the id to search for
  33697. * @return the found skeleton or null if not found at all.
  33698. */
  33699. getLastSkeletonByID(id: string): Nullable<Skeleton>;
  33700. /**
  33701. * Gets a skeleton using a given auto generated unique id
  33702. * @param uniqueId defines the unique id to search for
  33703. * @return the found skeleton or null if not found at all.
  33704. */
  33705. getSkeletonByUniqueId(uniqueId: number): Nullable<Skeleton>;
  33706. /**
  33707. * Gets a skeleton using a given id (if many are found, this function will pick the first one)
  33708. * @param id defines the id to search for
  33709. * @return the found skeleton or null if not found at all.
  33710. */
  33711. getSkeletonById(id: string): Nullable<Skeleton>;
  33712. /**
  33713. * Gets a skeleton using a given name
  33714. * @param name defines the name to search for
  33715. * @return the found skeleton or null if not found at all.
  33716. */
  33717. getSkeletonByName(name: string): Nullable<Skeleton>;
  33718. /**
  33719. * Gets a morph target manager using a given id (if many are found, this function will pick the last one)
  33720. * @param id defines the id to search for
  33721. * @return the found morph target manager or null if not found at all.
  33722. */
  33723. getMorphTargetManagerById(id: number): Nullable<MorphTargetManager>;
  33724. /**
  33725. * Gets a morph target using a given id (if many are found, this function will pick the first one)
  33726. * @param id defines the id to search for
  33727. * @return the found morph target or null if not found at all.
  33728. */
  33729. getMorphTargetById(id: string): Nullable<MorphTarget>;
  33730. /**
  33731. * Gets a boolean indicating if the given mesh is active
  33732. * @param mesh defines the mesh to look for
  33733. * @returns true if the mesh is in the active list
  33734. */
  33735. isActiveMesh(mesh: AbstractMesh): boolean;
  33736. /**
  33737. * Return a unique id as a string which can serve as an identifier for the scene
  33738. */
  33739. readonly uid: string;
  33740. /**
  33741. * Add an externaly attached data from its key.
  33742. * This method call will fail and return false, if such key already exists.
  33743. * If you don't care and just want to get the data no matter what, use the more convenient getOrAddExternalDataWithFactory() method.
  33744. * @param key the unique key that identifies the data
  33745. * @param data the data object to associate to the key for this Engine instance
  33746. * @return true if no such key were already present and the data was added successfully, false otherwise
  33747. */
  33748. addExternalData<T>(key: string, data: T): boolean;
  33749. /**
  33750. * Get an externaly attached data from its key
  33751. * @param key the unique key that identifies the data
  33752. * @return the associated data, if present (can be null), or undefined if not present
  33753. */
  33754. getExternalData<T>(key: string): Nullable<T>;
  33755. /**
  33756. * Get an externaly attached data from its key, create it using a factory if it's not already present
  33757. * @param key the unique key that identifies the data
  33758. * @param factory the factory that will be called to create the instance if and only if it doesn't exists
  33759. * @return the associated data, can be null if the factory returned null.
  33760. */
  33761. getOrAddExternalDataWithFactory<T>(key: string, factory: (k: string) => T): T;
  33762. /**
  33763. * Remove an externaly attached data from the Engine instance
  33764. * @param key the unique key that identifies the data
  33765. * @return true if the data was successfully removed, false if it doesn't exist
  33766. */
  33767. removeExternalData(key: string): boolean;
  33768. private _evaluateSubMesh;
  33769. /**
  33770. * Clear the processed materials smart array preventing retention point in material dispose.
  33771. */
  33772. freeProcessedMaterials(): void;
  33773. private _preventFreeActiveMeshesAndRenderingGroups;
  33774. /** Gets or sets a boolean blocking all the calls to freeActiveMeshes and freeRenderingGroups
  33775. * It can be used in order to prevent going through methods freeRenderingGroups and freeActiveMeshes several times to improve performance
  33776. * when disposing several meshes in a row or a hierarchy of meshes.
  33777. * When used, it is the responsability of the user to blockfreeActiveMeshesAndRenderingGroups back to false.
  33778. */
  33779. blockfreeActiveMeshesAndRenderingGroups: boolean;
  33780. /**
  33781. * Clear the active meshes smart array preventing retention point in mesh dispose.
  33782. */
  33783. freeActiveMeshes(): void;
  33784. /**
  33785. * Clear the info related to rendering groups preventing retention points during dispose.
  33786. */
  33787. freeRenderingGroups(): void;
  33788. /** @hidden */
  33789. _isInIntermediateRendering(): boolean;
  33790. /**
  33791. * Lambda returning the list of potentially active meshes.
  33792. */
  33793. getActiveMeshCandidates: () => ISmartArrayLike<AbstractMesh>;
  33794. /**
  33795. * Lambda returning the list of potentially active sub meshes.
  33796. */
  33797. getActiveSubMeshCandidates: (mesh: AbstractMesh) => ISmartArrayLike<SubMesh>;
  33798. /**
  33799. * Lambda returning the list of potentially intersecting sub meshes.
  33800. */
  33801. getIntersectingSubMeshCandidates: (mesh: AbstractMesh, localRay: Ray) => ISmartArrayLike<SubMesh>;
  33802. /**
  33803. * Lambda returning the list of potentially colliding sub meshes.
  33804. */
  33805. getCollidingSubMeshCandidates: (mesh: AbstractMesh, collider: Collider) => ISmartArrayLike<SubMesh>;
  33806. private _activeMeshesFrozen;
  33807. /**
  33808. * Use this function to stop evaluating active meshes. The current list will be keep alive between frames
  33809. * @returns the current scene
  33810. */
  33811. freezeActiveMeshes(): Scene;
  33812. /**
  33813. * Use this function to restart evaluating active meshes on every frame
  33814. * @returns the current scene
  33815. */
  33816. unfreezeActiveMeshes(): Scene;
  33817. private _evaluateActiveMeshes;
  33818. private _activeMesh;
  33819. /**
  33820. * Update the transform matrix to update from the current active camera
  33821. * @param force defines a boolean used to force the update even if cache is up to date
  33822. */
  33823. updateTransformMatrix(force?: boolean): void;
  33824. /**
  33825. * 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)
  33826. * @param alternateCamera defines the camera to use
  33827. */
  33828. updateAlternateTransformMatrix(alternateCamera: Camera): void;
  33829. /** @hidden */
  33830. _allowPostProcessClearColor: boolean;
  33831. private _renderForCamera;
  33832. private _processSubCameras;
  33833. private _checkIntersections;
  33834. /** @hidden */
  33835. _advancePhysicsEngineStep(step: number): void;
  33836. /**
  33837. * User updatable function that will return a deterministic frame time when engine is in deterministic lock step mode
  33838. */
  33839. getDeterministicFrameTime: () => number;
  33840. /** @hidden */
  33841. _animate(): void;
  33842. /**
  33843. * Render the scene
  33844. * @param updateCameras defines a boolean indicating if cameras must update according to their inputs (true by default)
  33845. */
  33846. render(updateCameras?: boolean): void;
  33847. /**
  33848. * Freeze all materials
  33849. * A frozen material will not be updatable but should be faster to render
  33850. */
  33851. freezeMaterials(): void;
  33852. /**
  33853. * Unfreeze all materials
  33854. * A frozen material will not be updatable but should be faster to render
  33855. */
  33856. unfreezeMaterials(): void;
  33857. /**
  33858. * Releases all held ressources
  33859. */
  33860. dispose(): void;
  33861. /**
  33862. * Gets if the scene is already disposed
  33863. */
  33864. readonly isDisposed: boolean;
  33865. /**
  33866. * Call this function to reduce memory footprint of the scene.
  33867. * Vertex buffers will not store CPU data anymore (this will prevent picking, collisions or physics to work correctly)
  33868. */
  33869. clearCachedVertexData(): void;
  33870. /**
  33871. * This function will remove the local cached buffer data from texture.
  33872. * It will save memory but will prevent the texture from being rebuilt
  33873. */
  33874. cleanCachedTextureBuffer(): void;
  33875. /**
  33876. * Get the world extend vectors with an optional filter
  33877. *
  33878. * @param filterPredicate the predicate - which meshes should be included when calculating the world size
  33879. * @returns {{ min: Vector3; max: Vector3 }} min and max vectors
  33880. */
  33881. getWorldExtends(filterPredicate?: (mesh: AbstractMesh) => boolean): {
  33882. min: Vector3;
  33883. max: Vector3;
  33884. };
  33885. /**
  33886. * Creates a ray that can be used to pick in the scene
  33887. * @param x defines the x coordinate of the origin (on-screen)
  33888. * @param y defines the y coordinate of the origin (on-screen)
  33889. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  33890. * @param camera defines the camera to use for the picking
  33891. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  33892. * @returns a Ray
  33893. */
  33894. createPickingRay(x: number, y: number, world: Matrix, camera: Nullable<Camera>, cameraViewSpace?: boolean): Ray;
  33895. /**
  33896. * Creates a ray that can be used to pick in the scene
  33897. * @param x defines the x coordinate of the origin (on-screen)
  33898. * @param y defines the y coordinate of the origin (on-screen)
  33899. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  33900. * @param result defines the ray where to store the picking ray
  33901. * @param camera defines the camera to use for the picking
  33902. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  33903. * @returns the current scene
  33904. */
  33905. createPickingRayToRef(x: number, y: number, world: Matrix, result: Ray, camera: Nullable<Camera>, cameraViewSpace?: boolean): Scene;
  33906. /**
  33907. * Creates a ray that can be used to pick in the scene
  33908. * @param x defines the x coordinate of the origin (on-screen)
  33909. * @param y defines the y coordinate of the origin (on-screen)
  33910. * @param camera defines the camera to use for the picking
  33911. * @returns a Ray
  33912. */
  33913. createPickingRayInCameraSpace(x: number, y: number, camera?: Camera): Ray;
  33914. /**
  33915. * Creates a ray that can be used to pick in the scene
  33916. * @param x defines the x coordinate of the origin (on-screen)
  33917. * @param y defines the y coordinate of the origin (on-screen)
  33918. * @param result defines the ray where to store the picking ray
  33919. * @param camera defines the camera to use for the picking
  33920. * @returns the current scene
  33921. */
  33922. createPickingRayInCameraSpaceToRef(x: number, y: number, result: Ray, camera?: Camera): Scene;
  33923. /** Launch a ray to try to pick a mesh in the scene
  33924. * @param x position on screen
  33925. * @param y position on screen
  33926. * @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
  33927. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  33928. * @param camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  33929. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  33930. * @returns a PickingInfo
  33931. */
  33932. pick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, camera?: Nullable<Camera>, trianglePredicate?: (p0: Vector3, p1: Vector3, p2: Vector3) => boolean): Nullable<PickingInfo>;
  33933. /** Use the given ray to pick a mesh in the scene
  33934. * @param ray The ray to use to pick meshes
  33935. * @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
  33936. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null
  33937. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  33938. * @returns a PickingInfo
  33939. */
  33940. pickWithRay(ray: Ray, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  33941. /**
  33942. * Launch a ray to try to pick a mesh in the scene
  33943. * @param x X position on screen
  33944. * @param y Y position on screen
  33945. * @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
  33946. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  33947. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  33948. * @returns an array of PickingInfo
  33949. */
  33950. multiPick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, camera?: Camera, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  33951. /**
  33952. * Launch a ray to try to pick a mesh in the scene
  33953. * @param ray Ray to use
  33954. * @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
  33955. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  33956. * @returns an array of PickingInfo
  33957. */
  33958. multiPickWithRay(ray: Ray, predicate: (mesh: AbstractMesh) => boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  33959. /**
  33960. * Force the value of meshUnderPointer
  33961. * @param mesh defines the mesh to use
  33962. */
  33963. setPointerOverMesh(mesh: Nullable<AbstractMesh>): void;
  33964. /**
  33965. * Gets the mesh under the pointer
  33966. * @returns a Mesh or null if no mesh is under the pointer
  33967. */
  33968. getPointerOverMesh(): Nullable<AbstractMesh>;
  33969. /** @hidden */
  33970. _rebuildGeometries(): void;
  33971. /** @hidden */
  33972. _rebuildTextures(): void;
  33973. private _getByTags;
  33974. /**
  33975. * Get a list of meshes by tags
  33976. * @param tagsQuery defines the tags query to use
  33977. * @param forEach defines a predicate used to filter results
  33978. * @returns an array of Mesh
  33979. */
  33980. getMeshesByTags(tagsQuery: string, forEach?: (mesh: AbstractMesh) => void): Mesh[];
  33981. /**
  33982. * Get a list of cameras by tags
  33983. * @param tagsQuery defines the tags query to use
  33984. * @param forEach defines a predicate used to filter results
  33985. * @returns an array of Camera
  33986. */
  33987. getCamerasByTags(tagsQuery: string, forEach?: (camera: Camera) => void): Camera[];
  33988. /**
  33989. * Get a list of lights by tags
  33990. * @param tagsQuery defines the tags query to use
  33991. * @param forEach defines a predicate used to filter results
  33992. * @returns an array of Light
  33993. */
  33994. getLightsByTags(tagsQuery: string, forEach?: (light: Light) => void): Light[];
  33995. /**
  33996. * Get a list of materials by tags
  33997. * @param tagsQuery defines the tags query to use
  33998. * @param forEach defines a predicate used to filter results
  33999. * @returns an array of Material
  34000. */
  34001. getMaterialByTags(tagsQuery: string, forEach?: (material: Material) => void): Material[];
  34002. /**
  34003. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  34004. * This allowed control for front to back rendering or reversly depending of the special needs.
  34005. *
  34006. * @param renderingGroupId The rendering group id corresponding to its index
  34007. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  34008. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  34009. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  34010. */
  34011. 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;
  34012. /**
  34013. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  34014. *
  34015. * @param renderingGroupId The rendering group id corresponding to its index
  34016. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  34017. * @param depth Automatically clears depth between groups if true and autoClear is true.
  34018. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  34019. */
  34020. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  34021. /**
  34022. * Gets the current auto clear configuration for one rendering group of the rendering
  34023. * manager.
  34024. * @param index the rendering group index to get the information for
  34025. * @returns The auto clear setup for the requested rendering group
  34026. */
  34027. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  34028. private _blockMaterialDirtyMechanism;
  34029. /** Gets or sets a boolean blocking all the calls to markAllMaterialsAsDirty (ie. the materials won't be updated if they are out of sync) */
  34030. blockMaterialDirtyMechanism: boolean;
  34031. /**
  34032. * Will flag all materials as dirty to trigger new shader compilation
  34033. * @param flag defines the flag used to specify which material part must be marked as dirty
  34034. * @param predicate If not null, it will be used to specifiy if a material has to be marked as dirty
  34035. */
  34036. markAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  34037. /** @hidden */
  34038. _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;
  34039. /** @hidden */
  34040. _loadFileAsync(url: string, useOfflineSupport?: boolean, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  34041. }
  34042. }
  34043. declare module "babylonjs/assetContainer" {
  34044. import { AbstractScene } from "babylonjs/abstractScene";
  34045. import { Scene } from "babylonjs/scene";
  34046. import { Mesh } from "babylonjs/Meshes/mesh";
  34047. /**
  34048. * Set of assets to keep when moving a scene into an asset container.
  34049. */
  34050. export class KeepAssets extends AbstractScene {
  34051. }
  34052. /**
  34053. * Container with a set of assets that can be added or removed from a scene.
  34054. */
  34055. export class AssetContainer extends AbstractScene {
  34056. /**
  34057. * The scene the AssetContainer belongs to.
  34058. */
  34059. scene: Scene;
  34060. /**
  34061. * Instantiates an AssetContainer.
  34062. * @param scene The scene the AssetContainer belongs to.
  34063. */
  34064. constructor(scene: Scene);
  34065. /**
  34066. * Adds all the assets from the container to the scene.
  34067. */
  34068. addAllToScene(): void;
  34069. /**
  34070. * Removes all the assets in the container from the scene
  34071. */
  34072. removeAllFromScene(): void;
  34073. /**
  34074. * Disposes all the assets in the container
  34075. */
  34076. dispose(): void;
  34077. private _moveAssets;
  34078. /**
  34079. * Removes all the assets contained in the scene and adds them to the container.
  34080. * @param keepAssets Set of assets to keep in the scene. (default: empty)
  34081. */
  34082. moveAllFromScene(keepAssets?: KeepAssets): void;
  34083. /**
  34084. * 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.
  34085. * @returns the root mesh
  34086. */
  34087. createRootMesh(): Mesh;
  34088. }
  34089. }
  34090. declare module "babylonjs/abstractScene" {
  34091. import { Scene } from "babylonjs/scene";
  34092. import { Nullable } from "babylonjs/types";
  34093. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  34094. import { TransformNode } from "babylonjs/Meshes/transformNode";
  34095. import { Geometry } from "babylonjs/Meshes/geometry";
  34096. import { Skeleton } from "babylonjs/Bones/skeleton";
  34097. import { MorphTargetManager } from "babylonjs/Morph/morphTargetManager";
  34098. import { AssetContainer } from "babylonjs/assetContainer";
  34099. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  34100. import { AnimationGroup } from "babylonjs/Animations/animationGroup";
  34101. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  34102. import { Material } from "babylonjs/Materials/material";
  34103. import { MultiMaterial } from "babylonjs/Materials/multiMaterial";
  34104. import { AbstractActionManager } from "babylonjs/Actions/abstractActionManager";
  34105. import { Camera } from "babylonjs/Cameras/camera";
  34106. import { Light } from "babylonjs/Lights/light";
  34107. import { Node } from "babylonjs/node";
  34108. import { Animation } from "babylonjs/Animations/animation";
  34109. /**
  34110. * Defines how the parser contract is defined.
  34111. * These parsers are used to parse a list of specific assets (like particle systems, etc..)
  34112. */
  34113. export type BabylonFileParser = (parsedData: any, scene: Scene, container: AssetContainer, rootUrl: string) => void;
  34114. /**
  34115. * Defines how the individual parser contract is defined.
  34116. * These parser can parse an individual asset
  34117. */
  34118. export type IndividualBabylonFileParser = (parsedData: any, scene: Scene, rootUrl: string) => any;
  34119. /**
  34120. * Base class of the scene acting as a container for the different elements composing a scene.
  34121. * This class is dynamically extended by the different components of the scene increasing
  34122. * flexibility and reducing coupling
  34123. */
  34124. export abstract class AbstractScene {
  34125. /**
  34126. * Stores the list of available parsers in the application.
  34127. */
  34128. private static _BabylonFileParsers;
  34129. /**
  34130. * Stores the list of available individual parsers in the application.
  34131. */
  34132. private static _IndividualBabylonFileParsers;
  34133. /**
  34134. * Adds a parser in the list of available ones
  34135. * @param name Defines the name of the parser
  34136. * @param parser Defines the parser to add
  34137. */
  34138. static AddParser(name: string, parser: BabylonFileParser): void;
  34139. /**
  34140. * Gets a general parser from the list of avaialble ones
  34141. * @param name Defines the name of the parser
  34142. * @returns the requested parser or null
  34143. */
  34144. static GetParser(name: string): Nullable<BabylonFileParser>;
  34145. /**
  34146. * Adds n individual parser in the list of available ones
  34147. * @param name Defines the name of the parser
  34148. * @param parser Defines the parser to add
  34149. */
  34150. static AddIndividualParser(name: string, parser: IndividualBabylonFileParser): void;
  34151. /**
  34152. * Gets an individual parser from the list of avaialble ones
  34153. * @param name Defines the name of the parser
  34154. * @returns the requested parser or null
  34155. */
  34156. static GetIndividualParser(name: string): Nullable<IndividualBabylonFileParser>;
  34157. /**
  34158. * Parser json data and populate both a scene and its associated container object
  34159. * @param jsonData Defines the data to parse
  34160. * @param scene Defines the scene to parse the data for
  34161. * @param container Defines the container attached to the parsing sequence
  34162. * @param rootUrl Defines the root url of the data
  34163. */
  34164. static Parse(jsonData: any, scene: Scene, container: AssetContainer, rootUrl: string): void;
  34165. /**
  34166. * Gets the list of root nodes (ie. nodes with no parent)
  34167. */
  34168. rootNodes: Node[];
  34169. /** All of the cameras added to this scene
  34170. * @see http://doc.babylonjs.com/babylon101/cameras
  34171. */
  34172. cameras: Camera[];
  34173. /**
  34174. * All of the lights added to this scene
  34175. * @see http://doc.babylonjs.com/babylon101/lights
  34176. */
  34177. lights: Light[];
  34178. /**
  34179. * All of the (abstract) meshes added to this scene
  34180. */
  34181. meshes: AbstractMesh[];
  34182. /**
  34183. * The list of skeletons added to the scene
  34184. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  34185. */
  34186. skeletons: Skeleton[];
  34187. /**
  34188. * All of the particle systems added to this scene
  34189. * @see http://doc.babylonjs.com/babylon101/particles
  34190. */
  34191. particleSystems: IParticleSystem[];
  34192. /**
  34193. * Gets a list of Animations associated with the scene
  34194. */
  34195. animations: Animation[];
  34196. /**
  34197. * All of the animation groups added to this scene
  34198. * @see http://doc.babylonjs.com/how_to/group
  34199. */
  34200. animationGroups: AnimationGroup[];
  34201. /**
  34202. * All of the multi-materials added to this scene
  34203. * @see http://doc.babylonjs.com/how_to/multi_materials
  34204. */
  34205. multiMaterials: MultiMaterial[];
  34206. /**
  34207. * All of the materials added to this scene
  34208. * In the context of a Scene, it is not supposed to be modified manually.
  34209. * Any addition or removal should be done using the addMaterial and removeMAterial Scene methods.
  34210. * Note also that the order of the Material wihin the array is not significant and might change.
  34211. * @see http://doc.babylonjs.com/babylon101/materials
  34212. */
  34213. materials: Material[];
  34214. /**
  34215. * The list of morph target managers added to the scene
  34216. * @see http://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh
  34217. */
  34218. morphTargetManagers: MorphTargetManager[];
  34219. /**
  34220. * The list of geometries used in the scene.
  34221. */
  34222. geometries: Geometry[];
  34223. /**
  34224. * All of the tranform nodes added to this scene
  34225. * In the context of a Scene, it is not supposed to be modified manually.
  34226. * Any addition or removal should be done using the addTransformNode and removeTransformNode Scene methods.
  34227. * Note also that the order of the TransformNode wihin the array is not significant and might change.
  34228. * @see http://doc.babylonjs.com/how_to/transformnode
  34229. */
  34230. transformNodes: TransformNode[];
  34231. /**
  34232. * ActionManagers available on the scene.
  34233. */
  34234. actionManagers: AbstractActionManager[];
  34235. /**
  34236. * Textures to keep.
  34237. */
  34238. textures: BaseTexture[];
  34239. }
  34240. }
  34241. declare module "babylonjs/Audio/sound" {
  34242. import { Observable } from "babylonjs/Misc/observable";
  34243. import { Vector3 } from "babylonjs/Maths/math";
  34244. import { Nullable } from "babylonjs/types";
  34245. import { Scene } from "babylonjs/scene";
  34246. import { TransformNode } from "babylonjs/Meshes/transformNode";
  34247. /**
  34248. * Defines a sound that can be played in the application.
  34249. * The sound can either be an ambient track or a simple sound played in reaction to a user action.
  34250. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  34251. */
  34252. export class Sound {
  34253. /**
  34254. * The name of the sound in the scene.
  34255. */
  34256. name: string;
  34257. /**
  34258. * Does the sound autoplay once loaded.
  34259. */
  34260. autoplay: boolean;
  34261. /**
  34262. * Does the sound loop after it finishes playing once.
  34263. */
  34264. loop: boolean;
  34265. /**
  34266. * Does the sound use a custom attenuation curve to simulate the falloff
  34267. * happening when the source gets further away from the camera.
  34268. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  34269. */
  34270. useCustomAttenuation: boolean;
  34271. /**
  34272. * The sound track id this sound belongs to.
  34273. */
  34274. soundTrackId: number;
  34275. /**
  34276. * Is this sound currently played.
  34277. */
  34278. isPlaying: boolean;
  34279. /**
  34280. * Is this sound currently paused.
  34281. */
  34282. isPaused: boolean;
  34283. /**
  34284. * Does this sound enables spatial sound.
  34285. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  34286. */
  34287. spatialSound: boolean;
  34288. /**
  34289. * Define the reference distance the sound should be heard perfectly.
  34290. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  34291. */
  34292. refDistance: number;
  34293. /**
  34294. * Define the roll off factor of spatial sounds.
  34295. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  34296. */
  34297. rolloffFactor: number;
  34298. /**
  34299. * Define the max distance the sound should be heard (intensity just became 0 at this point).
  34300. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  34301. */
  34302. maxDistance: number;
  34303. /**
  34304. * Define the distance attenuation model the sound will follow.
  34305. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  34306. */
  34307. distanceModel: string;
  34308. /**
  34309. * @hidden
  34310. * Back Compat
  34311. **/
  34312. onended: () => any;
  34313. /**
  34314. * Observable event when the current playing sound finishes.
  34315. */
  34316. onEndedObservable: Observable<Sound>;
  34317. private _panningModel;
  34318. private _playbackRate;
  34319. private _streaming;
  34320. private _startTime;
  34321. private _startOffset;
  34322. private _position;
  34323. /** @hidden */
  34324. _positionInEmitterSpace: boolean;
  34325. private _localDirection;
  34326. private _volume;
  34327. private _isReadyToPlay;
  34328. private _isDirectional;
  34329. private _readyToPlayCallback;
  34330. private _audioBuffer;
  34331. private _soundSource;
  34332. private _streamingSource;
  34333. private _soundPanner;
  34334. private _soundGain;
  34335. private _inputAudioNode;
  34336. private _outputAudioNode;
  34337. private _coneInnerAngle;
  34338. private _coneOuterAngle;
  34339. private _coneOuterGain;
  34340. private _scene;
  34341. private _connectedTransformNode;
  34342. private _customAttenuationFunction;
  34343. private _registerFunc;
  34344. private _isOutputConnected;
  34345. private _htmlAudioElement;
  34346. private _urlType;
  34347. /** @hidden */
  34348. static _SceneComponentInitialization: (scene: Scene) => void;
  34349. /**
  34350. * Create a sound and attach it to a scene
  34351. * @param name Name of your sound
  34352. * @param urlOrArrayBuffer Url to the sound to load async or ArrayBuffer, it also works with MediaStreams
  34353. * @param scene defines the scene the sound belongs to
  34354. * @param readyToPlayCallback Provide a callback function if you'd like to load your code once the sound is ready to be played
  34355. * @param options Objects to provide with the current available options: autoplay, loop, volume, spatialSound, maxDistance, rolloffFactor, refDistance, distanceModel, panningModel, streaming
  34356. */
  34357. constructor(name: string, urlOrArrayBuffer: any, scene: Scene, readyToPlayCallback?: Nullable<() => void>, options?: any);
  34358. /**
  34359. * Release the sound and its associated resources
  34360. */
  34361. dispose(): void;
  34362. /**
  34363. * Gets if the sounds is ready to be played or not.
  34364. * @returns true if ready, otherwise false
  34365. */
  34366. isReady(): boolean;
  34367. private _soundLoaded;
  34368. /**
  34369. * Sets the data of the sound from an audiobuffer
  34370. * @param audioBuffer The audioBuffer containing the data
  34371. */
  34372. setAudioBuffer(audioBuffer: AudioBuffer): void;
  34373. /**
  34374. * Updates the current sounds options such as maxdistance, loop...
  34375. * @param options A JSON object containing values named as the object properties
  34376. */
  34377. updateOptions(options: any): void;
  34378. private _createSpatialParameters;
  34379. private _updateSpatialParameters;
  34380. /**
  34381. * Switch the panning model to HRTF:
  34382. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  34383. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  34384. */
  34385. switchPanningModelToHRTF(): void;
  34386. /**
  34387. * Switch the panning model to Equal Power:
  34388. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  34389. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  34390. */
  34391. switchPanningModelToEqualPower(): void;
  34392. private _switchPanningModel;
  34393. /**
  34394. * Connect this sound to a sound track audio node like gain...
  34395. * @param soundTrackAudioNode the sound track audio node to connect to
  34396. */
  34397. connectToSoundTrackAudioNode(soundTrackAudioNode: AudioNode): void;
  34398. /**
  34399. * Transform this sound into a directional source
  34400. * @param coneInnerAngle Size of the inner cone in degree
  34401. * @param coneOuterAngle Size of the outer cone in degree
  34402. * @param coneOuterGain Volume of the sound outside the outer cone (between 0.0 and 1.0)
  34403. */
  34404. setDirectionalCone(coneInnerAngle: number, coneOuterAngle: number, coneOuterGain: number): void;
  34405. /**
  34406. * Gets or sets the inner angle for the directional cone.
  34407. */
  34408. /**
  34409. * Gets or sets the inner angle for the directional cone.
  34410. */
  34411. directionalConeInnerAngle: number;
  34412. /**
  34413. * Gets or sets the outer angle for the directional cone.
  34414. */
  34415. /**
  34416. * Gets or sets the outer angle for the directional cone.
  34417. */
  34418. directionalConeOuterAngle: number;
  34419. /**
  34420. * Sets the position of the emitter if spatial sound is enabled
  34421. * @param newPosition Defines the new posisiton
  34422. */
  34423. setPosition(newPosition: Vector3): void;
  34424. /**
  34425. * Sets the local direction of the emitter if spatial sound is enabled
  34426. * @param newLocalDirection Defines the new local direction
  34427. */
  34428. setLocalDirectionToMesh(newLocalDirection: Vector3): void;
  34429. private _updateDirection;
  34430. /** @hidden */
  34431. updateDistanceFromListener(): void;
  34432. /**
  34433. * Sets a new custom attenuation function for the sound.
  34434. * @param callback Defines the function used for the attenuation
  34435. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  34436. */
  34437. setAttenuationFunction(callback: (currentVolume: number, currentDistance: number, maxDistance: number, refDistance: number, rolloffFactor: number) => number): void;
  34438. /**
  34439. * Play the sound
  34440. * @param time (optional) Start the sound after X seconds. Start immediately (0) by default.
  34441. * @param offset (optional) Start the sound setting it at a specific time
  34442. */
  34443. play(time?: number, offset?: number): void;
  34444. private _onended;
  34445. /**
  34446. * Stop the sound
  34447. * @param time (optional) Stop the sound after X seconds. Stop immediately (0) by default.
  34448. */
  34449. stop(time?: number): void;
  34450. /**
  34451. * Put the sound in pause
  34452. */
  34453. pause(): void;
  34454. /**
  34455. * Sets a dedicated volume for this sounds
  34456. * @param newVolume Define the new volume of the sound
  34457. * @param time Define in how long the sound should be at this value
  34458. */
  34459. setVolume(newVolume: number, time?: number): void;
  34460. /**
  34461. * Set the sound play back rate
  34462. * @param newPlaybackRate Define the playback rate the sound should be played at
  34463. */
  34464. setPlaybackRate(newPlaybackRate: number): void;
  34465. /**
  34466. * Gets the volume of the sound.
  34467. * @returns the volume of the sound
  34468. */
  34469. getVolume(): number;
  34470. /**
  34471. * Attach the sound to a dedicated mesh
  34472. * @param transformNode The transform node to connect the sound with
  34473. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  34474. */
  34475. attachToMesh(transformNode: TransformNode): void;
  34476. /**
  34477. * Detach the sound from the previously attached mesh
  34478. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  34479. */
  34480. detachFromMesh(): void;
  34481. private _onRegisterAfterWorldMatrixUpdate;
  34482. /**
  34483. * Clone the current sound in the scene.
  34484. * @returns the new sound clone
  34485. */
  34486. clone(): Nullable<Sound>;
  34487. /**
  34488. * Gets the current underlying audio buffer containing the data
  34489. * @returns the audio buffer
  34490. */
  34491. getAudioBuffer(): Nullable<AudioBuffer>;
  34492. /**
  34493. * Serializes the Sound in a JSON representation
  34494. * @returns the JSON representation of the sound
  34495. */
  34496. serialize(): any;
  34497. /**
  34498. * Parse a JSON representation of a sound to innstantiate in a given scene
  34499. * @param parsedSound Define the JSON representation of the sound (usually coming from the serialize method)
  34500. * @param scene Define the scene the new parsed sound should be created in
  34501. * @param rootUrl Define the rooturl of the load in case we need to fetch relative dependencies
  34502. * @param sourceSound Define a cound place holder if do not need to instantiate a new one
  34503. * @returns the newly parsed sound
  34504. */
  34505. static Parse(parsedSound: any, scene: Scene, rootUrl: string, sourceSound?: Sound): Sound;
  34506. }
  34507. }
  34508. declare module "babylonjs/Actions/directAudioActions" {
  34509. import { Action } from "babylonjs/Actions/action";
  34510. import { Condition } from "babylonjs/Actions/condition";
  34511. import { Sound } from "babylonjs/Audio/sound";
  34512. /**
  34513. * This defines an action helpful to play a defined sound on a triggered action.
  34514. */
  34515. export class PlaySoundAction extends Action {
  34516. private _sound;
  34517. /**
  34518. * Instantiate the action
  34519. * @param triggerOptions defines the trigger options
  34520. * @param sound defines the sound to play
  34521. * @param condition defines the trigger related conditions
  34522. */
  34523. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  34524. /** @hidden */
  34525. _prepare(): void;
  34526. /**
  34527. * Execute the action and play the sound.
  34528. */
  34529. execute(): void;
  34530. /**
  34531. * Serializes the actions and its related information.
  34532. * @param parent defines the object to serialize in
  34533. * @returns the serialized object
  34534. */
  34535. serialize(parent: any): any;
  34536. }
  34537. /**
  34538. * This defines an action helpful to stop a defined sound on a triggered action.
  34539. */
  34540. export class StopSoundAction extends Action {
  34541. private _sound;
  34542. /**
  34543. * Instantiate the action
  34544. * @param triggerOptions defines the trigger options
  34545. * @param sound defines the sound to stop
  34546. * @param condition defines the trigger related conditions
  34547. */
  34548. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  34549. /** @hidden */
  34550. _prepare(): void;
  34551. /**
  34552. * Execute the action and stop the sound.
  34553. */
  34554. execute(): void;
  34555. /**
  34556. * Serializes the actions and its related information.
  34557. * @param parent defines the object to serialize in
  34558. * @returns the serialized object
  34559. */
  34560. serialize(parent: any): any;
  34561. }
  34562. }
  34563. declare module "babylonjs/Actions/interpolateValueAction" {
  34564. import { Action } from "babylonjs/Actions/action";
  34565. import { Condition } from "babylonjs/Actions/condition";
  34566. import { Observable } from "babylonjs/Misc/observable";
  34567. /**
  34568. * This defines an action responsible to change the value of a property
  34569. * by interpolating between its current value and the newly set one once triggered.
  34570. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  34571. */
  34572. export class InterpolateValueAction extends Action {
  34573. /**
  34574. * Defines the path of the property where the value should be interpolated
  34575. */
  34576. propertyPath: string;
  34577. /**
  34578. * Defines the target value at the end of the interpolation.
  34579. */
  34580. value: any;
  34581. /**
  34582. * Defines the time it will take for the property to interpolate to the value.
  34583. */
  34584. duration: number;
  34585. /**
  34586. * Defines if the other scene animations should be stopped when the action has been triggered
  34587. */
  34588. stopOtherAnimations?: boolean;
  34589. /**
  34590. * Defines a callback raised once the interpolation animation has been done.
  34591. */
  34592. onInterpolationDone?: () => void;
  34593. /**
  34594. * Observable triggered once the interpolation animation has been done.
  34595. */
  34596. onInterpolationDoneObservable: Observable<InterpolateValueAction>;
  34597. private _target;
  34598. private _effectiveTarget;
  34599. private _property;
  34600. /**
  34601. * Instantiate the action
  34602. * @param triggerOptions defines the trigger options
  34603. * @param target defines the object containing the value to interpolate
  34604. * @param propertyPath defines the path to the property in the target object
  34605. * @param value defines the target value at the end of the interpolation
  34606. * @param duration deines the time it will take for the property to interpolate to the value.
  34607. * @param condition defines the trigger related conditions
  34608. * @param stopOtherAnimations defines if the other scene animations should be stopped when the action has been triggered
  34609. * @param onInterpolationDone defines a callback raised once the interpolation animation has been done
  34610. */
  34611. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, duration?: number, condition?: Condition, stopOtherAnimations?: boolean, onInterpolationDone?: () => void);
  34612. /** @hidden */
  34613. _prepare(): void;
  34614. /**
  34615. * Execute the action starts the value interpolation.
  34616. */
  34617. execute(): void;
  34618. /**
  34619. * Serializes the actions and its related information.
  34620. * @param parent defines the object to serialize in
  34621. * @returns the serialized object
  34622. */
  34623. serialize(parent: any): any;
  34624. }
  34625. }
  34626. declare module "babylonjs/Actions/index" {
  34627. export * from "babylonjs/Actions/action";
  34628. export * from "babylonjs/Actions/actionEvent";
  34629. export * from "babylonjs/Actions/actionManager";
  34630. export * from "babylonjs/Actions/condition";
  34631. export * from "babylonjs/Actions/directActions";
  34632. export * from "babylonjs/Actions/directAudioActions";
  34633. export * from "babylonjs/Actions/interpolateValueAction";
  34634. }
  34635. declare module "babylonjs/Animations/index" {
  34636. export * from "babylonjs/Animations/animatable";
  34637. export * from "babylonjs/Animations/animation";
  34638. export * from "babylonjs/Animations/animationGroup";
  34639. export * from "babylonjs/Animations/animationPropertiesOverride";
  34640. export * from "babylonjs/Animations/easing";
  34641. export * from "babylonjs/Animations/runtimeAnimation";
  34642. export * from "babylonjs/Animations/animationEvent";
  34643. export * from "babylonjs/Animations/animationGroup";
  34644. export * from "babylonjs/Animations/animationKey";
  34645. export * from "babylonjs/Animations/animationRange";
  34646. }
  34647. declare module "babylonjs/Audio/soundTrack" {
  34648. import { Sound } from "babylonjs/Audio/sound";
  34649. import { Analyser } from "babylonjs/Audio/analyser";
  34650. import { Scene } from "babylonjs/scene";
  34651. /**
  34652. * Options allowed during the creation of a sound track.
  34653. */
  34654. export interface ISoundTrackOptions {
  34655. /**
  34656. * The volume the sound track should take during creation
  34657. */
  34658. volume?: number;
  34659. /**
  34660. * Define if the sound track is the main sound track of the scene
  34661. */
  34662. mainTrack?: boolean;
  34663. }
  34664. /**
  34665. * It could be useful to isolate your music & sounds on several tracks to better manage volume on a grouped instance of sounds.
  34666. * It will be also used in a future release to apply effects on a specific track.
  34667. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  34668. */
  34669. export class SoundTrack {
  34670. /**
  34671. * The unique identifier of the sound track in the scene.
  34672. */
  34673. id: number;
  34674. /**
  34675. * The list of sounds included in the sound track.
  34676. */
  34677. soundCollection: Array<Sound>;
  34678. private _outputAudioNode;
  34679. private _scene;
  34680. private _isMainTrack;
  34681. private _connectedAnalyser;
  34682. private _options;
  34683. private _isInitialized;
  34684. /**
  34685. * Creates a new sound track.
  34686. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  34687. * @param scene Define the scene the sound track belongs to
  34688. * @param options
  34689. */
  34690. constructor(scene: Scene, options?: ISoundTrackOptions);
  34691. private _initializeSoundTrackAudioGraph;
  34692. /**
  34693. * Release the sound track and its associated resources
  34694. */
  34695. dispose(): void;
  34696. /**
  34697. * Adds a sound to this sound track
  34698. * @param sound define the cound to add
  34699. * @ignoreNaming
  34700. */
  34701. AddSound(sound: Sound): void;
  34702. /**
  34703. * Removes a sound to this sound track
  34704. * @param sound define the cound to remove
  34705. * @ignoreNaming
  34706. */
  34707. RemoveSound(sound: Sound): void;
  34708. /**
  34709. * Set a global volume for the full sound track.
  34710. * @param newVolume Define the new volume of the sound track
  34711. */
  34712. setVolume(newVolume: number): void;
  34713. /**
  34714. * Switch the panning model to HRTF:
  34715. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  34716. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  34717. */
  34718. switchPanningModelToHRTF(): void;
  34719. /**
  34720. * Switch the panning model to Equal Power:
  34721. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  34722. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  34723. */
  34724. switchPanningModelToEqualPower(): void;
  34725. /**
  34726. * Connect the sound track to an audio analyser allowing some amazing
  34727. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  34728. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  34729. * @param analyser The analyser to connect to the engine
  34730. */
  34731. connectToAnalyser(analyser: Analyser): void;
  34732. }
  34733. }
  34734. declare module "babylonjs/Audio/audioSceneComponent" {
  34735. import { Sound } from "babylonjs/Audio/sound";
  34736. import { SoundTrack } from "babylonjs/Audio/soundTrack";
  34737. import { Nullable } from "babylonjs/types";
  34738. import { ISceneSerializableComponent } from "babylonjs/sceneComponent";
  34739. import { Scene } from "babylonjs/scene";
  34740. import { AbstractScene } from "babylonjs/abstractScene";
  34741. module "babylonjs/abstractScene" {
  34742. interface AbstractScene {
  34743. /**
  34744. * The list of sounds used in the scene.
  34745. */
  34746. sounds: Nullable<Array<Sound>>;
  34747. }
  34748. }
  34749. module "babylonjs/scene" {
  34750. interface Scene {
  34751. /**
  34752. * @hidden
  34753. * Backing field
  34754. */
  34755. _mainSoundTrack: SoundTrack;
  34756. /**
  34757. * The main sound track played by the scene.
  34758. * It cotains your primary collection of sounds.
  34759. */
  34760. mainSoundTrack: SoundTrack;
  34761. /**
  34762. * The list of sound tracks added to the scene
  34763. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  34764. */
  34765. soundTracks: Nullable<Array<SoundTrack>>;
  34766. /**
  34767. * Gets a sound using a given name
  34768. * @param name defines the name to search for
  34769. * @return the found sound or null if not found at all.
  34770. */
  34771. getSoundByName(name: string): Nullable<Sound>;
  34772. /**
  34773. * Gets or sets if audio support is enabled
  34774. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  34775. */
  34776. audioEnabled: boolean;
  34777. /**
  34778. * Gets or sets if audio will be output to headphones
  34779. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  34780. */
  34781. headphone: boolean;
  34782. }
  34783. }
  34784. /**
  34785. * Defines the sound scene component responsible to manage any sounds
  34786. * in a given scene.
  34787. */
  34788. export class AudioSceneComponent implements ISceneSerializableComponent {
  34789. /**
  34790. * The component name helpfull to identify the component in the list of scene components.
  34791. */
  34792. readonly name: string;
  34793. /**
  34794. * The scene the component belongs to.
  34795. */
  34796. scene: Scene;
  34797. private _audioEnabled;
  34798. /**
  34799. * Gets whether audio is enabled or not.
  34800. * Please use related enable/disable method to switch state.
  34801. */
  34802. readonly audioEnabled: boolean;
  34803. private _headphone;
  34804. /**
  34805. * Gets whether audio is outputing to headphone or not.
  34806. * Please use the according Switch methods to change output.
  34807. */
  34808. readonly headphone: boolean;
  34809. /**
  34810. * Creates a new instance of the component for the given scene
  34811. * @param scene Defines the scene to register the component in
  34812. */
  34813. constructor(scene: Scene);
  34814. /**
  34815. * Registers the component in a given scene
  34816. */
  34817. register(): void;
  34818. /**
  34819. * Rebuilds the elements related to this component in case of
  34820. * context lost for instance.
  34821. */
  34822. rebuild(): void;
  34823. /**
  34824. * Serializes the component data to the specified json object
  34825. * @param serializationObject The object to serialize to
  34826. */
  34827. serialize(serializationObject: any): void;
  34828. /**
  34829. * Adds all the element from the container to the scene
  34830. * @param container the container holding the elements
  34831. */
  34832. addFromContainer(container: AbstractScene): void;
  34833. /**
  34834. * Removes all the elements in the container from the scene
  34835. * @param container contains the elements to remove
  34836. */
  34837. removeFromContainer(container: AbstractScene): void;
  34838. /**
  34839. * Disposes the component and the associated ressources.
  34840. */
  34841. dispose(): void;
  34842. /**
  34843. * Disables audio in the associated scene.
  34844. */
  34845. disableAudio(): void;
  34846. /**
  34847. * Enables audio in the associated scene.
  34848. */
  34849. enableAudio(): void;
  34850. /**
  34851. * Switch audio to headphone output.
  34852. */
  34853. switchAudioModeForHeadphones(): void;
  34854. /**
  34855. * Switch audio to normal speakers.
  34856. */
  34857. switchAudioModeForNormalSpeakers(): void;
  34858. private _afterRender;
  34859. }
  34860. }
  34861. declare module "babylonjs/Audio/weightedsound" {
  34862. import { Sound } from "babylonjs/Audio/sound";
  34863. /**
  34864. * Wraps one or more Sound objects and selects one with random weight for playback.
  34865. */
  34866. export class WeightedSound {
  34867. /** When true a Sound will be selected and played when the current playing Sound completes. */
  34868. loop: boolean;
  34869. private _coneInnerAngle;
  34870. private _coneOuterAngle;
  34871. private _volume;
  34872. /** A Sound is currently playing. */
  34873. isPlaying: boolean;
  34874. /** A Sound is currently paused. */
  34875. isPaused: boolean;
  34876. private _sounds;
  34877. private _weights;
  34878. private _currentIndex?;
  34879. /**
  34880. * Creates a new WeightedSound from the list of sounds given.
  34881. * @param loop When true a Sound will be selected and played when the current playing Sound completes.
  34882. * @param sounds Array of Sounds that will be selected from.
  34883. * @param weights Array of number values for selection weights; length must equal sounds, values will be normalized to 1
  34884. */
  34885. constructor(loop: boolean, sounds: Sound[], weights: number[]);
  34886. /**
  34887. * The size of cone in degrees for a directional sound in which there will be no attenuation.
  34888. */
  34889. /**
  34890. * The size of cone in degress for a directional sound in which there will be no attenuation.
  34891. */
  34892. directionalConeInnerAngle: number;
  34893. /**
  34894. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  34895. * Listener angles between innerAngle and outerAngle will falloff linearly.
  34896. */
  34897. /**
  34898. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  34899. * Listener angles between innerAngle and outerAngle will falloff linearly.
  34900. */
  34901. directionalConeOuterAngle: number;
  34902. /**
  34903. * Playback volume.
  34904. */
  34905. /**
  34906. * Playback volume.
  34907. */
  34908. volume: number;
  34909. private _onended;
  34910. /**
  34911. * Suspend playback
  34912. */
  34913. pause(): void;
  34914. /**
  34915. * Stop playback
  34916. */
  34917. stop(): void;
  34918. /**
  34919. * Start playback.
  34920. * @param startOffset Position the clip head at a specific time in seconds.
  34921. */
  34922. play(startOffset?: number): void;
  34923. }
  34924. }
  34925. declare module "babylonjs/Audio/index" {
  34926. export * from "babylonjs/Audio/analyser";
  34927. export * from "babylonjs/Audio/audioEngine";
  34928. export * from "babylonjs/Audio/audioSceneComponent";
  34929. export * from "babylonjs/Audio/sound";
  34930. export * from "babylonjs/Audio/soundTrack";
  34931. export * from "babylonjs/Audio/weightedsound";
  34932. }
  34933. declare module "babylonjs/Behaviors/Cameras/bouncingBehavior" {
  34934. import { Behavior } from "babylonjs/Behaviors/behavior";
  34935. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  34936. import { BackEase } from "babylonjs/Animations/easing";
  34937. /**
  34938. * Add a bouncing effect to an ArcRotateCamera when reaching a specified minimum and maximum radius
  34939. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  34940. */
  34941. export class BouncingBehavior implements Behavior<ArcRotateCamera> {
  34942. /**
  34943. * Gets the name of the behavior.
  34944. */
  34945. readonly name: string;
  34946. /**
  34947. * The easing function used by animations
  34948. */
  34949. static EasingFunction: BackEase;
  34950. /**
  34951. * The easing mode used by animations
  34952. */
  34953. static EasingMode: number;
  34954. /**
  34955. * The duration of the animation, in milliseconds
  34956. */
  34957. transitionDuration: number;
  34958. /**
  34959. * Length of the distance animated by the transition when lower radius is reached
  34960. */
  34961. lowerRadiusTransitionRange: number;
  34962. /**
  34963. * Length of the distance animated by the transition when upper radius is reached
  34964. */
  34965. upperRadiusTransitionRange: number;
  34966. private _autoTransitionRange;
  34967. /**
  34968. * Gets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  34969. */
  34970. /**
  34971. * Sets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  34972. * Transition ranges will be set to 5% of the bounding box diagonal in world space
  34973. */
  34974. autoTransitionRange: boolean;
  34975. private _attachedCamera;
  34976. private _onAfterCheckInputsObserver;
  34977. private _onMeshTargetChangedObserver;
  34978. /**
  34979. * Initializes the behavior.
  34980. */
  34981. init(): void;
  34982. /**
  34983. * Attaches the behavior to its arc rotate camera.
  34984. * @param camera Defines the camera to attach the behavior to
  34985. */
  34986. attach(camera: ArcRotateCamera): void;
  34987. /**
  34988. * Detaches the behavior from its current arc rotate camera.
  34989. */
  34990. detach(): void;
  34991. private _radiusIsAnimating;
  34992. private _radiusBounceTransition;
  34993. private _animatables;
  34994. private _cachedWheelPrecision;
  34995. /**
  34996. * Checks if the camera radius is at the specified limit. Takes into account animation locks.
  34997. * @param radiusLimit The limit to check against.
  34998. * @return Bool to indicate if at limit.
  34999. */
  35000. private _isRadiusAtLimit;
  35001. /**
  35002. * Applies an animation to the radius of the camera, extending by the radiusDelta.
  35003. * @param radiusDelta The delta by which to animate to. Can be negative.
  35004. */
  35005. private _applyBoundRadiusAnimation;
  35006. /**
  35007. * Removes all animation locks. Allows new animations to be added to any of the camera properties.
  35008. */
  35009. protected _clearAnimationLocks(): void;
  35010. /**
  35011. * Stops and removes all animations that have been applied to the camera
  35012. */
  35013. stopAllAnimations(): void;
  35014. }
  35015. }
  35016. declare module "babylonjs/Behaviors/Cameras/framingBehavior" {
  35017. import { Behavior } from "babylonjs/Behaviors/behavior";
  35018. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  35019. import { ExponentialEase } from "babylonjs/Animations/easing";
  35020. import { Nullable } from "babylonjs/types";
  35021. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  35022. import { Vector3 } from "babylonjs/Maths/math";
  35023. /**
  35024. * 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.
  35025. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  35026. */
  35027. export class FramingBehavior implements Behavior<ArcRotateCamera> {
  35028. /**
  35029. * Gets the name of the behavior.
  35030. */
  35031. readonly name: string;
  35032. private _mode;
  35033. private _radiusScale;
  35034. private _positionScale;
  35035. private _defaultElevation;
  35036. private _elevationReturnTime;
  35037. private _elevationReturnWaitTime;
  35038. private _zoomStopsAnimation;
  35039. private _framingTime;
  35040. /**
  35041. * The easing function used by animations
  35042. */
  35043. static EasingFunction: ExponentialEase;
  35044. /**
  35045. * The easing mode used by animations
  35046. */
  35047. static EasingMode: number;
  35048. /**
  35049. * Sets the current mode used by the behavior
  35050. */
  35051. /**
  35052. * Gets current mode used by the behavior.
  35053. */
  35054. mode: number;
  35055. /**
  35056. * Sets the scale applied to the radius (1 by default)
  35057. */
  35058. /**
  35059. * Gets the scale applied to the radius
  35060. */
  35061. radiusScale: number;
  35062. /**
  35063. * Sets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  35064. */
  35065. /**
  35066. * Gets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  35067. */
  35068. positionScale: number;
  35069. /**
  35070. * Sets the angle above/below the horizontal plane to return to when the return to default elevation idle
  35071. * behaviour is triggered, in radians.
  35072. */
  35073. /**
  35074. * Gets the angle above/below the horizontal plane to return to when the return to default elevation idle
  35075. * behaviour is triggered, in radians.
  35076. */
  35077. defaultElevation: number;
  35078. /**
  35079. * Sets the time (in milliseconds) taken to return to the default beta position.
  35080. * Negative value indicates camera should not return to default.
  35081. */
  35082. /**
  35083. * Gets the time (in milliseconds) taken to return to the default beta position.
  35084. * Negative value indicates camera should not return to default.
  35085. */
  35086. elevationReturnTime: number;
  35087. /**
  35088. * Sets the delay (in milliseconds) taken before the camera returns to the default beta position.
  35089. */
  35090. /**
  35091. * Gets the delay (in milliseconds) taken before the camera returns to the default beta position.
  35092. */
  35093. elevationReturnWaitTime: number;
  35094. /**
  35095. * Sets the flag that indicates if user zooming should stop animation.
  35096. */
  35097. /**
  35098. * Gets the flag that indicates if user zooming should stop animation.
  35099. */
  35100. zoomStopsAnimation: boolean;
  35101. /**
  35102. * Sets the transition time when framing the mesh, in milliseconds
  35103. */
  35104. /**
  35105. * Gets the transition time when framing the mesh, in milliseconds
  35106. */
  35107. framingTime: number;
  35108. /**
  35109. * Define if the behavior should automatically change the configured
  35110. * camera limits and sensibilities.
  35111. */
  35112. autoCorrectCameraLimitsAndSensibility: boolean;
  35113. private _onPrePointerObservableObserver;
  35114. private _onAfterCheckInputsObserver;
  35115. private _onMeshTargetChangedObserver;
  35116. private _attachedCamera;
  35117. private _isPointerDown;
  35118. private _lastInteractionTime;
  35119. /**
  35120. * Initializes the behavior.
  35121. */
  35122. init(): void;
  35123. /**
  35124. * Attaches the behavior to its arc rotate camera.
  35125. * @param camera Defines the camera to attach the behavior to
  35126. */
  35127. attach(camera: ArcRotateCamera): void;
  35128. /**
  35129. * Detaches the behavior from its current arc rotate camera.
  35130. */
  35131. detach(): void;
  35132. private _animatables;
  35133. private _betaIsAnimating;
  35134. private _betaTransition;
  35135. private _radiusTransition;
  35136. private _vectorTransition;
  35137. /**
  35138. * Targets the given mesh and updates zoom level accordingly.
  35139. * @param mesh The mesh to target.
  35140. * @param radius Optional. If a cached radius position already exists, overrides default.
  35141. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  35142. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  35143. * @param onAnimationEnd Callback triggered at the end of the framing animation
  35144. */
  35145. zoomOnMesh(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  35146. /**
  35147. * Targets the given mesh with its children and updates zoom level accordingly.
  35148. * @param mesh The mesh to target.
  35149. * @param radius Optional. If a cached radius position already exists, overrides default.
  35150. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  35151. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  35152. * @param onAnimationEnd Callback triggered at the end of the framing animation
  35153. */
  35154. zoomOnMeshHierarchy(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  35155. /**
  35156. * Targets the given meshes with their children and updates zoom level accordingly.
  35157. * @param meshes The mesh to target.
  35158. * @param radius Optional. If a cached radius position already exists, overrides default.
  35159. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  35160. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  35161. * @param onAnimationEnd Callback triggered at the end of the framing animation
  35162. */
  35163. zoomOnMeshesHierarchy(meshes: AbstractMesh[], focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  35164. /**
  35165. * Targets the bounding box info defined by its extends and updates zoom level accordingly.
  35166. * @param minimumWorld Determines the smaller position of the bounding box extend
  35167. * @param maximumWorld Determines the bigger position of the bounding box extend
  35168. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  35169. * @param onAnimationEnd Callback triggered at the end of the framing animation
  35170. */
  35171. zoomOnBoundingInfo(minimumWorld: Vector3, maximumWorld: Vector3, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  35172. /**
  35173. * Calculates the lowest radius for the camera based on the bounding box of the mesh.
  35174. * @param mesh The mesh on which to base the calculation. mesh boundingInfo used to estimate necessary
  35175. * frustum width.
  35176. * @return The minimum distance from the primary mesh's center point at which the camera must be kept in order
  35177. * to fully enclose the mesh in the viewing frustum.
  35178. */
  35179. protected _calculateLowerRadiusFromModelBoundingSphere(minimumWorld: Vector3, maximumWorld: Vector3): number;
  35180. /**
  35181. * Keeps the camera above the ground plane. If the user pulls the camera below the ground plane, the camera
  35182. * is automatically returned to its default position (expected to be above ground plane).
  35183. */
  35184. private _maintainCameraAboveGround;
  35185. /**
  35186. * Returns the frustum slope based on the canvas ratio and camera FOV
  35187. * @returns The frustum slope represented as a Vector2 with X and Y slopes
  35188. */
  35189. private _getFrustumSlope;
  35190. /**
  35191. * Removes all animation locks. Allows new animations to be added to any of the arcCamera properties.
  35192. */
  35193. private _clearAnimationLocks;
  35194. /**
  35195. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  35196. */
  35197. private _applyUserInteraction;
  35198. /**
  35199. * Stops and removes all animations that have been applied to the camera
  35200. */
  35201. stopAllAnimations(): void;
  35202. /**
  35203. * Gets a value indicating if the user is moving the camera
  35204. */
  35205. readonly isUserIsMoving: boolean;
  35206. /**
  35207. * The camera can move all the way towards the mesh.
  35208. */
  35209. static IgnoreBoundsSizeMode: number;
  35210. /**
  35211. * The camera is not allowed to zoom closer to the mesh than the point at which the adjusted bounding sphere touches the frustum sides
  35212. */
  35213. static FitFrustumSidesMode: number;
  35214. }
  35215. }
  35216. declare module "babylonjs/Cameras/Inputs/BaseCameraPointersInput" {
  35217. import { Nullable } from "babylonjs/types";
  35218. import { Camera } from "babylonjs/Cameras/camera";
  35219. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  35220. import { PointerTouch } from "babylonjs/Events/pointerEvents";
  35221. /**
  35222. * Base class for Camera Pointer Inputs.
  35223. * See FollowCameraPointersInput in src/Cameras/Inputs/followCameraPointersInput.ts
  35224. * for example usage.
  35225. */
  35226. export abstract class BaseCameraPointersInput implements ICameraInput<Camera> {
  35227. /**
  35228. * Defines the camera the input is attached to.
  35229. */
  35230. abstract camera: Camera;
  35231. /**
  35232. * Whether keyboard modifier keys are pressed at time of last mouse event.
  35233. */
  35234. protected _altKey: boolean;
  35235. protected _ctrlKey: boolean;
  35236. protected _metaKey: boolean;
  35237. protected _shiftKey: boolean;
  35238. /**
  35239. * Which mouse buttons were pressed at time of last mouse event.
  35240. * https://developer.mozilla.org/en-US/docs/Web/API/MouseEvent/buttons
  35241. */
  35242. protected _buttonsPressed: number;
  35243. /**
  35244. * Defines the buttons associated with the input to handle camera move.
  35245. */
  35246. buttons: number[];
  35247. /**
  35248. * Attach the input controls to a specific dom element to get the input from.
  35249. * @param element Defines the element the controls should be listened from
  35250. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  35251. */
  35252. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  35253. /**
  35254. * Detach the current controls from the specified dom element.
  35255. * @param element Defines the element to stop listening the inputs from
  35256. */
  35257. detachControl(element: Nullable<HTMLElement>): void;
  35258. /**
  35259. * Gets the class name of the current input.
  35260. * @returns the class name
  35261. */
  35262. getClassName(): string;
  35263. /**
  35264. * Get the friendly name associated with the input class.
  35265. * @returns the input friendly name
  35266. */
  35267. getSimpleName(): string;
  35268. /**
  35269. * Called on pointer POINTERDOUBLETAP event.
  35270. * Override this method to provide functionality on POINTERDOUBLETAP event.
  35271. */
  35272. protected onDoubleTap(type: string): void;
  35273. /**
  35274. * Called on pointer POINTERMOVE event if only a single touch is active.
  35275. * Override this method to provide functionality.
  35276. */
  35277. protected onTouch(point: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  35278. /**
  35279. * Called on pointer POINTERMOVE event if multiple touches are active.
  35280. * Override this method to provide functionality.
  35281. */
  35282. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  35283. /**
  35284. * Called on JS contextmenu event.
  35285. * Override this method to provide functionality.
  35286. */
  35287. protected onContextMenu(evt: PointerEvent): void;
  35288. /**
  35289. * Called each time a new POINTERDOWN event occurs. Ie, for each button
  35290. * press.
  35291. * Override this method to provide functionality.
  35292. */
  35293. protected onButtonDown(evt: PointerEvent): void;
  35294. /**
  35295. * Called each time a new POINTERUP event occurs. Ie, for each button
  35296. * release.
  35297. * Override this method to provide functionality.
  35298. */
  35299. protected onButtonUp(evt: PointerEvent): void;
  35300. /**
  35301. * Called when window becomes inactive.
  35302. * Override this method to provide functionality.
  35303. */
  35304. protected onLostFocus(): void;
  35305. private _pointerInput;
  35306. private _observer;
  35307. private _onLostFocus;
  35308. private pointA;
  35309. private pointB;
  35310. }
  35311. }
  35312. declare module "babylonjs/Cameras/Inputs/arcRotateCameraPointersInput" {
  35313. import { Nullable } from "babylonjs/types";
  35314. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  35315. import { BaseCameraPointersInput } from "babylonjs/Cameras/Inputs/BaseCameraPointersInput";
  35316. import { PointerTouch } from "babylonjs/Events/pointerEvents";
  35317. /**
  35318. * Manage the pointers inputs to control an arc rotate camera.
  35319. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  35320. */
  35321. export class ArcRotateCameraPointersInput extends BaseCameraPointersInput {
  35322. /**
  35323. * Defines the camera the input is attached to.
  35324. */
  35325. camera: ArcRotateCamera;
  35326. /**
  35327. * Gets the class name of the current input.
  35328. * @returns the class name
  35329. */
  35330. getClassName(): string;
  35331. /**
  35332. * Defines the buttons associated with the input to handle camera move.
  35333. */
  35334. buttons: number[];
  35335. /**
  35336. * Defines the pointer angular sensibility along the X axis or how fast is
  35337. * the camera rotating.
  35338. */
  35339. angularSensibilityX: number;
  35340. /**
  35341. * Defines the pointer angular sensibility along the Y axis or how fast is
  35342. * the camera rotating.
  35343. */
  35344. angularSensibilityY: number;
  35345. /**
  35346. * Defines the pointer pinch precision or how fast is the camera zooming.
  35347. */
  35348. pinchPrecision: number;
  35349. /**
  35350. * pinchDeltaPercentage will be used instead of pinchPrecision if different
  35351. * from 0.
  35352. * It defines the percentage of current camera.radius to use as delta when
  35353. * pinch zoom is used.
  35354. */
  35355. pinchDeltaPercentage: number;
  35356. /**
  35357. * Defines the pointer panning sensibility or how fast is the camera moving.
  35358. */
  35359. panningSensibility: number;
  35360. /**
  35361. * Defines whether panning (2 fingers swipe) is enabled through multitouch.
  35362. */
  35363. multiTouchPanning: boolean;
  35364. /**
  35365. * Defines whether panning is enabled for both pan (2 fingers swipe) and
  35366. * zoom (pinch) through multitouch.
  35367. */
  35368. multiTouchPanAndZoom: boolean;
  35369. /**
  35370. * Revers pinch action direction.
  35371. */
  35372. pinchInwards: boolean;
  35373. private _isPanClick;
  35374. private _twoFingerActivityCount;
  35375. private _isPinching;
  35376. /**
  35377. * Called on pointer POINTERMOVE event if only a single touch is active.
  35378. */
  35379. protected onTouch(point: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  35380. /**
  35381. * Called on pointer POINTERDOUBLETAP event.
  35382. */
  35383. protected onDoubleTap(type: string): void;
  35384. /**
  35385. * Called on pointer POINTERMOVE event if multiple touches are active.
  35386. */
  35387. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  35388. /**
  35389. * Called each time a new POINTERDOWN event occurs. Ie, for each button
  35390. * press.
  35391. */
  35392. protected onButtonDown(evt: PointerEvent): void;
  35393. /**
  35394. * Called each time a new POINTERUP event occurs. Ie, for each button
  35395. * release.
  35396. */
  35397. protected onButtonUp(evt: PointerEvent): void;
  35398. /**
  35399. * Called when window becomes inactive.
  35400. */
  35401. protected onLostFocus(): void;
  35402. }
  35403. }
  35404. declare module "babylonjs/Cameras/Inputs/arcRotateCameraKeyboardMoveInput" {
  35405. import { Nullable } from "babylonjs/types";
  35406. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  35407. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  35408. /**
  35409. * Manage the keyboard inputs to control the movement of an arc rotate camera.
  35410. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  35411. */
  35412. export class ArcRotateCameraKeyboardMoveInput implements ICameraInput<ArcRotateCamera> {
  35413. /**
  35414. * Defines the camera the input is attached to.
  35415. */
  35416. camera: ArcRotateCamera;
  35417. /**
  35418. * Defines the list of key codes associated with the up action (increase alpha)
  35419. */
  35420. keysUp: number[];
  35421. /**
  35422. * Defines the list of key codes associated with the down action (decrease alpha)
  35423. */
  35424. keysDown: number[];
  35425. /**
  35426. * Defines the list of key codes associated with the left action (increase beta)
  35427. */
  35428. keysLeft: number[];
  35429. /**
  35430. * Defines the list of key codes associated with the right action (decrease beta)
  35431. */
  35432. keysRight: number[];
  35433. /**
  35434. * Defines the list of key codes associated with the reset action.
  35435. * Those keys reset the camera to its last stored state (with the method camera.storeState())
  35436. */
  35437. keysReset: number[];
  35438. /**
  35439. * Defines the panning sensibility of the inputs.
  35440. * (How fast is the camera paning)
  35441. */
  35442. panningSensibility: number;
  35443. /**
  35444. * Defines the zooming sensibility of the inputs.
  35445. * (How fast is the camera zooming)
  35446. */
  35447. zoomingSensibility: number;
  35448. /**
  35449. * Defines wether maintaining the alt key down switch the movement mode from
  35450. * orientation to zoom.
  35451. */
  35452. useAltToZoom: boolean;
  35453. /**
  35454. * Rotation speed of the camera
  35455. */
  35456. angularSpeed: number;
  35457. private _keys;
  35458. private _ctrlPressed;
  35459. private _altPressed;
  35460. private _onCanvasBlurObserver;
  35461. private _onKeyboardObserver;
  35462. private _engine;
  35463. private _scene;
  35464. /**
  35465. * Attach the input controls to a specific dom element to get the input from.
  35466. * @param element Defines the element the controls should be listened from
  35467. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  35468. */
  35469. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  35470. /**
  35471. * Detach the current controls from the specified dom element.
  35472. * @param element Defines the element to stop listening the inputs from
  35473. */
  35474. detachControl(element: Nullable<HTMLElement>): void;
  35475. /**
  35476. * Update the current camera state depending on the inputs that have been used this frame.
  35477. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  35478. */
  35479. checkInputs(): void;
  35480. /**
  35481. * Gets the class name of the current intput.
  35482. * @returns the class name
  35483. */
  35484. getClassName(): string;
  35485. /**
  35486. * Get the friendly name associated with the input class.
  35487. * @returns the input friendly name
  35488. */
  35489. getSimpleName(): string;
  35490. }
  35491. }
  35492. declare module "babylonjs/Cameras/Inputs/arcRotateCameraMouseWheelInput" {
  35493. import { Nullable } from "babylonjs/types";
  35494. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  35495. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  35496. /**
  35497. * Manage the mouse wheel inputs to control an arc rotate camera.
  35498. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  35499. */
  35500. export class ArcRotateCameraMouseWheelInput implements ICameraInput<ArcRotateCamera> {
  35501. /**
  35502. * Defines the camera the input is attached to.
  35503. */
  35504. camera: ArcRotateCamera;
  35505. /**
  35506. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  35507. */
  35508. wheelPrecision: number;
  35509. /**
  35510. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  35511. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  35512. */
  35513. wheelDeltaPercentage: number;
  35514. private _wheel;
  35515. private _observer;
  35516. /**
  35517. * Attach the input controls to a specific dom element to get the input from.
  35518. * @param element Defines the element the controls should be listened from
  35519. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  35520. */
  35521. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  35522. /**
  35523. * Detach the current controls from the specified dom element.
  35524. * @param element Defines the element to stop listening the inputs from
  35525. */
  35526. detachControl(element: Nullable<HTMLElement>): void;
  35527. /**
  35528. * Gets the class name of the current intput.
  35529. * @returns the class name
  35530. */
  35531. getClassName(): string;
  35532. /**
  35533. * Get the friendly name associated with the input class.
  35534. * @returns the input friendly name
  35535. */
  35536. getSimpleName(): string;
  35537. }
  35538. }
  35539. declare module "babylonjs/Cameras/arcRotateCameraInputsManager" {
  35540. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  35541. import { CameraInputsManager } from "babylonjs/Cameras/cameraInputsManager";
  35542. /**
  35543. * Default Inputs manager for the ArcRotateCamera.
  35544. * It groups all the default supported inputs for ease of use.
  35545. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  35546. */
  35547. export class ArcRotateCameraInputsManager extends CameraInputsManager<ArcRotateCamera> {
  35548. /**
  35549. * Instantiates a new ArcRotateCameraInputsManager.
  35550. * @param camera Defines the camera the inputs belong to
  35551. */
  35552. constructor(camera: ArcRotateCamera);
  35553. /**
  35554. * Add mouse wheel input support to the input manager.
  35555. * @returns the current input manager
  35556. */
  35557. addMouseWheel(): ArcRotateCameraInputsManager;
  35558. /**
  35559. * Add pointers input support to the input manager.
  35560. * @returns the current input manager
  35561. */
  35562. addPointers(): ArcRotateCameraInputsManager;
  35563. /**
  35564. * Add keyboard input support to the input manager.
  35565. * @returns the current input manager
  35566. */
  35567. addKeyboard(): ArcRotateCameraInputsManager;
  35568. }
  35569. }
  35570. declare module "babylonjs/Cameras/arcRotateCamera" {
  35571. import { Observable } from "babylonjs/Misc/observable";
  35572. import { Nullable } from "babylonjs/types";
  35573. import { Scene } from "babylonjs/scene";
  35574. import { Matrix, Vector3, Vector2 } from "babylonjs/Maths/math";
  35575. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  35576. import { AutoRotationBehavior } from "babylonjs/Behaviors/Cameras/autoRotationBehavior";
  35577. import { BouncingBehavior } from "babylonjs/Behaviors/Cameras/bouncingBehavior";
  35578. import { FramingBehavior } from "babylonjs/Behaviors/Cameras/framingBehavior";
  35579. import { Camera } from "babylonjs/Cameras/camera";
  35580. import { TargetCamera } from "babylonjs/Cameras/targetCamera";
  35581. import { ArcRotateCameraInputsManager } from "babylonjs/Cameras/arcRotateCameraInputsManager";
  35582. import { Collider } from "babylonjs/Collisions/collider";
  35583. /**
  35584. * This represents an orbital type of camera.
  35585. *
  35586. * 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.
  35587. * 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.
  35588. * @see http://doc.babylonjs.com/babylon101/cameras#arc-rotate-camera
  35589. */
  35590. export class ArcRotateCamera extends TargetCamera {
  35591. /**
  35592. * Defines the rotation angle of the camera along the longitudinal axis.
  35593. */
  35594. alpha: number;
  35595. /**
  35596. * Defines the rotation angle of the camera along the latitudinal axis.
  35597. */
  35598. beta: number;
  35599. /**
  35600. * Defines the radius of the camera from it s target point.
  35601. */
  35602. radius: number;
  35603. protected _target: Vector3;
  35604. protected _targetHost: Nullable<AbstractMesh>;
  35605. /**
  35606. * Defines the target point of the camera.
  35607. * The camera looks towards it form the radius distance.
  35608. */
  35609. target: Vector3;
  35610. /**
  35611. * Define the current local position of the camera in the scene
  35612. */
  35613. position: Vector3;
  35614. /**
  35615. * Current inertia value on the longitudinal axis.
  35616. * The bigger this number the longer it will take for the camera to stop.
  35617. */
  35618. inertialAlphaOffset: number;
  35619. /**
  35620. * Current inertia value on the latitudinal axis.
  35621. * The bigger this number the longer it will take for the camera to stop.
  35622. */
  35623. inertialBetaOffset: number;
  35624. /**
  35625. * Current inertia value on the radius axis.
  35626. * The bigger this number the longer it will take for the camera to stop.
  35627. */
  35628. inertialRadiusOffset: number;
  35629. /**
  35630. * Minimum allowed angle on the longitudinal axis.
  35631. * This can help limiting how the Camera is able to move in the scene.
  35632. */
  35633. lowerAlphaLimit: Nullable<number>;
  35634. /**
  35635. * Maximum allowed angle on the longitudinal axis.
  35636. * This can help limiting how the Camera is able to move in the scene.
  35637. */
  35638. upperAlphaLimit: Nullable<number>;
  35639. /**
  35640. * Minimum allowed angle on the latitudinal axis.
  35641. * This can help limiting how the Camera is able to move in the scene.
  35642. */
  35643. lowerBetaLimit: number;
  35644. /**
  35645. * Maximum allowed angle on the latitudinal axis.
  35646. * This can help limiting how the Camera is able to move in the scene.
  35647. */
  35648. upperBetaLimit: number;
  35649. /**
  35650. * Minimum allowed distance of the camera to the target (The camera can not get closer).
  35651. * This can help limiting how the Camera is able to move in the scene.
  35652. */
  35653. lowerRadiusLimit: Nullable<number>;
  35654. /**
  35655. * Maximum allowed distance of the camera to the target (The camera can not get further).
  35656. * This can help limiting how the Camera is able to move in the scene.
  35657. */
  35658. upperRadiusLimit: Nullable<number>;
  35659. /**
  35660. * Defines the current inertia value used during panning of the camera along the X axis.
  35661. */
  35662. inertialPanningX: number;
  35663. /**
  35664. * Defines the current inertia value used during panning of the camera along the Y axis.
  35665. */
  35666. inertialPanningY: number;
  35667. /**
  35668. * Defines the distance used to consider the camera in pan mode vs pinch/zoom.
  35669. * Basically if your fingers moves away from more than this distance you will be considered
  35670. * in pinch mode.
  35671. */
  35672. pinchToPanMaxDistance: number;
  35673. /**
  35674. * Defines the maximum distance the camera can pan.
  35675. * This could help keeping the cammera always in your scene.
  35676. */
  35677. panningDistanceLimit: Nullable<number>;
  35678. /**
  35679. * Defines the target of the camera before paning.
  35680. */
  35681. panningOriginTarget: Vector3;
  35682. /**
  35683. * Defines the value of the inertia used during panning.
  35684. * 0 would mean stop inertia and one would mean no decelleration at all.
  35685. */
  35686. panningInertia: number;
  35687. /**
  35688. * Gets or Set the pointer angular sensibility along the X axis or how fast is the camera rotating.
  35689. */
  35690. angularSensibilityX: number;
  35691. /**
  35692. * Gets or Set the pointer angular sensibility along the Y axis or how fast is the camera rotating.
  35693. */
  35694. angularSensibilityY: number;
  35695. /**
  35696. * Gets or Set the pointer pinch precision or how fast is the camera zooming.
  35697. */
  35698. pinchPrecision: number;
  35699. /**
  35700. * Gets or Set the pointer pinch delta percentage or how fast is the camera zooming.
  35701. * It will be used instead of pinchDeltaPrecision if different from 0.
  35702. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  35703. */
  35704. pinchDeltaPercentage: number;
  35705. /**
  35706. * Gets or Set the pointer panning sensibility or how fast is the camera moving.
  35707. */
  35708. panningSensibility: number;
  35709. /**
  35710. * Gets or Set the list of keyboard keys used to control beta angle in a positive direction.
  35711. */
  35712. keysUp: number[];
  35713. /**
  35714. * Gets or Set the list of keyboard keys used to control beta angle in a negative direction.
  35715. */
  35716. keysDown: number[];
  35717. /**
  35718. * Gets or Set the list of keyboard keys used to control alpha angle in a negative direction.
  35719. */
  35720. keysLeft: number[];
  35721. /**
  35722. * Gets or Set the list of keyboard keys used to control alpha angle in a positive direction.
  35723. */
  35724. keysRight: number[];
  35725. /**
  35726. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  35727. */
  35728. wheelPrecision: number;
  35729. /**
  35730. * Gets or Set the mouse wheel delta percentage or how fast is the camera zooming.
  35731. * It will be used instead of pinchDeltaPrecision if different from 0.
  35732. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  35733. */
  35734. wheelDeltaPercentage: number;
  35735. /**
  35736. * Defines how much the radius should be scaled while zomming on a particular mesh (through the zoomOn function)
  35737. */
  35738. zoomOnFactor: number;
  35739. /**
  35740. * Defines a screen offset for the camera position.
  35741. */
  35742. targetScreenOffset: Vector2;
  35743. /**
  35744. * Allows the camera to be completely reversed.
  35745. * If false the camera can not arrive upside down.
  35746. */
  35747. allowUpsideDown: boolean;
  35748. /**
  35749. * Define if double tap/click is used to restore the previously saved state of the camera.
  35750. */
  35751. useInputToRestoreState: boolean;
  35752. /** @hidden */
  35753. _viewMatrix: Matrix;
  35754. /** @hidden */
  35755. _useCtrlForPanning: boolean;
  35756. /** @hidden */
  35757. _panningMouseButton: number;
  35758. /**
  35759. * Defines the input associated to the camera.
  35760. */
  35761. inputs: ArcRotateCameraInputsManager;
  35762. /** @hidden */
  35763. _reset: () => void;
  35764. /**
  35765. * Defines the allowed panning axis.
  35766. */
  35767. panningAxis: Vector3;
  35768. protected _localDirection: Vector3;
  35769. protected _transformedDirection: Vector3;
  35770. private _bouncingBehavior;
  35771. /**
  35772. * Gets the bouncing behavior of the camera if it has been enabled.
  35773. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  35774. */
  35775. readonly bouncingBehavior: Nullable<BouncingBehavior>;
  35776. /**
  35777. * Defines if the bouncing behavior of the camera is enabled on the camera.
  35778. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  35779. */
  35780. useBouncingBehavior: boolean;
  35781. private _framingBehavior;
  35782. /**
  35783. * Gets the framing behavior of the camera if it has been enabled.
  35784. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  35785. */
  35786. readonly framingBehavior: Nullable<FramingBehavior>;
  35787. /**
  35788. * Defines if the framing behavior of the camera is enabled on the camera.
  35789. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  35790. */
  35791. useFramingBehavior: boolean;
  35792. private _autoRotationBehavior;
  35793. /**
  35794. * Gets the auto rotation behavior of the camera if it has been enabled.
  35795. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  35796. */
  35797. readonly autoRotationBehavior: Nullable<AutoRotationBehavior>;
  35798. /**
  35799. * Defines if the auto rotation behavior of the camera is enabled on the camera.
  35800. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  35801. */
  35802. useAutoRotationBehavior: boolean;
  35803. /**
  35804. * Observable triggered when the mesh target has been changed on the camera.
  35805. */
  35806. onMeshTargetChangedObservable: Observable<Nullable<AbstractMesh>>;
  35807. /**
  35808. * Event raised when the camera is colliding with a mesh.
  35809. */
  35810. onCollide: (collidedMesh: AbstractMesh) => void;
  35811. /**
  35812. * Defines whether the camera should check collision with the objects oh the scene.
  35813. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#how-can-i-do-this
  35814. */
  35815. checkCollisions: boolean;
  35816. /**
  35817. * Defines the collision radius of the camera.
  35818. * This simulates a sphere around the camera.
  35819. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  35820. */
  35821. collisionRadius: Vector3;
  35822. protected _collider: Collider;
  35823. protected _previousPosition: Vector3;
  35824. protected _collisionVelocity: Vector3;
  35825. protected _newPosition: Vector3;
  35826. protected _previousAlpha: number;
  35827. protected _previousBeta: number;
  35828. protected _previousRadius: number;
  35829. protected _collisionTriggered: boolean;
  35830. protected _targetBoundingCenter: Nullable<Vector3>;
  35831. private _computationVector;
  35832. private _tempAxisVector;
  35833. private _tempAxisRotationMatrix;
  35834. /**
  35835. * Instantiates a new ArcRotateCamera in a given scene
  35836. * @param name Defines the name of the camera
  35837. * @param alpha Defines the camera rotation along the logitudinal axis
  35838. * @param beta Defines the camera rotation along the latitudinal axis
  35839. * @param radius Defines the camera distance from its target
  35840. * @param target Defines the camera target
  35841. * @param scene Defines the scene the camera belongs to
  35842. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  35843. */
  35844. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  35845. /** @hidden */
  35846. _initCache(): void;
  35847. /** @hidden */
  35848. _updateCache(ignoreParentClass?: boolean): void;
  35849. protected _getTargetPosition(): Vector3;
  35850. private _storedAlpha;
  35851. private _storedBeta;
  35852. private _storedRadius;
  35853. private _storedTarget;
  35854. /**
  35855. * Stores the current state of the camera (alpha, beta, radius and target)
  35856. * @returns the camera itself
  35857. */
  35858. storeState(): Camera;
  35859. /**
  35860. * @hidden
  35861. * Restored camera state. You must call storeState() first
  35862. */
  35863. _restoreStateValues(): boolean;
  35864. /** @hidden */
  35865. _isSynchronizedViewMatrix(): boolean;
  35866. /**
  35867. * Attached controls to the current camera.
  35868. * @param element Defines the element the controls should be listened from
  35869. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  35870. * @param useCtrlForPanning Defines whether ctrl is used for paning within the controls
  35871. * @param panningMouseButton Defines whether panning is allowed through mouse click button
  35872. */
  35873. attachControl(element: HTMLElement, noPreventDefault?: boolean, useCtrlForPanning?: boolean, panningMouseButton?: number): void;
  35874. /**
  35875. * Detach the current controls from the camera.
  35876. * The camera will stop reacting to inputs.
  35877. * @param element Defines the element to stop listening the inputs from
  35878. */
  35879. detachControl(element: HTMLElement): void;
  35880. /** @hidden */
  35881. _checkInputs(): void;
  35882. protected _checkLimits(): void;
  35883. /**
  35884. * Rebuilds angles (alpha, beta) and radius from the give position and target
  35885. * @param updateView defines a boolean forcing the camera to update its position with a view matrix computation first (default is true)
  35886. */
  35887. rebuildAnglesAndRadius(updateView?: boolean): void;
  35888. /**
  35889. * Use a position to define the current camera related information like aplha, beta and radius
  35890. * @param position Defines the position to set the camera at
  35891. */
  35892. setPosition(position: Vector3): void;
  35893. /**
  35894. * Defines the target the camera should look at.
  35895. * This will automatically adapt alpha beta and radius to fit within the new target.
  35896. * @param target Defines the new target as a Vector or a mesh
  35897. * @param toBoundingCenter In case of a mesh target, defines wether to target the mesh position or its bounding information center
  35898. * @param allowSamePosition If false, prevents reapplying the new computed position if it is identical to the current one (optim)
  35899. */
  35900. setTarget(target: AbstractMesh | Vector3, toBoundingCenter?: boolean, allowSamePosition?: boolean): void;
  35901. /** @hidden */
  35902. _getViewMatrix(): Matrix;
  35903. protected _onCollisionPositionChange: (collisionId: number, newPosition: Vector3, collidedMesh?: Nullable<AbstractMesh>) => void;
  35904. /**
  35905. * Zooms on a mesh to be at the min distance where we could see it fully in the current viewport.
  35906. * @param meshes Defines the mesh to zoom on
  35907. * @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)
  35908. */
  35909. zoomOn(meshes?: AbstractMesh[], doNotUpdateMaxZ?: boolean): void;
  35910. /**
  35911. * Focus on a mesh or a bounding box. This adapts the target and maxRadius if necessary but does not update the current radius.
  35912. * The target will be changed but the radius
  35913. * @param meshesOrMinMaxVectorAndDistance Defines the mesh or bounding info to focus on
  35914. * @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)
  35915. */
  35916. focusOn(meshesOrMinMaxVectorAndDistance: AbstractMesh[] | {
  35917. min: Vector3;
  35918. max: Vector3;
  35919. distance: number;
  35920. }, doNotUpdateMaxZ?: boolean): void;
  35921. /**
  35922. * @override
  35923. * Override Camera.createRigCamera
  35924. */
  35925. createRigCamera(name: string, cameraIndex: number): Camera;
  35926. /**
  35927. * @hidden
  35928. * @override
  35929. * Override Camera._updateRigCameras
  35930. */
  35931. _updateRigCameras(): void;
  35932. /**
  35933. * Destroy the camera and release the current resources hold by it.
  35934. */
  35935. dispose(): void;
  35936. /**
  35937. * Gets the current object class name.
  35938. * @return the class name
  35939. */
  35940. getClassName(): string;
  35941. }
  35942. }
  35943. declare module "babylonjs/Behaviors/Cameras/autoRotationBehavior" {
  35944. import { Behavior } from "babylonjs/Behaviors/behavior";
  35945. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  35946. /**
  35947. * The autoRotation behavior (AutoRotationBehavior) is designed to create a smooth rotation of an ArcRotateCamera when there is no user interaction.
  35948. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  35949. */
  35950. export class AutoRotationBehavior implements Behavior<ArcRotateCamera> {
  35951. /**
  35952. * Gets the name of the behavior.
  35953. */
  35954. readonly name: string;
  35955. private _zoomStopsAnimation;
  35956. private _idleRotationSpeed;
  35957. private _idleRotationWaitTime;
  35958. private _idleRotationSpinupTime;
  35959. /**
  35960. * Sets the flag that indicates if user zooming should stop animation.
  35961. */
  35962. /**
  35963. * Gets the flag that indicates if user zooming should stop animation.
  35964. */
  35965. zoomStopsAnimation: boolean;
  35966. /**
  35967. * Sets the default speed at which the camera rotates around the model.
  35968. */
  35969. /**
  35970. * Gets the default speed at which the camera rotates around the model.
  35971. */
  35972. idleRotationSpeed: number;
  35973. /**
  35974. * Sets the time (in milliseconds) to wait after user interaction before the camera starts rotating.
  35975. */
  35976. /**
  35977. * Gets the time (milliseconds) to wait after user interaction before the camera starts rotating.
  35978. */
  35979. idleRotationWaitTime: number;
  35980. /**
  35981. * Sets the time (milliseconds) to take to spin up to the full idle rotation speed.
  35982. */
  35983. /**
  35984. * Gets the time (milliseconds) to take to spin up to the full idle rotation speed.
  35985. */
  35986. idleRotationSpinupTime: number;
  35987. /**
  35988. * Gets a value indicating if the camera is currently rotating because of this behavior
  35989. */
  35990. readonly rotationInProgress: boolean;
  35991. private _onPrePointerObservableObserver;
  35992. private _onAfterCheckInputsObserver;
  35993. private _attachedCamera;
  35994. private _isPointerDown;
  35995. private _lastFrameTime;
  35996. private _lastInteractionTime;
  35997. private _cameraRotationSpeed;
  35998. /**
  35999. * Initializes the behavior.
  36000. */
  36001. init(): void;
  36002. /**
  36003. * Attaches the behavior to its arc rotate camera.
  36004. * @param camera Defines the camera to attach the behavior to
  36005. */
  36006. attach(camera: ArcRotateCamera): void;
  36007. /**
  36008. * Detaches the behavior from its current arc rotate camera.
  36009. */
  36010. detach(): void;
  36011. /**
  36012. * Returns true if user is scrolling.
  36013. * @return true if user is scrolling.
  36014. */
  36015. private _userIsZooming;
  36016. private _lastFrameRadius;
  36017. private _shouldAnimationStopForInteraction;
  36018. /**
  36019. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  36020. */
  36021. private _applyUserInteraction;
  36022. private _userIsMoving;
  36023. }
  36024. }
  36025. declare module "babylonjs/Behaviors/Cameras/index" {
  36026. export * from "babylonjs/Behaviors/Cameras/autoRotationBehavior";
  36027. export * from "babylonjs/Behaviors/Cameras/bouncingBehavior";
  36028. export * from "babylonjs/Behaviors/Cameras/framingBehavior";
  36029. }
  36030. declare module "babylonjs/Behaviors/Meshes/attachToBoxBehavior" {
  36031. import { Mesh } from "babylonjs/Meshes/mesh";
  36032. import { TransformNode } from "babylonjs/Meshes/transformNode";
  36033. import { Behavior } from "babylonjs/Behaviors/behavior";
  36034. /**
  36035. * A behavior that when attached to a mesh will will place a specified node on the meshes face pointing towards the camera
  36036. */
  36037. export class AttachToBoxBehavior implements Behavior<Mesh> {
  36038. private ui;
  36039. /**
  36040. * The name of the behavior
  36041. */
  36042. name: string;
  36043. /**
  36044. * The distance away from the face of the mesh that the UI should be attached to (default: 0.15)
  36045. */
  36046. distanceAwayFromFace: number;
  36047. /**
  36048. * The distance from the bottom of the face that the UI should be attached to (default: 0.15)
  36049. */
  36050. distanceAwayFromBottomOfFace: number;
  36051. private _faceVectors;
  36052. private _target;
  36053. private _scene;
  36054. private _onRenderObserver;
  36055. private _tmpMatrix;
  36056. private _tmpVector;
  36057. /**
  36058. * Creates the AttachToBoxBehavior, used to attach UI to the closest face of the box to a camera
  36059. * @param ui The transform node that should be attched to the mesh
  36060. */
  36061. constructor(ui: TransformNode);
  36062. /**
  36063. * Initializes the behavior
  36064. */
  36065. init(): void;
  36066. private _closestFace;
  36067. private _zeroVector;
  36068. private _lookAtTmpMatrix;
  36069. private _lookAtToRef;
  36070. /**
  36071. * Attaches the AttachToBoxBehavior to the passed in mesh
  36072. * @param target The mesh that the specified node will be attached to
  36073. */
  36074. attach(target: Mesh): void;
  36075. /**
  36076. * Detaches the behavior from the mesh
  36077. */
  36078. detach(): void;
  36079. }
  36080. }
  36081. declare module "babylonjs/Behaviors/Meshes/fadeInOutBehavior" {
  36082. import { Behavior } from "babylonjs/Behaviors/behavior";
  36083. import { Mesh } from "babylonjs/Meshes/mesh";
  36084. /**
  36085. * A behavior that when attached to a mesh will allow the mesh to fade in and out
  36086. */
  36087. export class FadeInOutBehavior implements Behavior<Mesh> {
  36088. /**
  36089. * Time in milliseconds to delay before fading in (Default: 0)
  36090. */
  36091. delay: number;
  36092. /**
  36093. * Time in milliseconds for the mesh to fade in (Default: 300)
  36094. */
  36095. fadeInTime: number;
  36096. private _millisecondsPerFrame;
  36097. private _hovered;
  36098. private _hoverValue;
  36099. private _ownerNode;
  36100. /**
  36101. * Instatiates the FadeInOutBehavior
  36102. */
  36103. constructor();
  36104. /**
  36105. * The name of the behavior
  36106. */
  36107. readonly name: string;
  36108. /**
  36109. * Initializes the behavior
  36110. */
  36111. init(): void;
  36112. /**
  36113. * Attaches the fade behavior on the passed in mesh
  36114. * @param ownerNode The mesh that will be faded in/out once attached
  36115. */
  36116. attach(ownerNode: Mesh): void;
  36117. /**
  36118. * Detaches the behavior from the mesh
  36119. */
  36120. detach(): void;
  36121. /**
  36122. * Triggers the mesh to begin fading in or out
  36123. * @param value if the object should fade in or out (true to fade in)
  36124. */
  36125. fadeIn(value: boolean): void;
  36126. private _update;
  36127. private _setAllVisibility;
  36128. }
  36129. }
  36130. declare module "babylonjs/Misc/pivotTools" {
  36131. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  36132. /**
  36133. * Class containing a set of static utilities functions for managing Pivots
  36134. * @hidden
  36135. */
  36136. export class PivotTools {
  36137. private static _PivotCached;
  36138. private static _OldPivotPoint;
  36139. private static _PivotTranslation;
  36140. private static _PivotTmpVector;
  36141. /** @hidden */
  36142. static _RemoveAndStorePivotPoint(mesh: AbstractMesh): void;
  36143. /** @hidden */
  36144. static _RestorePivotPoint(mesh: AbstractMesh): void;
  36145. }
  36146. }
  36147. declare module "babylonjs/Meshes/Builders/planeBuilder" {
  36148. import { Scene } from "babylonjs/scene";
  36149. import { Vector4, Plane } from "babylonjs/Maths/math";
  36150. import { Mesh } from "babylonjs/Meshes/mesh";
  36151. /**
  36152. * Class containing static functions to help procedurally build meshes
  36153. */
  36154. export class PlaneBuilder {
  36155. /**
  36156. * Creates a plane mesh
  36157. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  36158. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  36159. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  36160. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  36161. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  36162. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  36163. * @param name defines the name of the mesh
  36164. * @param options defines the options used to create the mesh
  36165. * @param scene defines the hosting scene
  36166. * @returns the plane mesh
  36167. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  36168. */
  36169. static CreatePlane(name: string, options: {
  36170. size?: number;
  36171. width?: number;
  36172. height?: number;
  36173. sideOrientation?: number;
  36174. frontUVs?: Vector4;
  36175. backUVs?: Vector4;
  36176. updatable?: boolean;
  36177. sourcePlane?: Plane;
  36178. }, scene: Scene): Mesh;
  36179. }
  36180. }
  36181. declare module "babylonjs/Behaviors/Meshes/pointerDragBehavior" {
  36182. import { Behavior } from "babylonjs/Behaviors/behavior";
  36183. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  36184. import { Observable } from "babylonjs/Misc/observable";
  36185. import { Vector3 } from "babylonjs/Maths/math";
  36186. import { Ray } from "babylonjs/Culling/ray";
  36187. import "babylonjs/Meshes/Builders/planeBuilder";
  36188. /**
  36189. * A behavior that when attached to a mesh will allow the mesh to be dragged around the screen based on pointer events
  36190. */
  36191. export class PointerDragBehavior implements Behavior<AbstractMesh> {
  36192. private static _AnyMouseID;
  36193. private _attachedNode;
  36194. private _dragPlane;
  36195. private _scene;
  36196. private _pointerObserver;
  36197. private _beforeRenderObserver;
  36198. private static _planeScene;
  36199. private _useAlternatePickedPointAboveMaxDragAngleDragSpeed;
  36200. /**
  36201. * 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)
  36202. */
  36203. maxDragAngle: number;
  36204. /**
  36205. * @hidden
  36206. */
  36207. _useAlternatePickedPointAboveMaxDragAngle: boolean;
  36208. /**
  36209. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  36210. */
  36211. currentDraggingPointerID: number;
  36212. /**
  36213. * The last position where the pointer hit the drag plane in world space
  36214. */
  36215. lastDragPosition: Vector3;
  36216. /**
  36217. * If the behavior is currently in a dragging state
  36218. */
  36219. dragging: boolean;
  36220. /**
  36221. * 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)
  36222. */
  36223. dragDeltaRatio: number;
  36224. /**
  36225. * If the drag plane orientation should be updated during the dragging (Default: true)
  36226. */
  36227. updateDragPlane: boolean;
  36228. private _debugMode;
  36229. private _moving;
  36230. /**
  36231. * Fires each time the attached mesh is dragged with the pointer
  36232. * * delta between last drag position and current drag position in world space
  36233. * * dragDistance along the drag axis
  36234. * * dragPlaneNormal normal of the current drag plane used during the drag
  36235. * * dragPlanePoint in world space where the drag intersects the drag plane
  36236. */
  36237. onDragObservable: Observable<{
  36238. delta: Vector3;
  36239. dragPlanePoint: Vector3;
  36240. dragPlaneNormal: Vector3;
  36241. dragDistance: number;
  36242. pointerId: number;
  36243. }>;
  36244. /**
  36245. * Fires each time a drag begins (eg. mouse down on mesh)
  36246. */
  36247. onDragStartObservable: Observable<{
  36248. dragPlanePoint: Vector3;
  36249. pointerId: number;
  36250. }>;
  36251. /**
  36252. * Fires each time a drag ends (eg. mouse release after drag)
  36253. */
  36254. onDragEndObservable: Observable<{
  36255. dragPlanePoint: Vector3;
  36256. pointerId: number;
  36257. }>;
  36258. /**
  36259. * If the attached mesh should be moved when dragged
  36260. */
  36261. moveAttached: boolean;
  36262. /**
  36263. * If the drag behavior will react to drag events (Default: true)
  36264. */
  36265. enabled: boolean;
  36266. /**
  36267. * If camera controls should be detached during the drag
  36268. */
  36269. detachCameraControls: boolean;
  36270. /**
  36271. * If set, the drag plane/axis will be rotated based on the attached mesh's world rotation (Default: true)
  36272. */
  36273. useObjectOrienationForDragging: boolean;
  36274. private _options;
  36275. /**
  36276. * Creates a pointer drag behavior that can be attached to a mesh
  36277. * @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)
  36278. */
  36279. constructor(options?: {
  36280. dragAxis?: Vector3;
  36281. dragPlaneNormal?: Vector3;
  36282. });
  36283. /**
  36284. * Predicate to determine if it is valid to move the object to a new position when it is moved
  36285. */
  36286. validateDrag: (targetPosition: Vector3) => boolean;
  36287. /**
  36288. * The name of the behavior
  36289. */
  36290. readonly name: string;
  36291. /**
  36292. * Initializes the behavior
  36293. */
  36294. init(): void;
  36295. private _tmpVector;
  36296. private _alternatePickedPoint;
  36297. private _worldDragAxis;
  36298. private _targetPosition;
  36299. private _attachedElement;
  36300. /**
  36301. * Attaches the drag behavior the passed in mesh
  36302. * @param ownerNode The mesh that will be dragged around once attached
  36303. */
  36304. attach(ownerNode: AbstractMesh): void;
  36305. /**
  36306. * Force relase the drag action by code.
  36307. */
  36308. releaseDrag(): void;
  36309. private _startDragRay;
  36310. private _lastPointerRay;
  36311. /**
  36312. * Simulates the start of a pointer drag event on the behavior
  36313. * @param pointerId pointerID of the pointer that should be simulated (Default: Any mouse pointer ID)
  36314. * @param fromRay initial ray of the pointer to be simulated (Default: Ray from camera to attached mesh)
  36315. * @param startPickedPoint picked point of the pointer to be simulated (Default: attached mesh position)
  36316. */
  36317. startDrag(pointerId?: number, fromRay?: Ray, startPickedPoint?: Vector3): void;
  36318. private _startDrag;
  36319. private _dragDelta;
  36320. private _moveDrag;
  36321. private _pickWithRayOnDragPlane;
  36322. private _pointA;
  36323. private _pointB;
  36324. private _pointC;
  36325. private _lineA;
  36326. private _lineB;
  36327. private _localAxis;
  36328. private _lookAt;
  36329. private _updateDragPlanePosition;
  36330. /**
  36331. * Detaches the behavior from the mesh
  36332. */
  36333. detach(): void;
  36334. }
  36335. }
  36336. declare module "babylonjs/Behaviors/Meshes/multiPointerScaleBehavior" {
  36337. import { Mesh } from "babylonjs/Meshes/mesh";
  36338. import { Behavior } from "babylonjs/Behaviors/behavior";
  36339. /**
  36340. * A behavior that when attached to a mesh will allow the mesh to be scaled
  36341. */
  36342. export class MultiPointerScaleBehavior implements Behavior<Mesh> {
  36343. private _dragBehaviorA;
  36344. private _dragBehaviorB;
  36345. private _startDistance;
  36346. private _initialScale;
  36347. private _targetScale;
  36348. private _ownerNode;
  36349. private _sceneRenderObserver;
  36350. /**
  36351. * Instantiate a new behavior that when attached to a mesh will allow the mesh to be scaled
  36352. */
  36353. constructor();
  36354. /**
  36355. * The name of the behavior
  36356. */
  36357. readonly name: string;
  36358. /**
  36359. * Initializes the behavior
  36360. */
  36361. init(): void;
  36362. private _getCurrentDistance;
  36363. /**
  36364. * Attaches the scale behavior the passed in mesh
  36365. * @param ownerNode The mesh that will be scaled around once attached
  36366. */
  36367. attach(ownerNode: Mesh): void;
  36368. /**
  36369. * Detaches the behavior from the mesh
  36370. */
  36371. detach(): void;
  36372. }
  36373. }
  36374. declare module "babylonjs/Behaviors/Meshes/sixDofDragBehavior" {
  36375. import { Behavior } from "babylonjs/Behaviors/behavior";
  36376. import { Mesh } from "babylonjs/Meshes/mesh";
  36377. import { Observable } from "babylonjs/Misc/observable";
  36378. /**
  36379. * 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
  36380. */
  36381. export class SixDofDragBehavior implements Behavior<Mesh> {
  36382. private static _virtualScene;
  36383. private _ownerNode;
  36384. private _sceneRenderObserver;
  36385. private _scene;
  36386. private _targetPosition;
  36387. private _virtualOriginMesh;
  36388. private _virtualDragMesh;
  36389. private _pointerObserver;
  36390. private _moving;
  36391. private _startingOrientation;
  36392. /**
  36393. * 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)
  36394. */
  36395. private zDragFactor;
  36396. /**
  36397. * If the object should rotate to face the drag origin
  36398. */
  36399. rotateDraggedObject: boolean;
  36400. /**
  36401. * If the behavior is currently in a dragging state
  36402. */
  36403. dragging: boolean;
  36404. /**
  36405. * 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)
  36406. */
  36407. dragDeltaRatio: number;
  36408. /**
  36409. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  36410. */
  36411. currentDraggingPointerID: number;
  36412. /**
  36413. * If camera controls should be detached during the drag
  36414. */
  36415. detachCameraControls: boolean;
  36416. /**
  36417. * Fires each time a drag starts
  36418. */
  36419. onDragStartObservable: Observable<{}>;
  36420. /**
  36421. * Fires each time a drag ends (eg. mouse release after drag)
  36422. */
  36423. onDragEndObservable: Observable<{}>;
  36424. /**
  36425. * 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
  36426. */
  36427. constructor();
  36428. /**
  36429. * The name of the behavior
  36430. */
  36431. readonly name: string;
  36432. /**
  36433. * Initializes the behavior
  36434. */
  36435. init(): void;
  36436. /**
  36437. * Attaches the scale behavior the passed in mesh
  36438. * @param ownerNode The mesh that will be scaled around once attached
  36439. */
  36440. attach(ownerNode: Mesh): void;
  36441. /**
  36442. * Detaches the behavior from the mesh
  36443. */
  36444. detach(): void;
  36445. }
  36446. }
  36447. declare module "babylonjs/Behaviors/Meshes/index" {
  36448. export * from "babylonjs/Behaviors/Meshes/attachToBoxBehavior";
  36449. export * from "babylonjs/Behaviors/Meshes/fadeInOutBehavior";
  36450. export * from "babylonjs/Behaviors/Meshes/multiPointerScaleBehavior";
  36451. export * from "babylonjs/Behaviors/Meshes/pointerDragBehavior";
  36452. export * from "babylonjs/Behaviors/Meshes/sixDofDragBehavior";
  36453. }
  36454. declare module "babylonjs/Behaviors/index" {
  36455. export * from "babylonjs/Behaviors/behavior";
  36456. export * from "babylonjs/Behaviors/Cameras/index";
  36457. export * from "babylonjs/Behaviors/Meshes/index";
  36458. }
  36459. declare module "babylonjs/Bones/boneIKController" {
  36460. import { Bone } from "babylonjs/Bones/bone";
  36461. import { Vector3 } from "babylonjs/Maths/math";
  36462. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  36463. import { Nullable } from "babylonjs/types";
  36464. /**
  36465. * Class used to apply inverse kinematics to bones
  36466. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#boneikcontroller
  36467. */
  36468. export class BoneIKController {
  36469. private static _tmpVecs;
  36470. private static _tmpQuat;
  36471. private static _tmpMats;
  36472. /**
  36473. * Gets or sets the target mesh
  36474. */
  36475. targetMesh: AbstractMesh;
  36476. /** Gets or sets the mesh used as pole */
  36477. poleTargetMesh: AbstractMesh;
  36478. /**
  36479. * Gets or sets the bone used as pole
  36480. */
  36481. poleTargetBone: Nullable<Bone>;
  36482. /**
  36483. * Gets or sets the target position
  36484. */
  36485. targetPosition: Vector3;
  36486. /**
  36487. * Gets or sets the pole target position
  36488. */
  36489. poleTargetPosition: Vector3;
  36490. /**
  36491. * Gets or sets the pole target local offset
  36492. */
  36493. poleTargetLocalOffset: Vector3;
  36494. /**
  36495. * Gets or sets the pole angle
  36496. */
  36497. poleAngle: number;
  36498. /**
  36499. * Gets or sets the mesh associated with the controller
  36500. */
  36501. mesh: AbstractMesh;
  36502. /**
  36503. * 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)
  36504. */
  36505. slerpAmount: number;
  36506. private _bone1Quat;
  36507. private _bone1Mat;
  36508. private _bone2Ang;
  36509. private _bone1;
  36510. private _bone2;
  36511. private _bone1Length;
  36512. private _bone2Length;
  36513. private _maxAngle;
  36514. private _maxReach;
  36515. private _rightHandedSystem;
  36516. private _bendAxis;
  36517. private _slerping;
  36518. private _adjustRoll;
  36519. /**
  36520. * Gets or sets maximum allowed angle
  36521. */
  36522. maxAngle: number;
  36523. /**
  36524. * Creates a new BoneIKController
  36525. * @param mesh defines the mesh to control
  36526. * @param bone defines the bone to control
  36527. * @param options defines options to set up the controller
  36528. */
  36529. constructor(mesh: AbstractMesh, bone: Bone, options?: {
  36530. targetMesh?: AbstractMesh;
  36531. poleTargetMesh?: AbstractMesh;
  36532. poleTargetBone?: Bone;
  36533. poleTargetLocalOffset?: Vector3;
  36534. poleAngle?: number;
  36535. bendAxis?: Vector3;
  36536. maxAngle?: number;
  36537. slerpAmount?: number;
  36538. });
  36539. private _setMaxAngle;
  36540. /**
  36541. * Force the controller to update the bones
  36542. */
  36543. update(): void;
  36544. }
  36545. }
  36546. declare module "babylonjs/Bones/boneLookController" {
  36547. import { Vector3, Space } from "babylonjs/Maths/math";
  36548. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  36549. import { Bone } from "babylonjs/Bones/bone";
  36550. /**
  36551. * Class used to make a bone look toward a point in space
  36552. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#bonelookcontroller
  36553. */
  36554. export class BoneLookController {
  36555. private static _tmpVecs;
  36556. private static _tmpQuat;
  36557. private static _tmpMats;
  36558. /**
  36559. * The target Vector3 that the bone will look at
  36560. */
  36561. target: Vector3;
  36562. /**
  36563. * The mesh that the bone is attached to
  36564. */
  36565. mesh: AbstractMesh;
  36566. /**
  36567. * The bone that will be looking to the target
  36568. */
  36569. bone: Bone;
  36570. /**
  36571. * The up axis of the coordinate system that is used when the bone is rotated
  36572. */
  36573. upAxis: Vector3;
  36574. /**
  36575. * The space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD
  36576. */
  36577. upAxisSpace: Space;
  36578. /**
  36579. * Used to make an adjustment to the yaw of the bone
  36580. */
  36581. adjustYaw: number;
  36582. /**
  36583. * Used to make an adjustment to the pitch of the bone
  36584. */
  36585. adjustPitch: number;
  36586. /**
  36587. * Used to make an adjustment to the roll of the bone
  36588. */
  36589. adjustRoll: number;
  36590. /**
  36591. * 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)
  36592. */
  36593. slerpAmount: number;
  36594. private _minYaw;
  36595. private _maxYaw;
  36596. private _minPitch;
  36597. private _maxPitch;
  36598. private _minYawSin;
  36599. private _minYawCos;
  36600. private _maxYawSin;
  36601. private _maxYawCos;
  36602. private _midYawConstraint;
  36603. private _minPitchTan;
  36604. private _maxPitchTan;
  36605. private _boneQuat;
  36606. private _slerping;
  36607. private _transformYawPitch;
  36608. private _transformYawPitchInv;
  36609. private _firstFrameSkipped;
  36610. private _yawRange;
  36611. private _fowardAxis;
  36612. /**
  36613. * Gets or sets the minimum yaw angle that the bone can look to
  36614. */
  36615. minYaw: number;
  36616. /**
  36617. * Gets or sets the maximum yaw angle that the bone can look to
  36618. */
  36619. maxYaw: number;
  36620. /**
  36621. * Gets or sets the minimum pitch angle that the bone can look to
  36622. */
  36623. minPitch: number;
  36624. /**
  36625. * Gets or sets the maximum pitch angle that the bone can look to
  36626. */
  36627. maxPitch: number;
  36628. /**
  36629. * Create a BoneLookController
  36630. * @param mesh the mesh that the bone belongs to
  36631. * @param bone the bone that will be looking to the target
  36632. * @param target the target Vector3 to look at
  36633. * @param options optional settings:
  36634. * * maxYaw: the maximum angle the bone will yaw to
  36635. * * minYaw: the minimum angle the bone will yaw to
  36636. * * maxPitch: the maximum angle the bone will pitch to
  36637. * * minPitch: the minimum angle the bone will yaw to
  36638. * * slerpAmount: set the between 0 and 1 to make the bone slerp to the target.
  36639. * * upAxis: the up axis of the coordinate system
  36640. * * upAxisSpace: the space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD.
  36641. * * yawAxis: set yawAxis if the bone does not yaw on the y axis
  36642. * * pitchAxis: set pitchAxis if the bone does not pitch on the x axis
  36643. * * adjustYaw: used to make an adjustment to the yaw of the bone
  36644. * * adjustPitch: used to make an adjustment to the pitch of the bone
  36645. * * adjustRoll: used to make an adjustment to the roll of the bone
  36646. **/
  36647. constructor(mesh: AbstractMesh, bone: Bone, target: Vector3, options?: {
  36648. maxYaw?: number;
  36649. minYaw?: number;
  36650. maxPitch?: number;
  36651. minPitch?: number;
  36652. slerpAmount?: number;
  36653. upAxis?: Vector3;
  36654. upAxisSpace?: Space;
  36655. yawAxis?: Vector3;
  36656. pitchAxis?: Vector3;
  36657. adjustYaw?: number;
  36658. adjustPitch?: number;
  36659. adjustRoll?: number;
  36660. });
  36661. /**
  36662. * Update the bone to look at the target. This should be called before the scene is rendered (use scene.registerBeforeRender())
  36663. */
  36664. update(): void;
  36665. private _getAngleDiff;
  36666. private _getAngleBetween;
  36667. private _isAngleBetween;
  36668. }
  36669. }
  36670. declare module "babylonjs/Bones/index" {
  36671. export * from "babylonjs/Bones/bone";
  36672. export * from "babylonjs/Bones/boneIKController";
  36673. export * from "babylonjs/Bones/boneLookController";
  36674. export * from "babylonjs/Bones/skeleton";
  36675. }
  36676. declare module "babylonjs/Cameras/Inputs/arcRotateCameraGamepadInput" {
  36677. import { Nullable } from "babylonjs/types";
  36678. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  36679. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  36680. import { Gamepad } from "babylonjs/Gamepads/gamepad";
  36681. /**
  36682. * Manage the gamepad inputs to control an arc rotate camera.
  36683. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  36684. */
  36685. export class ArcRotateCameraGamepadInput implements ICameraInput<ArcRotateCamera> {
  36686. /**
  36687. * Defines the camera the input is attached to.
  36688. */
  36689. camera: ArcRotateCamera;
  36690. /**
  36691. * Defines the gamepad the input is gathering event from.
  36692. */
  36693. gamepad: Nullable<Gamepad>;
  36694. /**
  36695. * Defines the gamepad rotation sensiblity.
  36696. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  36697. */
  36698. gamepadRotationSensibility: number;
  36699. /**
  36700. * Defines the gamepad move sensiblity.
  36701. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  36702. */
  36703. gamepadMoveSensibility: number;
  36704. private _onGamepadConnectedObserver;
  36705. private _onGamepadDisconnectedObserver;
  36706. /**
  36707. * Attach the input controls to a specific dom element to get the input from.
  36708. * @param element Defines the element the controls should be listened from
  36709. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  36710. */
  36711. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  36712. /**
  36713. * Detach the current controls from the specified dom element.
  36714. * @param element Defines the element to stop listening the inputs from
  36715. */
  36716. detachControl(element: Nullable<HTMLElement>): void;
  36717. /**
  36718. * Update the current camera state depending on the inputs that have been used this frame.
  36719. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  36720. */
  36721. checkInputs(): void;
  36722. /**
  36723. * Gets the class name of the current intput.
  36724. * @returns the class name
  36725. */
  36726. getClassName(): string;
  36727. /**
  36728. * Get the friendly name associated with the input class.
  36729. * @returns the input friendly name
  36730. */
  36731. getSimpleName(): string;
  36732. }
  36733. }
  36734. declare module "babylonjs/Cameras/Inputs/arcRotateCameraVRDeviceOrientationInput" {
  36735. import { Nullable } from "babylonjs/types";
  36736. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  36737. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  36738. module "babylonjs/Cameras/arcRotateCameraInputsManager" {
  36739. interface ArcRotateCameraInputsManager {
  36740. /**
  36741. * Add orientation input support to the input manager.
  36742. * @returns the current input manager
  36743. */
  36744. addVRDeviceOrientation(): ArcRotateCameraInputsManager;
  36745. }
  36746. }
  36747. /**
  36748. * Manage the device orientation inputs (gyroscope) to control an arc rotate camera.
  36749. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  36750. */
  36751. export class ArcRotateCameraVRDeviceOrientationInput implements ICameraInput<ArcRotateCamera> {
  36752. /**
  36753. * Defines the camera the input is attached to.
  36754. */
  36755. camera: ArcRotateCamera;
  36756. /**
  36757. * Defines a correction factor applied on the alpha value retrieved from the orientation events.
  36758. */
  36759. alphaCorrection: number;
  36760. /**
  36761. * Defines a correction factor applied on the gamma value retrieved from the orientation events.
  36762. */
  36763. gammaCorrection: number;
  36764. private _alpha;
  36765. private _gamma;
  36766. private _dirty;
  36767. private _deviceOrientationHandler;
  36768. /**
  36769. * Instantiate a new ArcRotateCameraVRDeviceOrientationInput.
  36770. */
  36771. constructor();
  36772. /**
  36773. * Attach the input controls to a specific dom element to get the input from.
  36774. * @param element Defines the element the controls should be listened from
  36775. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  36776. */
  36777. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  36778. /** @hidden */
  36779. _onOrientationEvent(evt: DeviceOrientationEvent): void;
  36780. /**
  36781. * Update the current camera state depending on the inputs that have been used this frame.
  36782. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  36783. */
  36784. checkInputs(): void;
  36785. /**
  36786. * Detach the current controls from the specified dom element.
  36787. * @param element Defines the element to stop listening the inputs from
  36788. */
  36789. detachControl(element: Nullable<HTMLElement>): void;
  36790. /**
  36791. * Gets the class name of the current intput.
  36792. * @returns the class name
  36793. */
  36794. getClassName(): string;
  36795. /**
  36796. * Get the friendly name associated with the input class.
  36797. * @returns the input friendly name
  36798. */
  36799. getSimpleName(): string;
  36800. }
  36801. }
  36802. declare module "babylonjs/Cameras/Inputs/flyCameraMouseInput" {
  36803. import { Nullable } from "babylonjs/types";
  36804. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  36805. import { FlyCamera } from "babylonjs/Cameras/flyCamera";
  36806. /**
  36807. * Listen to mouse events to control the camera.
  36808. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  36809. */
  36810. export class FlyCameraMouseInput implements ICameraInput<FlyCamera> {
  36811. /**
  36812. * Defines the camera the input is attached to.
  36813. */
  36814. camera: FlyCamera;
  36815. /**
  36816. * Defines if touch is enabled. (Default is true.)
  36817. */
  36818. touchEnabled: boolean;
  36819. /**
  36820. * Defines the buttons associated with the input to handle camera rotation.
  36821. */
  36822. buttons: number[];
  36823. /**
  36824. * Assign buttons for Yaw control.
  36825. */
  36826. buttonsYaw: number[];
  36827. /**
  36828. * Assign buttons for Pitch control.
  36829. */
  36830. buttonsPitch: number[];
  36831. /**
  36832. * Assign buttons for Roll control.
  36833. */
  36834. buttonsRoll: number[];
  36835. /**
  36836. * Detect if any button is being pressed while mouse is moved.
  36837. * -1 = Mouse locked.
  36838. * 0 = Left button.
  36839. * 1 = Middle Button.
  36840. * 2 = Right Button.
  36841. */
  36842. activeButton: number;
  36843. /**
  36844. * Defines the pointer's angular sensibility, to control the camera rotation speed.
  36845. * Higher values reduce its sensitivity.
  36846. */
  36847. angularSensibility: number;
  36848. private _mousemoveCallback;
  36849. private _observer;
  36850. private _rollObserver;
  36851. private previousPosition;
  36852. private noPreventDefault;
  36853. private element;
  36854. /**
  36855. * Listen to mouse events to control the camera.
  36856. * @param touchEnabled Define if touch is enabled. (Default is true.)
  36857. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  36858. */
  36859. constructor(touchEnabled?: boolean);
  36860. /**
  36861. * Attach the mouse control to the HTML DOM element.
  36862. * @param element Defines the element that listens to the input events.
  36863. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault().
  36864. */
  36865. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  36866. /**
  36867. * Detach the current controls from the specified dom element.
  36868. * @param element Defines the element to stop listening the inputs from
  36869. */
  36870. detachControl(element: Nullable<HTMLElement>): void;
  36871. /**
  36872. * Gets the class name of the current input.
  36873. * @returns the class name.
  36874. */
  36875. getClassName(): string;
  36876. /**
  36877. * Get the friendly name associated with the input class.
  36878. * @returns the input's friendly name.
  36879. */
  36880. getSimpleName(): string;
  36881. private _pointerInput;
  36882. private _onMouseMove;
  36883. /**
  36884. * Rotate camera by mouse offset.
  36885. */
  36886. private rotateCamera;
  36887. }
  36888. }
  36889. declare module "babylonjs/Cameras/flyCameraInputsManager" {
  36890. import { FlyCamera } from "babylonjs/Cameras/flyCamera";
  36891. import { CameraInputsManager } from "babylonjs/Cameras/cameraInputsManager";
  36892. /**
  36893. * Default Inputs manager for the FlyCamera.
  36894. * It groups all the default supported inputs for ease of use.
  36895. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  36896. */
  36897. export class FlyCameraInputsManager extends CameraInputsManager<FlyCamera> {
  36898. /**
  36899. * Instantiates a new FlyCameraInputsManager.
  36900. * @param camera Defines the camera the inputs belong to.
  36901. */
  36902. constructor(camera: FlyCamera);
  36903. /**
  36904. * Add keyboard input support to the input manager.
  36905. * @returns the new FlyCameraKeyboardMoveInput().
  36906. */
  36907. addKeyboard(): FlyCameraInputsManager;
  36908. /**
  36909. * Add mouse input support to the input manager.
  36910. * @param touchEnabled Enable touch screen support.
  36911. * @returns the new FlyCameraMouseInput().
  36912. */
  36913. addMouse(touchEnabled?: boolean): FlyCameraInputsManager;
  36914. }
  36915. }
  36916. declare module "babylonjs/Cameras/flyCamera" {
  36917. import { Scene } from "babylonjs/scene";
  36918. import { Vector3, Quaternion } from "babylonjs/Maths/math";
  36919. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  36920. import { TargetCamera } from "babylonjs/Cameras/targetCamera";
  36921. import { FlyCameraInputsManager } from "babylonjs/Cameras/flyCameraInputsManager";
  36922. /**
  36923. * This is a flying camera, designed for 3D movement and rotation in all directions,
  36924. * such as in a 3D Space Shooter or a Flight Simulator.
  36925. */
  36926. export class FlyCamera extends TargetCamera {
  36927. /**
  36928. * Define the collision ellipsoid of the camera.
  36929. * This is helpful for simulating a camera body, like a player's body.
  36930. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  36931. */
  36932. ellipsoid: Vector3;
  36933. /**
  36934. * Define an offset for the position of the ellipsoid around the camera.
  36935. * This can be helpful if the camera is attached away from the player's body center,
  36936. * such as at its head.
  36937. */
  36938. ellipsoidOffset: Vector3;
  36939. /**
  36940. * Enable or disable collisions of the camera with the rest of the scene objects.
  36941. */
  36942. checkCollisions: boolean;
  36943. /**
  36944. * Enable or disable gravity on the camera.
  36945. */
  36946. applyGravity: boolean;
  36947. /**
  36948. * Define the current direction the camera is moving to.
  36949. */
  36950. cameraDirection: Vector3;
  36951. /**
  36952. * Define the current local rotation of the camera as a quaternion to prevent Gimbal lock.
  36953. * This overrides and empties cameraRotation.
  36954. */
  36955. rotationQuaternion: Quaternion;
  36956. /**
  36957. * Track Roll to maintain the wanted Rolling when looking around.
  36958. */
  36959. _trackRoll: number;
  36960. /**
  36961. * Slowly correct the Roll to its original value after a Pitch+Yaw rotation.
  36962. */
  36963. rollCorrect: number;
  36964. /**
  36965. * Mimic a banked turn, Rolling the camera when Yawing.
  36966. * It's recommended to use rollCorrect = 10 for faster banking correction.
  36967. */
  36968. bankedTurn: boolean;
  36969. /**
  36970. * Limit in radians for how much Roll banking will add. (Default: 90°)
  36971. */
  36972. bankedTurnLimit: number;
  36973. /**
  36974. * Value of 0 disables the banked Roll.
  36975. * Value of 1 is equal to the Yaw angle in radians.
  36976. */
  36977. bankedTurnMultiplier: number;
  36978. /**
  36979. * The inputs manager loads all the input sources, such as keyboard and mouse.
  36980. */
  36981. inputs: FlyCameraInputsManager;
  36982. /**
  36983. * Gets the input sensibility for mouse input.
  36984. * Higher values reduce sensitivity.
  36985. */
  36986. /**
  36987. * Sets the input sensibility for a mouse input.
  36988. * Higher values reduce sensitivity.
  36989. */
  36990. angularSensibility: number;
  36991. /**
  36992. * Get the keys for camera movement forward.
  36993. */
  36994. /**
  36995. * Set the keys for camera movement forward.
  36996. */
  36997. keysForward: number[];
  36998. /**
  36999. * Get the keys for camera movement backward.
  37000. */
  37001. keysBackward: number[];
  37002. /**
  37003. * Get the keys for camera movement up.
  37004. */
  37005. /**
  37006. * Set the keys for camera movement up.
  37007. */
  37008. keysUp: number[];
  37009. /**
  37010. * Get the keys for camera movement down.
  37011. */
  37012. /**
  37013. * Set the keys for camera movement down.
  37014. */
  37015. keysDown: number[];
  37016. /**
  37017. * Get the keys for camera movement left.
  37018. */
  37019. /**
  37020. * Set the keys for camera movement left.
  37021. */
  37022. keysLeft: number[];
  37023. /**
  37024. * Set the keys for camera movement right.
  37025. */
  37026. /**
  37027. * Set the keys for camera movement right.
  37028. */
  37029. keysRight: number[];
  37030. /**
  37031. * Event raised when the camera collides with a mesh in the scene.
  37032. */
  37033. onCollide: (collidedMesh: AbstractMesh) => void;
  37034. private _collider;
  37035. private _needMoveForGravity;
  37036. private _oldPosition;
  37037. private _diffPosition;
  37038. private _newPosition;
  37039. /** @hidden */
  37040. _localDirection: Vector3;
  37041. /** @hidden */
  37042. _transformedDirection: Vector3;
  37043. /**
  37044. * Instantiates a FlyCamera.
  37045. * This is a flying camera, designed for 3D movement and rotation in all directions,
  37046. * such as in a 3D Space Shooter or a Flight Simulator.
  37047. * @param name Define the name of the camera in the scene.
  37048. * @param position Define the starting position of the camera in the scene.
  37049. * @param scene Define the scene the camera belongs to.
  37050. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active, if no other camera has been defined as active.
  37051. */
  37052. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  37053. /**
  37054. * Attach a control to the HTML DOM element.
  37055. * @param element Defines the element that listens to the input events.
  37056. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault(). https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault
  37057. */
  37058. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  37059. /**
  37060. * Detach a control from the HTML DOM element.
  37061. * The camera will stop reacting to that input.
  37062. * @param element Defines the element that listens to the input events.
  37063. */
  37064. detachControl(element: HTMLElement): void;
  37065. private _collisionMask;
  37066. /**
  37067. * Get the mask that the camera ignores in collision events.
  37068. */
  37069. /**
  37070. * Set the mask that the camera ignores in collision events.
  37071. */
  37072. collisionMask: number;
  37073. /** @hidden */
  37074. _collideWithWorld(displacement: Vector3): void;
  37075. /** @hidden */
  37076. private _onCollisionPositionChange;
  37077. /** @hidden */
  37078. _checkInputs(): void;
  37079. /** @hidden */
  37080. _decideIfNeedsToMove(): boolean;
  37081. /** @hidden */
  37082. _updatePosition(): void;
  37083. /**
  37084. * Restore the Roll to its target value at the rate specified.
  37085. * @param rate - Higher means slower restoring.
  37086. * @hidden
  37087. */
  37088. restoreRoll(rate: number): void;
  37089. /**
  37090. * Destroy the camera and release the current resources held by it.
  37091. */
  37092. dispose(): void;
  37093. /**
  37094. * Get the current object class name.
  37095. * @returns the class name.
  37096. */
  37097. getClassName(): string;
  37098. }
  37099. }
  37100. declare module "babylonjs/Cameras/Inputs/flyCameraKeyboardInput" {
  37101. import { Nullable } from "babylonjs/types";
  37102. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  37103. import { FlyCamera } from "babylonjs/Cameras/flyCamera";
  37104. /**
  37105. * Listen to keyboard events to control the camera.
  37106. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  37107. */
  37108. export class FlyCameraKeyboardInput implements ICameraInput<FlyCamera> {
  37109. /**
  37110. * Defines the camera the input is attached to.
  37111. */
  37112. camera: FlyCamera;
  37113. /**
  37114. * The list of keyboard keys used to control the forward move of the camera.
  37115. */
  37116. keysForward: number[];
  37117. /**
  37118. * The list of keyboard keys used to control the backward move of the camera.
  37119. */
  37120. keysBackward: number[];
  37121. /**
  37122. * The list of keyboard keys used to control the forward move of the camera.
  37123. */
  37124. keysUp: number[];
  37125. /**
  37126. * The list of keyboard keys used to control the backward move of the camera.
  37127. */
  37128. keysDown: number[];
  37129. /**
  37130. * The list of keyboard keys used to control the right strafe move of the camera.
  37131. */
  37132. keysRight: number[];
  37133. /**
  37134. * The list of keyboard keys used to control the left strafe move of the camera.
  37135. */
  37136. keysLeft: number[];
  37137. private _keys;
  37138. private _onCanvasBlurObserver;
  37139. private _onKeyboardObserver;
  37140. private _engine;
  37141. private _scene;
  37142. /**
  37143. * Attach the input controls to a specific dom element to get the input from.
  37144. * @param element Defines the element the controls should be listened from
  37145. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  37146. */
  37147. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  37148. /**
  37149. * Detach the current controls from the specified dom element.
  37150. * @param element Defines the element to stop listening the inputs from
  37151. */
  37152. detachControl(element: Nullable<HTMLElement>): void;
  37153. /**
  37154. * Gets the class name of the current intput.
  37155. * @returns the class name
  37156. */
  37157. getClassName(): string;
  37158. /** @hidden */
  37159. _onLostFocus(e: FocusEvent): void;
  37160. /**
  37161. * Get the friendly name associated with the input class.
  37162. * @returns the input friendly name
  37163. */
  37164. getSimpleName(): string;
  37165. /**
  37166. * Update the current camera state depending on the inputs that have been used this frame.
  37167. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  37168. */
  37169. checkInputs(): void;
  37170. }
  37171. }
  37172. declare module "babylonjs/Cameras/Inputs/followCameraMouseWheelInput" {
  37173. import { Nullable } from "babylonjs/types";
  37174. import { FollowCamera } from "babylonjs/Cameras/followCamera";
  37175. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  37176. /**
  37177. * Manage the mouse wheel inputs to control a follow camera.
  37178. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  37179. */
  37180. export class FollowCameraMouseWheelInput implements ICameraInput<FollowCamera> {
  37181. /**
  37182. * Defines the camera the input is attached to.
  37183. */
  37184. camera: FollowCamera;
  37185. /**
  37186. * Moue wheel controls zoom. (Mouse wheel modifies camera.radius value.)
  37187. */
  37188. axisControlRadius: boolean;
  37189. /**
  37190. * Moue wheel controls height. (Mouse wheel modifies camera.heightOffset value.)
  37191. */
  37192. axisControlHeight: boolean;
  37193. /**
  37194. * Moue wheel controls angle. (Mouse wheel modifies camera.rotationOffset value.)
  37195. */
  37196. axisControlRotation: boolean;
  37197. /**
  37198. * Gets or Set the mouse wheel precision or how fast is the camera moves in
  37199. * relation to mouseWheel events.
  37200. */
  37201. wheelPrecision: number;
  37202. /**
  37203. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  37204. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  37205. */
  37206. wheelDeltaPercentage: number;
  37207. private _wheel;
  37208. private _observer;
  37209. /**
  37210. * Attach the input controls to a specific dom element to get the input from.
  37211. * @param element Defines the element the controls should be listened from
  37212. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  37213. */
  37214. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  37215. /**
  37216. * Detach the current controls from the specified dom element.
  37217. * @param element Defines the element to stop listening the inputs from
  37218. */
  37219. detachControl(element: Nullable<HTMLElement>): void;
  37220. /**
  37221. * Gets the class name of the current intput.
  37222. * @returns the class name
  37223. */
  37224. getClassName(): string;
  37225. /**
  37226. * Get the friendly name associated with the input class.
  37227. * @returns the input friendly name
  37228. */
  37229. getSimpleName(): string;
  37230. }
  37231. }
  37232. declare module "babylonjs/Cameras/Inputs/followCameraPointersInput" {
  37233. import { Nullable } from "babylonjs/types";
  37234. import { FollowCamera } from "babylonjs/Cameras/followCamera";
  37235. import { BaseCameraPointersInput } from "babylonjs/Cameras/Inputs/BaseCameraPointersInput";
  37236. import { PointerTouch } from "babylonjs/Events/pointerEvents";
  37237. /**
  37238. * Manage the pointers inputs to control an follow camera.
  37239. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  37240. */
  37241. export class FollowCameraPointersInput extends BaseCameraPointersInput {
  37242. /**
  37243. * Defines the camera the input is attached to.
  37244. */
  37245. camera: FollowCamera;
  37246. /**
  37247. * Gets the class name of the current input.
  37248. * @returns the class name
  37249. */
  37250. getClassName(): string;
  37251. /**
  37252. * Defines the pointer angular sensibility along the X axis or how fast is
  37253. * the camera rotating.
  37254. * A negative number will reverse the axis direction.
  37255. */
  37256. angularSensibilityX: number;
  37257. /**
  37258. * Defines the pointer angular sensibility along the Y axis or how fast is
  37259. * the camera rotating.
  37260. * A negative number will reverse the axis direction.
  37261. */
  37262. angularSensibilityY: number;
  37263. /**
  37264. * Defines the pointer pinch precision or how fast is the camera zooming.
  37265. * A negative number will reverse the axis direction.
  37266. */
  37267. pinchPrecision: number;
  37268. /**
  37269. * pinchDeltaPercentage will be used instead of pinchPrecision if different
  37270. * from 0.
  37271. * It defines the percentage of current camera.radius to use as delta when
  37272. * pinch zoom is used.
  37273. */
  37274. pinchDeltaPercentage: number;
  37275. /**
  37276. * Pointer X axis controls zoom. (X axis modifies camera.radius value.)
  37277. */
  37278. axisXControlRadius: boolean;
  37279. /**
  37280. * Pointer X axis controls height. (X axis modifies camera.heightOffset value.)
  37281. */
  37282. axisXControlHeight: boolean;
  37283. /**
  37284. * Pointer X axis controls angle. (X axis modifies camera.rotationOffset value.)
  37285. */
  37286. axisXControlRotation: boolean;
  37287. /**
  37288. * Pointer Y axis controls zoom. (Y axis modifies camera.radius value.)
  37289. */
  37290. axisYControlRadius: boolean;
  37291. /**
  37292. * Pointer Y axis controls height. (Y axis modifies camera.heightOffset value.)
  37293. */
  37294. axisYControlHeight: boolean;
  37295. /**
  37296. * Pointer Y axis controls angle. (Y axis modifies camera.rotationOffset value.)
  37297. */
  37298. axisYControlRotation: boolean;
  37299. /**
  37300. * Pinch controls zoom. (Pinch modifies camera.radius value.)
  37301. */
  37302. axisPinchControlRadius: boolean;
  37303. /**
  37304. * Pinch controls height. (Pinch modifies camera.heightOffset value.)
  37305. */
  37306. axisPinchControlHeight: boolean;
  37307. /**
  37308. * Pinch controls angle. (Pinch modifies camera.rotationOffset value.)
  37309. */
  37310. axisPinchControlRotation: boolean;
  37311. /**
  37312. * Log error messages if basic misconfiguration has occurred.
  37313. */
  37314. warningEnable: boolean;
  37315. protected onTouch(pointA: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  37316. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  37317. private _warningCounter;
  37318. private _warning;
  37319. }
  37320. }
  37321. declare module "babylonjs/Cameras/followCameraInputsManager" {
  37322. import { CameraInputsManager } from "babylonjs/Cameras/cameraInputsManager";
  37323. import { FollowCamera } from "babylonjs/Cameras/followCamera";
  37324. /**
  37325. * Default Inputs manager for the FollowCamera.
  37326. * It groups all the default supported inputs for ease of use.
  37327. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  37328. */
  37329. export class FollowCameraInputsManager extends CameraInputsManager<FollowCamera> {
  37330. /**
  37331. * Instantiates a new FollowCameraInputsManager.
  37332. * @param camera Defines the camera the inputs belong to
  37333. */
  37334. constructor(camera: FollowCamera);
  37335. /**
  37336. * Add keyboard input support to the input manager.
  37337. * @returns the current input manager
  37338. */
  37339. addKeyboard(): FollowCameraInputsManager;
  37340. /**
  37341. * Add mouse wheel input support to the input manager.
  37342. * @returns the current input manager
  37343. */
  37344. addMouseWheel(): FollowCameraInputsManager;
  37345. /**
  37346. * Add pointers input support to the input manager.
  37347. * @returns the current input manager
  37348. */
  37349. addPointers(): FollowCameraInputsManager;
  37350. /**
  37351. * Add orientation input support to the input manager.
  37352. * @returns the current input manager
  37353. */
  37354. addVRDeviceOrientation(): FollowCameraInputsManager;
  37355. }
  37356. }
  37357. declare module "babylonjs/Cameras/followCamera" {
  37358. import { Nullable } from "babylonjs/types";
  37359. import { TargetCamera } from "babylonjs/Cameras/targetCamera";
  37360. import { Scene } from "babylonjs/scene";
  37361. import { Vector3 } from "babylonjs/Maths/math";
  37362. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  37363. import { FollowCameraInputsManager } from "babylonjs/Cameras/followCameraInputsManager";
  37364. /**
  37365. * A follow camera takes a mesh as a target and follows it as it moves. Both a free camera version followCamera and
  37366. * an arc rotate version arcFollowCamera are available.
  37367. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  37368. */
  37369. export class FollowCamera extends TargetCamera {
  37370. /**
  37371. * Distance the follow camera should follow an object at
  37372. */
  37373. radius: number;
  37374. /**
  37375. * Minimum allowed distance of the camera to the axis of rotation
  37376. * (The camera can not get closer).
  37377. * This can help limiting how the Camera is able to move in the scene.
  37378. */
  37379. lowerRadiusLimit: Nullable<number>;
  37380. /**
  37381. * Maximum allowed distance of the camera to the axis of rotation
  37382. * (The camera can not get further).
  37383. * This can help limiting how the Camera is able to move in the scene.
  37384. */
  37385. upperRadiusLimit: Nullable<number>;
  37386. /**
  37387. * Define a rotation offset between the camera and the object it follows
  37388. */
  37389. rotationOffset: number;
  37390. /**
  37391. * Minimum allowed angle to camera position relative to target object.
  37392. * This can help limiting how the Camera is able to move in the scene.
  37393. */
  37394. lowerRotationOffsetLimit: Nullable<number>;
  37395. /**
  37396. * Maximum allowed angle to camera position relative to target object.
  37397. * This can help limiting how the Camera is able to move in the scene.
  37398. */
  37399. upperRotationOffsetLimit: Nullable<number>;
  37400. /**
  37401. * Define a height offset between the camera and the object it follows.
  37402. * It can help following an object from the top (like a car chaing a plane)
  37403. */
  37404. heightOffset: number;
  37405. /**
  37406. * Minimum allowed height of camera position relative to target object.
  37407. * This can help limiting how the Camera is able to move in the scene.
  37408. */
  37409. lowerHeightOffsetLimit: Nullable<number>;
  37410. /**
  37411. * Maximum allowed height of camera position relative to target object.
  37412. * This can help limiting how the Camera is able to move in the scene.
  37413. */
  37414. upperHeightOffsetLimit: Nullable<number>;
  37415. /**
  37416. * Define how fast the camera can accelerate to follow it s target.
  37417. */
  37418. cameraAcceleration: number;
  37419. /**
  37420. * Define the speed limit of the camera following an object.
  37421. */
  37422. maxCameraSpeed: number;
  37423. /**
  37424. * Define the target of the camera.
  37425. */
  37426. lockedTarget: Nullable<AbstractMesh>;
  37427. /**
  37428. * Defines the input associated with the camera.
  37429. */
  37430. inputs: FollowCameraInputsManager;
  37431. /**
  37432. * Instantiates the follow camera.
  37433. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  37434. * @param name Define the name of the camera in the scene
  37435. * @param position Define the position of the camera
  37436. * @param scene Define the scene the camera belong to
  37437. * @param lockedTarget Define the target of the camera
  37438. */
  37439. constructor(name: string, position: Vector3, scene: Scene, lockedTarget?: Nullable<AbstractMesh>);
  37440. private _follow;
  37441. /**
  37442. * Attached controls to the current camera.
  37443. * @param element Defines the element the controls should be listened from
  37444. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  37445. */
  37446. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  37447. /**
  37448. * Detach the current controls from the camera.
  37449. * The camera will stop reacting to inputs.
  37450. * @param element Defines the element to stop listening the inputs from
  37451. */
  37452. detachControl(element: HTMLElement): void;
  37453. /** @hidden */
  37454. _checkInputs(): void;
  37455. private _checkLimits;
  37456. /**
  37457. * Gets the camera class name.
  37458. * @returns the class name
  37459. */
  37460. getClassName(): string;
  37461. }
  37462. /**
  37463. * Arc Rotate version of the follow camera.
  37464. * It still follows a Defined mesh but in an Arc Rotate Camera fashion.
  37465. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  37466. */
  37467. export class ArcFollowCamera extends TargetCamera {
  37468. /** The longitudinal angle of the camera */
  37469. alpha: number;
  37470. /** The latitudinal angle of the camera */
  37471. beta: number;
  37472. /** The radius of the camera from its target */
  37473. radius: number;
  37474. /** Define the camera target (the messh it should follow) */
  37475. target: Nullable<AbstractMesh>;
  37476. private _cartesianCoordinates;
  37477. /**
  37478. * Instantiates a new ArcFollowCamera
  37479. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  37480. * @param name Define the name of the camera
  37481. * @param alpha Define the rotation angle of the camera around the logitudinal axis
  37482. * @param beta Define the rotation angle of the camera around the elevation axis
  37483. * @param radius Define the radius of the camera from its target point
  37484. * @param target Define the target of the camera
  37485. * @param scene Define the scene the camera belongs to
  37486. */
  37487. constructor(name: string,
  37488. /** The longitudinal angle of the camera */
  37489. alpha: number,
  37490. /** The latitudinal angle of the camera */
  37491. beta: number,
  37492. /** The radius of the camera from its target */
  37493. radius: number,
  37494. /** Define the camera target (the messh it should follow) */
  37495. target: Nullable<AbstractMesh>, scene: Scene);
  37496. private _follow;
  37497. /** @hidden */
  37498. _checkInputs(): void;
  37499. /**
  37500. * Returns the class name of the object.
  37501. * It is mostly used internally for serialization purposes.
  37502. */
  37503. getClassName(): string;
  37504. }
  37505. }
  37506. declare module "babylonjs/Cameras/Inputs/followCameraKeyboardMoveInput" {
  37507. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  37508. import { FollowCamera } from "babylonjs/Cameras/followCamera";
  37509. import { Nullable } from "babylonjs/types";
  37510. /**
  37511. * Manage the keyboard inputs to control the movement of a follow camera.
  37512. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  37513. */
  37514. export class FollowCameraKeyboardMoveInput implements ICameraInput<FollowCamera> {
  37515. /**
  37516. * Defines the camera the input is attached to.
  37517. */
  37518. camera: FollowCamera;
  37519. /**
  37520. * Defines the list of key codes associated with the up action (increase heightOffset)
  37521. */
  37522. keysHeightOffsetIncr: number[];
  37523. /**
  37524. * Defines the list of key codes associated with the down action (decrease heightOffset)
  37525. */
  37526. keysHeightOffsetDecr: number[];
  37527. /**
  37528. * Defines whether the Alt modifier key is required to move up/down (alter heightOffset)
  37529. */
  37530. keysHeightOffsetModifierAlt: boolean;
  37531. /**
  37532. * Defines whether the Ctrl modifier key is required to move up/down (alter heightOffset)
  37533. */
  37534. keysHeightOffsetModifierCtrl: boolean;
  37535. /**
  37536. * Defines whether the Shift modifier key is required to move up/down (alter heightOffset)
  37537. */
  37538. keysHeightOffsetModifierShift: boolean;
  37539. /**
  37540. * Defines the list of key codes associated with the left action (increase rotationOffset)
  37541. */
  37542. keysRotationOffsetIncr: number[];
  37543. /**
  37544. * Defines the list of key codes associated with the right action (decrease rotationOffset)
  37545. */
  37546. keysRotationOffsetDecr: number[];
  37547. /**
  37548. * Defines whether the Alt modifier key is required to move left/right (alter rotationOffset)
  37549. */
  37550. keysRotationOffsetModifierAlt: boolean;
  37551. /**
  37552. * Defines whether the Ctrl modifier key is required to move left/right (alter rotationOffset)
  37553. */
  37554. keysRotationOffsetModifierCtrl: boolean;
  37555. /**
  37556. * Defines whether the Shift modifier key is required to move left/right (alter rotationOffset)
  37557. */
  37558. keysRotationOffsetModifierShift: boolean;
  37559. /**
  37560. * Defines the list of key codes associated with the zoom-in action (decrease radius)
  37561. */
  37562. keysRadiusIncr: number[];
  37563. /**
  37564. * Defines the list of key codes associated with the zoom-out action (increase radius)
  37565. */
  37566. keysRadiusDecr: number[];
  37567. /**
  37568. * Defines whether the Alt modifier key is required to zoom in/out (alter radius value)
  37569. */
  37570. keysRadiusModifierAlt: boolean;
  37571. /**
  37572. * Defines whether the Ctrl modifier key is required to zoom in/out (alter radius value)
  37573. */
  37574. keysRadiusModifierCtrl: boolean;
  37575. /**
  37576. * Defines whether the Shift modifier key is required to zoom in/out (alter radius value)
  37577. */
  37578. keysRadiusModifierShift: boolean;
  37579. /**
  37580. * Defines the rate of change of heightOffset.
  37581. */
  37582. heightSensibility: number;
  37583. /**
  37584. * Defines the rate of change of rotationOffset.
  37585. */
  37586. rotationSensibility: number;
  37587. /**
  37588. * Defines the rate of change of radius.
  37589. */
  37590. radiusSensibility: number;
  37591. private _keys;
  37592. private _ctrlPressed;
  37593. private _altPressed;
  37594. private _shiftPressed;
  37595. private _onCanvasBlurObserver;
  37596. private _onKeyboardObserver;
  37597. private _engine;
  37598. private _scene;
  37599. /**
  37600. * Attach the input controls to a specific dom element to get the input from.
  37601. * @param element Defines the element the controls should be listened from
  37602. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  37603. */
  37604. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  37605. /**
  37606. * Detach the current controls from the specified dom element.
  37607. * @param element Defines the element to stop listening the inputs from
  37608. */
  37609. detachControl(element: Nullable<HTMLElement>): void;
  37610. /**
  37611. * Update the current camera state depending on the inputs that have been used this frame.
  37612. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  37613. */
  37614. checkInputs(): void;
  37615. /**
  37616. * Gets the class name of the current input.
  37617. * @returns the class name
  37618. */
  37619. getClassName(): string;
  37620. /**
  37621. * Get the friendly name associated with the input class.
  37622. * @returns the input friendly name
  37623. */
  37624. getSimpleName(): string;
  37625. /**
  37626. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  37627. * allow modification of the heightOffset value.
  37628. */
  37629. private _modifierHeightOffset;
  37630. /**
  37631. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  37632. * allow modification of the rotationOffset value.
  37633. */
  37634. private _modifierRotationOffset;
  37635. /**
  37636. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  37637. * allow modification of the radius value.
  37638. */
  37639. private _modifierRadius;
  37640. }
  37641. }
  37642. declare module "babylonjs/Cameras/Inputs/freeCameraDeviceOrientationInput" {
  37643. import { Nullable } from "babylonjs/types";
  37644. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  37645. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  37646. module "babylonjs/Cameras/freeCameraInputsManager" {
  37647. interface FreeCameraInputsManager {
  37648. /**
  37649. * Add orientation input support to the input manager.
  37650. * @returns the current input manager
  37651. */
  37652. addDeviceOrientation(): FreeCameraInputsManager;
  37653. }
  37654. }
  37655. /**
  37656. * Takes information about the orientation of the device as reported by the deviceorientation event to orient the camera.
  37657. * Screen rotation is taken into account.
  37658. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  37659. */
  37660. export class FreeCameraDeviceOrientationInput implements ICameraInput<FreeCamera> {
  37661. private _camera;
  37662. private _screenOrientationAngle;
  37663. private _constantTranform;
  37664. private _screenQuaternion;
  37665. private _alpha;
  37666. private _beta;
  37667. private _gamma;
  37668. /**
  37669. * Instantiates a new input
  37670. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  37671. */
  37672. constructor();
  37673. /**
  37674. * Define the camera controlled by the input.
  37675. */
  37676. camera: FreeCamera;
  37677. /**
  37678. * Attach the input controls to a specific dom element to get the input from.
  37679. * @param element Defines the element the controls should be listened from
  37680. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  37681. */
  37682. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  37683. private _orientationChanged;
  37684. private _deviceOrientation;
  37685. /**
  37686. * Detach the current controls from the specified dom element.
  37687. * @param element Defines the element to stop listening the inputs from
  37688. */
  37689. detachControl(element: Nullable<HTMLElement>): void;
  37690. /**
  37691. * Update the current camera state depending on the inputs that have been used this frame.
  37692. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  37693. */
  37694. checkInputs(): void;
  37695. /**
  37696. * Gets the class name of the current intput.
  37697. * @returns the class name
  37698. */
  37699. getClassName(): string;
  37700. /**
  37701. * Get the friendly name associated with the input class.
  37702. * @returns the input friendly name
  37703. */
  37704. getSimpleName(): string;
  37705. }
  37706. }
  37707. declare module "babylonjs/Cameras/Inputs/freeCameraGamepadInput" {
  37708. import { Nullable } from "babylonjs/types";
  37709. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  37710. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  37711. import { Gamepad } from "babylonjs/Gamepads/gamepad";
  37712. /**
  37713. * Manage the gamepad inputs to control a free camera.
  37714. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  37715. */
  37716. export class FreeCameraGamepadInput implements ICameraInput<FreeCamera> {
  37717. /**
  37718. * Define the camera the input is attached to.
  37719. */
  37720. camera: FreeCamera;
  37721. /**
  37722. * Define the Gamepad controlling the input
  37723. */
  37724. gamepad: Nullable<Gamepad>;
  37725. /**
  37726. * Defines the gamepad rotation sensiblity.
  37727. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  37728. */
  37729. gamepadAngularSensibility: number;
  37730. /**
  37731. * Defines the gamepad move sensiblity.
  37732. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  37733. */
  37734. gamepadMoveSensibility: number;
  37735. private _onGamepadConnectedObserver;
  37736. private _onGamepadDisconnectedObserver;
  37737. private _cameraTransform;
  37738. private _deltaTransform;
  37739. private _vector3;
  37740. private _vector2;
  37741. /**
  37742. * Attach the input controls to a specific dom element to get the input from.
  37743. * @param element Defines the element the controls should be listened from
  37744. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  37745. */
  37746. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  37747. /**
  37748. * Detach the current controls from the specified dom element.
  37749. * @param element Defines the element to stop listening the inputs from
  37750. */
  37751. detachControl(element: Nullable<HTMLElement>): void;
  37752. /**
  37753. * Update the current camera state depending on the inputs that have been used this frame.
  37754. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  37755. */
  37756. checkInputs(): void;
  37757. /**
  37758. * Gets the class name of the current intput.
  37759. * @returns the class name
  37760. */
  37761. getClassName(): string;
  37762. /**
  37763. * Get the friendly name associated with the input class.
  37764. * @returns the input friendly name
  37765. */
  37766. getSimpleName(): string;
  37767. }
  37768. }
  37769. declare module "babylonjs/Misc/virtualJoystick" {
  37770. import { Nullable } from "babylonjs/types";
  37771. import { Vector3 } from "babylonjs/Maths/math";
  37772. /**
  37773. * Defines the potential axis of a Joystick
  37774. */
  37775. export enum JoystickAxis {
  37776. /** X axis */
  37777. X = 0,
  37778. /** Y axis */
  37779. Y = 1,
  37780. /** Z axis */
  37781. Z = 2
  37782. }
  37783. /**
  37784. * Class used to define virtual joystick (used in touch mode)
  37785. */
  37786. export class VirtualJoystick {
  37787. /**
  37788. * Gets or sets a boolean indicating that left and right values must be inverted
  37789. */
  37790. reverseLeftRight: boolean;
  37791. /**
  37792. * Gets or sets a boolean indicating that up and down values must be inverted
  37793. */
  37794. reverseUpDown: boolean;
  37795. /**
  37796. * Gets the offset value for the position (ie. the change of the position value)
  37797. */
  37798. deltaPosition: Vector3;
  37799. /**
  37800. * Gets a boolean indicating if the virtual joystick was pressed
  37801. */
  37802. pressed: boolean;
  37803. /**
  37804. * Canvas the virtual joystick will render onto, default z-index of this is 5
  37805. */
  37806. static Canvas: Nullable<HTMLCanvasElement>;
  37807. private static _globalJoystickIndex;
  37808. private static vjCanvasContext;
  37809. private static vjCanvasWidth;
  37810. private static vjCanvasHeight;
  37811. private static halfWidth;
  37812. private _action;
  37813. private _axisTargetedByLeftAndRight;
  37814. private _axisTargetedByUpAndDown;
  37815. private _joystickSensibility;
  37816. private _inversedSensibility;
  37817. private _joystickPointerID;
  37818. private _joystickColor;
  37819. private _joystickPointerPos;
  37820. private _joystickPreviousPointerPos;
  37821. private _joystickPointerStartPos;
  37822. private _deltaJoystickVector;
  37823. private _leftJoystick;
  37824. private _touches;
  37825. private _onPointerDownHandlerRef;
  37826. private _onPointerMoveHandlerRef;
  37827. private _onPointerUpHandlerRef;
  37828. private _onResize;
  37829. /**
  37830. * Creates a new virtual joystick
  37831. * @param leftJoystick defines that the joystick is for left hand (false by default)
  37832. */
  37833. constructor(leftJoystick?: boolean);
  37834. /**
  37835. * Defines joystick sensibility (ie. the ratio beteen a physical move and virtual joystick position change)
  37836. * @param newJoystickSensibility defines the new sensibility
  37837. */
  37838. setJoystickSensibility(newJoystickSensibility: number): void;
  37839. private _onPointerDown;
  37840. private _onPointerMove;
  37841. private _onPointerUp;
  37842. /**
  37843. * Change the color of the virtual joystick
  37844. * @param newColor a string that must be a CSS color value (like "red") or the hexa value (like "#FF0000")
  37845. */
  37846. setJoystickColor(newColor: string): void;
  37847. /**
  37848. * Defines a callback to call when the joystick is touched
  37849. * @param action defines the callback
  37850. */
  37851. setActionOnTouch(action: () => any): void;
  37852. /**
  37853. * Defines which axis you'd like to control for left & right
  37854. * @param axis defines the axis to use
  37855. */
  37856. setAxisForLeftRight(axis: JoystickAxis): void;
  37857. /**
  37858. * Defines which axis you'd like to control for up & down
  37859. * @param axis defines the axis to use
  37860. */
  37861. setAxisForUpDown(axis: JoystickAxis): void;
  37862. private _drawVirtualJoystick;
  37863. /**
  37864. * Release internal HTML canvas
  37865. */
  37866. releaseCanvas(): void;
  37867. }
  37868. }
  37869. declare module "babylonjs/Cameras/Inputs/freeCameraVirtualJoystickInput" {
  37870. import { VirtualJoystick } from "babylonjs/Misc/virtualJoystick";
  37871. import { Nullable } from "babylonjs/types";
  37872. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  37873. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  37874. module "babylonjs/Cameras/freeCameraInputsManager" {
  37875. interface FreeCameraInputsManager {
  37876. /**
  37877. * Add virtual joystick input support to the input manager.
  37878. * @returns the current input manager
  37879. */
  37880. addVirtualJoystick(): FreeCameraInputsManager;
  37881. }
  37882. }
  37883. /**
  37884. * Manage the Virtual Joystick inputs to control the movement of a free camera.
  37885. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  37886. */
  37887. export class FreeCameraVirtualJoystickInput implements ICameraInput<FreeCamera> {
  37888. /**
  37889. * Defines the camera the input is attached to.
  37890. */
  37891. camera: FreeCamera;
  37892. private _leftjoystick;
  37893. private _rightjoystick;
  37894. /**
  37895. * Gets the left stick of the virtual joystick.
  37896. * @returns The virtual Joystick
  37897. */
  37898. getLeftJoystick(): VirtualJoystick;
  37899. /**
  37900. * Gets the right stick of the virtual joystick.
  37901. * @returns The virtual Joystick
  37902. */
  37903. getRightJoystick(): VirtualJoystick;
  37904. /**
  37905. * Update the current camera state depending on the inputs that have been used this frame.
  37906. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  37907. */
  37908. checkInputs(): void;
  37909. /**
  37910. * Attach the input controls to a specific dom element to get the input from.
  37911. * @param element Defines the element the controls should be listened from
  37912. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  37913. */
  37914. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  37915. /**
  37916. * Detach the current controls from the specified dom element.
  37917. * @param element Defines the element to stop listening the inputs from
  37918. */
  37919. detachControl(element: Nullable<HTMLElement>): void;
  37920. /**
  37921. * Gets the class name of the current intput.
  37922. * @returns the class name
  37923. */
  37924. getClassName(): string;
  37925. /**
  37926. * Get the friendly name associated with the input class.
  37927. * @returns the input friendly name
  37928. */
  37929. getSimpleName(): string;
  37930. }
  37931. }
  37932. declare module "babylonjs/Cameras/Inputs/index" {
  37933. export * from "babylonjs/Cameras/Inputs/arcRotateCameraGamepadInput";
  37934. export * from "babylonjs/Cameras/Inputs/arcRotateCameraKeyboardMoveInput";
  37935. export * from "babylonjs/Cameras/Inputs/arcRotateCameraMouseWheelInput";
  37936. export * from "babylonjs/Cameras/Inputs/arcRotateCameraPointersInput";
  37937. export * from "babylonjs/Cameras/Inputs/arcRotateCameraVRDeviceOrientationInput";
  37938. export * from "babylonjs/Cameras/Inputs/flyCameraKeyboardInput";
  37939. export * from "babylonjs/Cameras/Inputs/flyCameraMouseInput";
  37940. export * from "babylonjs/Cameras/Inputs/followCameraKeyboardMoveInput";
  37941. export * from "babylonjs/Cameras/Inputs/followCameraMouseWheelInput";
  37942. export * from "babylonjs/Cameras/Inputs/followCameraPointersInput";
  37943. export * from "babylonjs/Cameras/Inputs/freeCameraDeviceOrientationInput";
  37944. export * from "babylonjs/Cameras/Inputs/freeCameraGamepadInput";
  37945. export * from "babylonjs/Cameras/Inputs/freeCameraKeyboardMoveInput";
  37946. export * from "babylonjs/Cameras/Inputs/freeCameraMouseInput";
  37947. export * from "babylonjs/Cameras/Inputs/freeCameraTouchInput";
  37948. export * from "babylonjs/Cameras/Inputs/freeCameraVirtualJoystickInput";
  37949. }
  37950. declare module "babylonjs/Cameras/touchCamera" {
  37951. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  37952. import { Scene } from "babylonjs/scene";
  37953. import { Vector3 } from "babylonjs/Maths/math";
  37954. /**
  37955. * This represents a FPS type of camera controlled by touch.
  37956. * This is like a universal camera minus the Gamepad controls.
  37957. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  37958. */
  37959. export class TouchCamera extends FreeCamera {
  37960. /**
  37961. * Defines the touch sensibility for rotation.
  37962. * The higher the faster.
  37963. */
  37964. touchAngularSensibility: number;
  37965. /**
  37966. * Defines the touch sensibility for move.
  37967. * The higher the faster.
  37968. */
  37969. touchMoveSensibility: number;
  37970. /**
  37971. * Instantiates a new touch camera.
  37972. * This represents a FPS type of camera controlled by touch.
  37973. * This is like a universal camera minus the Gamepad controls.
  37974. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  37975. * @param name Define the name of the camera in the scene
  37976. * @param position Define the start position of the camera in the scene
  37977. * @param scene Define the scene the camera belongs to
  37978. */
  37979. constructor(name: string, position: Vector3, scene: Scene);
  37980. /**
  37981. * Gets the current object class name.
  37982. * @return the class name
  37983. */
  37984. getClassName(): string;
  37985. /** @hidden */
  37986. _setupInputs(): void;
  37987. }
  37988. }
  37989. declare module "babylonjs/Cameras/deviceOrientationCamera" {
  37990. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  37991. import { Scene } from "babylonjs/scene";
  37992. import { Vector3, Axis } from "babylonjs/Maths/math";
  37993. import "babylonjs/Cameras/Inputs/freeCameraDeviceOrientationInput";
  37994. /**
  37995. * This is a camera specifically designed to react to device orientation events such as a modern mobile device
  37996. * being tilted forward or back and left or right.
  37997. */
  37998. export class DeviceOrientationCamera extends FreeCamera {
  37999. private _initialQuaternion;
  38000. private _quaternionCache;
  38001. /**
  38002. * Creates a new device orientation camera
  38003. * @param name The name of the camera
  38004. * @param position The start position camera
  38005. * @param scene The scene the camera belongs to
  38006. */
  38007. constructor(name: string, position: Vector3, scene: Scene);
  38008. /**
  38009. * Gets the current instance class name ("DeviceOrientationCamera").
  38010. * This helps avoiding instanceof at run time.
  38011. * @returns the class name
  38012. */
  38013. getClassName(): string;
  38014. /**
  38015. * @hidden
  38016. * Checks and applies the current values of the inputs to the camera. (Internal use only)
  38017. */
  38018. _checkInputs(): void;
  38019. /**
  38020. * Reset the camera to its default orientation on the specified axis only.
  38021. * @param axis The axis to reset
  38022. */
  38023. resetToCurrentRotation(axis?: Axis): void;
  38024. }
  38025. }
  38026. declare module "babylonjs/Cameras/universalCamera" {
  38027. import { TouchCamera } from "babylonjs/Cameras/touchCamera";
  38028. import { Scene } from "babylonjs/scene";
  38029. import { Vector3 } from "babylonjs/Maths/math";
  38030. /**
  38031. * 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,
  38032. * which still works and will still be found in many Playgrounds.
  38033. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  38034. */
  38035. export class UniversalCamera extends TouchCamera {
  38036. /**
  38037. * Defines the gamepad rotation sensiblity.
  38038. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  38039. */
  38040. gamepadAngularSensibility: number;
  38041. /**
  38042. * Defines the gamepad move sensiblity.
  38043. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  38044. */
  38045. gamepadMoveSensibility: number;
  38046. /**
  38047. * 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,
  38048. * which still works and will still be found in many Playgrounds.
  38049. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  38050. * @param name Define the name of the camera in the scene
  38051. * @param position Define the start position of the camera in the scene
  38052. * @param scene Define the scene the camera belongs to
  38053. */
  38054. constructor(name: string, position: Vector3, scene: Scene);
  38055. /**
  38056. * Gets the current object class name.
  38057. * @return the class name
  38058. */
  38059. getClassName(): string;
  38060. }
  38061. }
  38062. declare module "babylonjs/Cameras/gamepadCamera" {
  38063. import { UniversalCamera } from "babylonjs/Cameras/universalCamera";
  38064. import { Scene } from "babylonjs/scene";
  38065. import { Vector3 } from "babylonjs/Maths/math";
  38066. /**
  38067. * This represents a FPS type of camera. This is only here for back compat purpose.
  38068. * Please use the UniversalCamera instead as both are identical.
  38069. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  38070. */
  38071. export class GamepadCamera extends UniversalCamera {
  38072. /**
  38073. * Instantiates a new Gamepad Camera
  38074. * This represents a FPS type of camera. This is only here for back compat purpose.
  38075. * Please use the UniversalCamera instead as both are identical.
  38076. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  38077. * @param name Define the name of the camera in the scene
  38078. * @param position Define the start position of the camera in the scene
  38079. * @param scene Define the scene the camera belongs to
  38080. */
  38081. constructor(name: string, position: Vector3, scene: Scene);
  38082. /**
  38083. * Gets the current object class name.
  38084. * @return the class name
  38085. */
  38086. getClassName(): string;
  38087. }
  38088. }
  38089. declare module "babylonjs/Shaders/pass.fragment" {
  38090. /** @hidden */
  38091. export var passPixelShader: {
  38092. name: string;
  38093. shader: string;
  38094. };
  38095. }
  38096. declare module "babylonjs/Shaders/passCube.fragment" {
  38097. /** @hidden */
  38098. export var passCubePixelShader: {
  38099. name: string;
  38100. shader: string;
  38101. };
  38102. }
  38103. declare module "babylonjs/PostProcesses/passPostProcess" {
  38104. import { Nullable } from "babylonjs/types";
  38105. import { Camera } from "babylonjs/Cameras/camera";
  38106. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  38107. import { Engine } from "babylonjs/Engines/engine";
  38108. import "babylonjs/Shaders/pass.fragment";
  38109. import "babylonjs/Shaders/passCube.fragment";
  38110. /**
  38111. * PassPostProcess which produces an output the same as it's input
  38112. */
  38113. export class PassPostProcess extends PostProcess {
  38114. /**
  38115. * Creates the PassPostProcess
  38116. * @param name The name of the effect.
  38117. * @param options The required width/height ratio to downsize to before computing the render pass.
  38118. * @param camera The camera to apply the render pass to.
  38119. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  38120. * @param engine The engine which the post process will be applied. (default: current engine)
  38121. * @param reusable If the post process can be reused on the same frame. (default: false)
  38122. * @param textureType The type of texture to be used when performing the post processing.
  38123. * @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)
  38124. */
  38125. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  38126. }
  38127. /**
  38128. * PassCubePostProcess which produces an output the same as it's input (which must be a cube texture)
  38129. */
  38130. export class PassCubePostProcess extends PostProcess {
  38131. private _face;
  38132. /**
  38133. * Gets or sets the cube face to display.
  38134. * * 0 is +X
  38135. * * 1 is -X
  38136. * * 2 is +Y
  38137. * * 3 is -Y
  38138. * * 4 is +Z
  38139. * * 5 is -Z
  38140. */
  38141. face: number;
  38142. /**
  38143. * Creates the PassCubePostProcess
  38144. * @param name The name of the effect.
  38145. * @param options The required width/height ratio to downsize to before computing the render pass.
  38146. * @param camera The camera to apply the render pass to.
  38147. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  38148. * @param engine The engine which the post process will be applied. (default: current engine)
  38149. * @param reusable If the post process can be reused on the same frame. (default: false)
  38150. * @param textureType The type of texture to be used when performing the post processing.
  38151. * @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)
  38152. */
  38153. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  38154. }
  38155. }
  38156. declare module "babylonjs/Shaders/anaglyph.fragment" {
  38157. /** @hidden */
  38158. export var anaglyphPixelShader: {
  38159. name: string;
  38160. shader: string;
  38161. };
  38162. }
  38163. declare module "babylonjs/PostProcesses/anaglyphPostProcess" {
  38164. import { Engine } from "babylonjs/Engines/engine";
  38165. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  38166. import { Camera } from "babylonjs/Cameras/camera";
  38167. import "babylonjs/Shaders/anaglyph.fragment";
  38168. /**
  38169. * Postprocess used to generate anaglyphic rendering
  38170. */
  38171. export class AnaglyphPostProcess extends PostProcess {
  38172. private _passedProcess;
  38173. /**
  38174. * Creates a new AnaglyphPostProcess
  38175. * @param name defines postprocess name
  38176. * @param options defines creation options or target ratio scale
  38177. * @param rigCameras defines cameras using this postprocess
  38178. * @param samplingMode defines required sampling mode (BABYLON.Texture.NEAREST_SAMPLINGMODE by default)
  38179. * @param engine defines hosting engine
  38180. * @param reusable defines if the postprocess will be reused multiple times per frame
  38181. */
  38182. constructor(name: string, options: number | PostProcessOptions, rigCameras: Camera[], samplingMode?: number, engine?: Engine, reusable?: boolean);
  38183. }
  38184. }
  38185. declare module "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode" { }
  38186. declare module "babylonjs/Cameras/Stereoscopic/anaglyphArcRotateCamera" {
  38187. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  38188. import { Scene } from "babylonjs/scene";
  38189. import { Vector3 } from "babylonjs/Maths/math";
  38190. import "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode";
  38191. /**
  38192. * Camera used to simulate anaglyphic rendering (based on ArcRotateCamera)
  38193. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  38194. */
  38195. export class AnaglyphArcRotateCamera extends ArcRotateCamera {
  38196. /**
  38197. * Creates a new AnaglyphArcRotateCamera
  38198. * @param name defines camera name
  38199. * @param alpha defines alpha angle (in radians)
  38200. * @param beta defines beta angle (in radians)
  38201. * @param radius defines radius
  38202. * @param target defines camera target
  38203. * @param interaxialDistance defines distance between each color axis
  38204. * @param scene defines the hosting scene
  38205. */
  38206. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, scene: Scene);
  38207. /**
  38208. * Gets camera class name
  38209. * @returns AnaglyphArcRotateCamera
  38210. */
  38211. getClassName(): string;
  38212. }
  38213. }
  38214. declare module "babylonjs/Cameras/Stereoscopic/anaglyphFreeCamera" {
  38215. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  38216. import { Scene } from "babylonjs/scene";
  38217. import { Vector3 } from "babylonjs/Maths/math";
  38218. import "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode";
  38219. /**
  38220. * Camera used to simulate anaglyphic rendering (based on FreeCamera)
  38221. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  38222. */
  38223. export class AnaglyphFreeCamera extends FreeCamera {
  38224. /**
  38225. * Creates a new AnaglyphFreeCamera
  38226. * @param name defines camera name
  38227. * @param position defines initial position
  38228. * @param interaxialDistance defines distance between each color axis
  38229. * @param scene defines the hosting scene
  38230. */
  38231. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  38232. /**
  38233. * Gets camera class name
  38234. * @returns AnaglyphFreeCamera
  38235. */
  38236. getClassName(): string;
  38237. }
  38238. }
  38239. declare module "babylonjs/Cameras/Stereoscopic/anaglyphGamepadCamera" {
  38240. import { GamepadCamera } from "babylonjs/Cameras/gamepadCamera";
  38241. import { Scene } from "babylonjs/scene";
  38242. import { Vector3 } from "babylonjs/Maths/math";
  38243. import "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode";
  38244. /**
  38245. * Camera used to simulate anaglyphic rendering (based on GamepadCamera)
  38246. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  38247. */
  38248. export class AnaglyphGamepadCamera extends GamepadCamera {
  38249. /**
  38250. * Creates a new AnaglyphGamepadCamera
  38251. * @param name defines camera name
  38252. * @param position defines initial position
  38253. * @param interaxialDistance defines distance between each color axis
  38254. * @param scene defines the hosting scene
  38255. */
  38256. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  38257. /**
  38258. * Gets camera class name
  38259. * @returns AnaglyphGamepadCamera
  38260. */
  38261. getClassName(): string;
  38262. }
  38263. }
  38264. declare module "babylonjs/Cameras/Stereoscopic/anaglyphUniversalCamera" {
  38265. import { UniversalCamera } from "babylonjs/Cameras/universalCamera";
  38266. import { Scene } from "babylonjs/scene";
  38267. import { Vector3 } from "babylonjs/Maths/math";
  38268. import "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode";
  38269. /**
  38270. * Camera used to simulate anaglyphic rendering (based on UniversalCamera)
  38271. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  38272. */
  38273. export class AnaglyphUniversalCamera extends UniversalCamera {
  38274. /**
  38275. * Creates a new AnaglyphUniversalCamera
  38276. * @param name defines camera name
  38277. * @param position defines initial position
  38278. * @param interaxialDistance defines distance between each color axis
  38279. * @param scene defines the hosting scene
  38280. */
  38281. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  38282. /**
  38283. * Gets camera class name
  38284. * @returns AnaglyphUniversalCamera
  38285. */
  38286. getClassName(): string;
  38287. }
  38288. }
  38289. declare module "babylonjs/Shaders/stereoscopicInterlace.fragment" {
  38290. /** @hidden */
  38291. export var stereoscopicInterlacePixelShader: {
  38292. name: string;
  38293. shader: string;
  38294. };
  38295. }
  38296. declare module "babylonjs/PostProcesses/stereoscopicInterlacePostProcess" {
  38297. import { Camera } from "babylonjs/Cameras/camera";
  38298. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  38299. import { Engine } from "babylonjs/Engines/engine";
  38300. import "babylonjs/Shaders/stereoscopicInterlace.fragment";
  38301. /**
  38302. * StereoscopicInterlacePostProcess used to render stereo views from a rigged camera
  38303. */
  38304. export class StereoscopicInterlacePostProcess extends PostProcess {
  38305. private _stepSize;
  38306. private _passedProcess;
  38307. /**
  38308. * Initializes a StereoscopicInterlacePostProcess
  38309. * @param name The name of the effect.
  38310. * @param rigCameras The rig cameras to be appled to the post process
  38311. * @param isStereoscopicHoriz If the rendered results are horizontal or verticle
  38312. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  38313. * @param engine The engine which the post process will be applied. (default: current engine)
  38314. * @param reusable If the post process can be reused on the same frame. (default: false)
  38315. */
  38316. constructor(name: string, rigCameras: Camera[], isStereoscopicHoriz: boolean, samplingMode?: number, engine?: Engine, reusable?: boolean);
  38317. }
  38318. }
  38319. declare module "babylonjs/Cameras/RigModes/stereoscopicRigMode" { }
  38320. declare module "babylonjs/Cameras/Stereoscopic/stereoscopicArcRotateCamera" {
  38321. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  38322. import { Scene } from "babylonjs/scene";
  38323. import { Vector3 } from "babylonjs/Maths/math";
  38324. import "babylonjs/Cameras/RigModes/stereoscopicRigMode";
  38325. /**
  38326. * Camera used to simulate stereoscopic rendering (based on ArcRotateCamera)
  38327. * @see http://doc.babylonjs.com/features/cameras
  38328. */
  38329. export class StereoscopicArcRotateCamera extends ArcRotateCamera {
  38330. /**
  38331. * Creates a new StereoscopicArcRotateCamera
  38332. * @param name defines camera name
  38333. * @param alpha defines alpha angle (in radians)
  38334. * @param beta defines beta angle (in radians)
  38335. * @param radius defines radius
  38336. * @param target defines camera target
  38337. * @param interaxialDistance defines distance between each color axis
  38338. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  38339. * @param scene defines the hosting scene
  38340. */
  38341. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  38342. /**
  38343. * Gets camera class name
  38344. * @returns StereoscopicArcRotateCamera
  38345. */
  38346. getClassName(): string;
  38347. }
  38348. }
  38349. declare module "babylonjs/Cameras/Stereoscopic/stereoscopicFreeCamera" {
  38350. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  38351. import { Scene } from "babylonjs/scene";
  38352. import { Vector3 } from "babylonjs/Maths/math";
  38353. import "babylonjs/Cameras/RigModes/stereoscopicRigMode";
  38354. /**
  38355. * Camera used to simulate stereoscopic rendering (based on FreeCamera)
  38356. * @see http://doc.babylonjs.com/features/cameras
  38357. */
  38358. export class StereoscopicFreeCamera extends FreeCamera {
  38359. /**
  38360. * Creates a new StereoscopicFreeCamera
  38361. * @param name defines camera name
  38362. * @param position defines initial position
  38363. * @param interaxialDistance defines distance between each color axis
  38364. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  38365. * @param scene defines the hosting scene
  38366. */
  38367. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  38368. /**
  38369. * Gets camera class name
  38370. * @returns StereoscopicFreeCamera
  38371. */
  38372. getClassName(): string;
  38373. }
  38374. }
  38375. declare module "babylonjs/Cameras/Stereoscopic/stereoscopicGamepadCamera" {
  38376. import { GamepadCamera } from "babylonjs/Cameras/gamepadCamera";
  38377. import { Scene } from "babylonjs/scene";
  38378. import { Vector3 } from "babylonjs/Maths/math";
  38379. import "babylonjs/Cameras/RigModes/stereoscopicRigMode";
  38380. /**
  38381. * Camera used to simulate stereoscopic rendering (based on GamepadCamera)
  38382. * @see http://doc.babylonjs.com/features/cameras
  38383. */
  38384. export class StereoscopicGamepadCamera extends GamepadCamera {
  38385. /**
  38386. * Creates a new StereoscopicGamepadCamera
  38387. * @param name defines camera name
  38388. * @param position defines initial position
  38389. * @param interaxialDistance defines distance between each color axis
  38390. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  38391. * @param scene defines the hosting scene
  38392. */
  38393. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  38394. /**
  38395. * Gets camera class name
  38396. * @returns StereoscopicGamepadCamera
  38397. */
  38398. getClassName(): string;
  38399. }
  38400. }
  38401. declare module "babylonjs/Cameras/Stereoscopic/stereoscopicUniversalCamera" {
  38402. import { UniversalCamera } from "babylonjs/Cameras/universalCamera";
  38403. import { Scene } from "babylonjs/scene";
  38404. import { Vector3 } from "babylonjs/Maths/math";
  38405. import "babylonjs/Cameras/RigModes/stereoscopicRigMode";
  38406. /**
  38407. * Camera used to simulate stereoscopic rendering (based on UniversalCamera)
  38408. * @see http://doc.babylonjs.com/features/cameras
  38409. */
  38410. export class StereoscopicUniversalCamera extends UniversalCamera {
  38411. /**
  38412. * Creates a new StereoscopicUniversalCamera
  38413. * @param name defines camera name
  38414. * @param position defines initial position
  38415. * @param interaxialDistance defines distance between each color axis
  38416. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  38417. * @param scene defines the hosting scene
  38418. */
  38419. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  38420. /**
  38421. * Gets camera class name
  38422. * @returns StereoscopicUniversalCamera
  38423. */
  38424. getClassName(): string;
  38425. }
  38426. }
  38427. declare module "babylonjs/Cameras/Stereoscopic/index" {
  38428. export * from "babylonjs/Cameras/Stereoscopic/anaglyphArcRotateCamera";
  38429. export * from "babylonjs/Cameras/Stereoscopic/anaglyphFreeCamera";
  38430. export * from "babylonjs/Cameras/Stereoscopic/anaglyphGamepadCamera";
  38431. export * from "babylonjs/Cameras/Stereoscopic/anaglyphUniversalCamera";
  38432. export * from "babylonjs/Cameras/Stereoscopic/stereoscopicArcRotateCamera";
  38433. export * from "babylonjs/Cameras/Stereoscopic/stereoscopicFreeCamera";
  38434. export * from "babylonjs/Cameras/Stereoscopic/stereoscopicGamepadCamera";
  38435. export * from "babylonjs/Cameras/Stereoscopic/stereoscopicUniversalCamera";
  38436. }
  38437. declare module "babylonjs/Cameras/virtualJoysticksCamera" {
  38438. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  38439. import { Scene } from "babylonjs/scene";
  38440. import { Vector3 } from "babylonjs/Maths/math";
  38441. import "babylonjs/Cameras/Inputs/freeCameraVirtualJoystickInput";
  38442. /**
  38443. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  38444. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  38445. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  38446. * @see http://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  38447. */
  38448. export class VirtualJoysticksCamera extends FreeCamera {
  38449. /**
  38450. * Intantiates a VirtualJoysticksCamera. It can be useful in First Person Shooter game for instance.
  38451. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  38452. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  38453. * @see http://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  38454. * @param name Define the name of the camera in the scene
  38455. * @param position Define the start position of the camera in the scene
  38456. * @param scene Define the scene the camera belongs to
  38457. */
  38458. constructor(name: string, position: Vector3, scene: Scene);
  38459. /**
  38460. * Gets the current object class name.
  38461. * @return the class name
  38462. */
  38463. getClassName(): string;
  38464. }
  38465. }
  38466. declare module "babylonjs/Cameras/VR/vrCameraMetrics" {
  38467. import { Matrix } from "babylonjs/Maths/math";
  38468. /**
  38469. * This represents all the required metrics to create a VR camera.
  38470. * @see http://doc.babylonjs.com/babylon101/cameras#device-orientation-camera
  38471. */
  38472. export class VRCameraMetrics {
  38473. /**
  38474. * Define the horizontal resolution off the screen.
  38475. */
  38476. hResolution: number;
  38477. /**
  38478. * Define the vertical resolution off the screen.
  38479. */
  38480. vResolution: number;
  38481. /**
  38482. * Define the horizontal screen size.
  38483. */
  38484. hScreenSize: number;
  38485. /**
  38486. * Define the vertical screen size.
  38487. */
  38488. vScreenSize: number;
  38489. /**
  38490. * Define the vertical screen center position.
  38491. */
  38492. vScreenCenter: number;
  38493. /**
  38494. * Define the distance of the eyes to the screen.
  38495. */
  38496. eyeToScreenDistance: number;
  38497. /**
  38498. * Define the distance between both lenses
  38499. */
  38500. lensSeparationDistance: number;
  38501. /**
  38502. * Define the distance between both viewer's eyes.
  38503. */
  38504. interpupillaryDistance: number;
  38505. /**
  38506. * Define the distortion factor of the VR postprocess.
  38507. * Please, touch with care.
  38508. */
  38509. distortionK: number[];
  38510. /**
  38511. * Define the chromatic aberration correction factors for the VR post process.
  38512. */
  38513. chromaAbCorrection: number[];
  38514. /**
  38515. * Define the scale factor of the post process.
  38516. * The smaller the better but the slower.
  38517. */
  38518. postProcessScaleFactor: number;
  38519. /**
  38520. * Define an offset for the lens center.
  38521. */
  38522. lensCenterOffset: number;
  38523. /**
  38524. * Define if the current vr camera should compensate the distortion of the lense or not.
  38525. */
  38526. compensateDistortion: boolean;
  38527. /**
  38528. * Gets the rendering aspect ratio based on the provided resolutions.
  38529. */
  38530. readonly aspectRatio: number;
  38531. /**
  38532. * Gets the aspect ratio based on the FOV, scale factors, and real screen sizes.
  38533. */
  38534. readonly aspectRatioFov: number;
  38535. /**
  38536. * @hidden
  38537. */
  38538. readonly leftHMatrix: Matrix;
  38539. /**
  38540. * @hidden
  38541. */
  38542. readonly rightHMatrix: Matrix;
  38543. /**
  38544. * @hidden
  38545. */
  38546. readonly leftPreViewMatrix: Matrix;
  38547. /**
  38548. * @hidden
  38549. */
  38550. readonly rightPreViewMatrix: Matrix;
  38551. /**
  38552. * Get the default VRMetrics based on the most generic setup.
  38553. * @returns the default vr metrics
  38554. */
  38555. static GetDefault(): VRCameraMetrics;
  38556. }
  38557. }
  38558. declare module "babylonjs/Shaders/vrDistortionCorrection.fragment" {
  38559. /** @hidden */
  38560. export var vrDistortionCorrectionPixelShader: {
  38561. name: string;
  38562. shader: string;
  38563. };
  38564. }
  38565. declare module "babylonjs/PostProcesses/vrDistortionCorrectionPostProcess" {
  38566. import { Camera } from "babylonjs/Cameras/camera";
  38567. import { VRCameraMetrics } from "babylonjs/Cameras/VR/vrCameraMetrics";
  38568. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  38569. import "babylonjs/Shaders/vrDistortionCorrection.fragment";
  38570. /**
  38571. * VRDistortionCorrectionPostProcess used for mobile VR
  38572. */
  38573. export class VRDistortionCorrectionPostProcess extends PostProcess {
  38574. private _isRightEye;
  38575. private _distortionFactors;
  38576. private _postProcessScaleFactor;
  38577. private _lensCenterOffset;
  38578. private _scaleIn;
  38579. private _scaleFactor;
  38580. private _lensCenter;
  38581. /**
  38582. * Initializes the VRDistortionCorrectionPostProcess
  38583. * @param name The name of the effect.
  38584. * @param camera The camera to apply the render pass to.
  38585. * @param isRightEye If this is for the right eye distortion
  38586. * @param vrMetrics All the required metrics for the VR camera
  38587. */
  38588. constructor(name: string, camera: Camera, isRightEye: boolean, vrMetrics: VRCameraMetrics);
  38589. }
  38590. }
  38591. declare module "babylonjs/Cameras/RigModes/vrRigMode" { }
  38592. declare module "babylonjs/Cameras/VR/vrDeviceOrientationArcRotateCamera" {
  38593. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  38594. import { VRCameraMetrics } from "babylonjs/Cameras/VR/vrCameraMetrics";
  38595. import { Scene } from "babylonjs/scene";
  38596. import { Vector3 } from "babylonjs/Maths/math";
  38597. import "babylonjs/Cameras/Inputs/arcRotateCameraVRDeviceOrientationInput";
  38598. import "babylonjs/Cameras/RigModes/vrRigMode";
  38599. /**
  38600. * Camera used to simulate VR rendering (based on ArcRotateCamera)
  38601. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  38602. */
  38603. export class VRDeviceOrientationArcRotateCamera extends ArcRotateCamera {
  38604. /**
  38605. * Creates a new VRDeviceOrientationArcRotateCamera
  38606. * @param name defines camera name
  38607. * @param alpha defines the camera rotation along the logitudinal axis
  38608. * @param beta defines the camera rotation along the latitudinal axis
  38609. * @param radius defines the camera distance from its target
  38610. * @param target defines the camera target
  38611. * @param scene defines the scene the camera belongs to
  38612. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  38613. * @param vrCameraMetrics defines the vr metrics associated to the camera
  38614. */
  38615. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  38616. /**
  38617. * Gets camera class name
  38618. * @returns VRDeviceOrientationArcRotateCamera
  38619. */
  38620. getClassName(): string;
  38621. }
  38622. }
  38623. declare module "babylonjs/Cameras/VR/vrDeviceOrientationFreeCamera" {
  38624. import { DeviceOrientationCamera } from "babylonjs/Cameras/deviceOrientationCamera";
  38625. import { VRCameraMetrics } from "babylonjs/Cameras/VR/vrCameraMetrics";
  38626. import { Scene } from "babylonjs/scene";
  38627. import { Vector3 } from "babylonjs/Maths/math";
  38628. import "babylonjs/Cameras/RigModes/vrRigMode";
  38629. /**
  38630. * Camera used to simulate VR rendering (based on FreeCamera)
  38631. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  38632. */
  38633. export class VRDeviceOrientationFreeCamera extends DeviceOrientationCamera {
  38634. /**
  38635. * Creates a new VRDeviceOrientationFreeCamera
  38636. * @param name defines camera name
  38637. * @param position defines the start position of the camera
  38638. * @param scene defines the scene the camera belongs to
  38639. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  38640. * @param vrCameraMetrics defines the vr metrics associated to the camera
  38641. */
  38642. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  38643. /**
  38644. * Gets camera class name
  38645. * @returns VRDeviceOrientationFreeCamera
  38646. */
  38647. getClassName(): string;
  38648. }
  38649. }
  38650. declare module "babylonjs/Cameras/VR/vrDeviceOrientationGamepadCamera" {
  38651. import { VRDeviceOrientationFreeCamera } from "babylonjs/Cameras/VR/vrDeviceOrientationFreeCamera";
  38652. import { VRCameraMetrics } from "babylonjs/Cameras/VR/vrCameraMetrics";
  38653. import { Scene } from "babylonjs/scene";
  38654. import { Vector3 } from "babylonjs/Maths/math";
  38655. /**
  38656. * Camera used to simulate VR rendering (based on VRDeviceOrientationFreeCamera)
  38657. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  38658. */
  38659. export class VRDeviceOrientationGamepadCamera extends VRDeviceOrientationFreeCamera {
  38660. /**
  38661. * Creates a new VRDeviceOrientationGamepadCamera
  38662. * @param name defines camera name
  38663. * @param position defines the start position of the camera
  38664. * @param scene defines the scene the camera belongs to
  38665. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  38666. * @param vrCameraMetrics defines the vr metrics associated to the camera
  38667. */
  38668. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  38669. /**
  38670. * Gets camera class name
  38671. * @returns VRDeviceOrientationGamepadCamera
  38672. */
  38673. getClassName(): string;
  38674. }
  38675. }
  38676. declare module "babylonjs/Gamepads/xboxGamepad" {
  38677. import { Observable } from "babylonjs/Misc/observable";
  38678. import { Gamepad } from "babylonjs/Gamepads/gamepad";
  38679. /**
  38680. * Defines supported buttons for XBox360 compatible gamepads
  38681. */
  38682. export enum Xbox360Button {
  38683. /** A */
  38684. A = 0,
  38685. /** B */
  38686. B = 1,
  38687. /** X */
  38688. X = 2,
  38689. /** Y */
  38690. Y = 3,
  38691. /** Start */
  38692. Start = 4,
  38693. /** Back */
  38694. Back = 5,
  38695. /** Left button */
  38696. LB = 6,
  38697. /** Right button */
  38698. RB = 7,
  38699. /** Left stick */
  38700. LeftStick = 8,
  38701. /** Right stick */
  38702. RightStick = 9
  38703. }
  38704. /** Defines values for XBox360 DPad */
  38705. export enum Xbox360Dpad {
  38706. /** Up */
  38707. Up = 0,
  38708. /** Down */
  38709. Down = 1,
  38710. /** Left */
  38711. Left = 2,
  38712. /** Right */
  38713. Right = 3
  38714. }
  38715. /**
  38716. * Defines a XBox360 gamepad
  38717. */
  38718. export class Xbox360Pad extends Gamepad {
  38719. private _leftTrigger;
  38720. private _rightTrigger;
  38721. private _onlefttriggerchanged;
  38722. private _onrighttriggerchanged;
  38723. private _onbuttondown;
  38724. private _onbuttonup;
  38725. private _ondpaddown;
  38726. private _ondpadup;
  38727. /** Observable raised when a button is pressed */
  38728. onButtonDownObservable: Observable<Xbox360Button>;
  38729. /** Observable raised when a button is released */
  38730. onButtonUpObservable: Observable<Xbox360Button>;
  38731. /** Observable raised when a pad is pressed */
  38732. onPadDownObservable: Observable<Xbox360Dpad>;
  38733. /** Observable raised when a pad is released */
  38734. onPadUpObservable: Observable<Xbox360Dpad>;
  38735. private _buttonA;
  38736. private _buttonB;
  38737. private _buttonX;
  38738. private _buttonY;
  38739. private _buttonBack;
  38740. private _buttonStart;
  38741. private _buttonLB;
  38742. private _buttonRB;
  38743. private _buttonLeftStick;
  38744. private _buttonRightStick;
  38745. private _dPadUp;
  38746. private _dPadDown;
  38747. private _dPadLeft;
  38748. private _dPadRight;
  38749. private _isXboxOnePad;
  38750. /**
  38751. * Creates a new XBox360 gamepad object
  38752. * @param id defines the id of this gamepad
  38753. * @param index defines its index
  38754. * @param gamepad defines the internal HTML gamepad object
  38755. * @param xboxOne defines if it is a XBox One gamepad
  38756. */
  38757. constructor(id: string, index: number, gamepad: any, xboxOne?: boolean);
  38758. /**
  38759. * Defines the callback to call when left trigger is pressed
  38760. * @param callback defines the callback to use
  38761. */
  38762. onlefttriggerchanged(callback: (value: number) => void): void;
  38763. /**
  38764. * Defines the callback to call when right trigger is pressed
  38765. * @param callback defines the callback to use
  38766. */
  38767. onrighttriggerchanged(callback: (value: number) => void): void;
  38768. /**
  38769. * Gets the left trigger value
  38770. */
  38771. /**
  38772. * Sets the left trigger value
  38773. */
  38774. leftTrigger: number;
  38775. /**
  38776. * Gets the right trigger value
  38777. */
  38778. /**
  38779. * Sets the right trigger value
  38780. */
  38781. rightTrigger: number;
  38782. /**
  38783. * Defines the callback to call when a button is pressed
  38784. * @param callback defines the callback to use
  38785. */
  38786. onbuttondown(callback: (buttonPressed: Xbox360Button) => void): void;
  38787. /**
  38788. * Defines the callback to call when a button is released
  38789. * @param callback defines the callback to use
  38790. */
  38791. onbuttonup(callback: (buttonReleased: Xbox360Button) => void): void;
  38792. /**
  38793. * Defines the callback to call when a pad is pressed
  38794. * @param callback defines the callback to use
  38795. */
  38796. ondpaddown(callback: (dPadPressed: Xbox360Dpad) => void): void;
  38797. /**
  38798. * Defines the callback to call when a pad is released
  38799. * @param callback defines the callback to use
  38800. */
  38801. ondpadup(callback: (dPadReleased: Xbox360Dpad) => void): void;
  38802. private _setButtonValue;
  38803. private _setDPadValue;
  38804. /**
  38805. * Gets the value of the `A` button
  38806. */
  38807. /**
  38808. * Sets the value of the `A` button
  38809. */
  38810. buttonA: number;
  38811. /**
  38812. * Gets the value of the `B` button
  38813. */
  38814. /**
  38815. * Sets the value of the `B` button
  38816. */
  38817. buttonB: number;
  38818. /**
  38819. * Gets the value of the `X` button
  38820. */
  38821. /**
  38822. * Sets the value of the `X` button
  38823. */
  38824. buttonX: number;
  38825. /**
  38826. * Gets the value of the `Y` button
  38827. */
  38828. /**
  38829. * Sets the value of the `Y` button
  38830. */
  38831. buttonY: number;
  38832. /**
  38833. * Gets the value of the `Start` button
  38834. */
  38835. /**
  38836. * Sets the value of the `Start` button
  38837. */
  38838. buttonStart: number;
  38839. /**
  38840. * Gets the value of the `Back` button
  38841. */
  38842. /**
  38843. * Sets the value of the `Back` button
  38844. */
  38845. buttonBack: number;
  38846. /**
  38847. * Gets the value of the `Left` button
  38848. */
  38849. /**
  38850. * Sets the value of the `Left` button
  38851. */
  38852. buttonLB: number;
  38853. /**
  38854. * Gets the value of the `Right` button
  38855. */
  38856. /**
  38857. * Sets the value of the `Right` button
  38858. */
  38859. buttonRB: number;
  38860. /**
  38861. * Gets the value of the Left joystick
  38862. */
  38863. /**
  38864. * Sets the value of the Left joystick
  38865. */
  38866. buttonLeftStick: number;
  38867. /**
  38868. * Gets the value of the Right joystick
  38869. */
  38870. /**
  38871. * Sets the value of the Right joystick
  38872. */
  38873. buttonRightStick: number;
  38874. /**
  38875. * Gets the value of D-pad up
  38876. */
  38877. /**
  38878. * Sets the value of D-pad up
  38879. */
  38880. dPadUp: number;
  38881. /**
  38882. * Gets the value of D-pad down
  38883. */
  38884. /**
  38885. * Sets the value of D-pad down
  38886. */
  38887. dPadDown: number;
  38888. /**
  38889. * Gets the value of D-pad left
  38890. */
  38891. /**
  38892. * Sets the value of D-pad left
  38893. */
  38894. dPadLeft: number;
  38895. /**
  38896. * Gets the value of D-pad right
  38897. */
  38898. /**
  38899. * Sets the value of D-pad right
  38900. */
  38901. dPadRight: number;
  38902. /**
  38903. * Force the gamepad to synchronize with device values
  38904. */
  38905. update(): void;
  38906. /**
  38907. * Disposes the gamepad
  38908. */
  38909. dispose(): void;
  38910. }
  38911. }
  38912. declare module "babylonjs/Materials/pushMaterial" {
  38913. import { Nullable } from "babylonjs/types";
  38914. import { Scene } from "babylonjs/scene";
  38915. import { Matrix } from "babylonjs/Maths/math";
  38916. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  38917. import { Mesh } from "babylonjs/Meshes/mesh";
  38918. import { Material } from "babylonjs/Materials/material";
  38919. import { Effect } from "babylonjs/Materials/effect";
  38920. /**
  38921. * Base class of materials working in push mode in babylon JS
  38922. * @hidden
  38923. */
  38924. export class PushMaterial extends Material {
  38925. protected _activeEffect: Effect;
  38926. protected _normalMatrix: Matrix;
  38927. /**
  38928. * Gets or sets a boolean indicating that the material is allowed to do shader hot swapping.
  38929. * This means that the material can keep using a previous shader while a new one is being compiled.
  38930. * This is mostly used when shader parallel compilation is supported (true by default)
  38931. */
  38932. allowShaderHotSwapping: boolean;
  38933. constructor(name: string, scene: Scene);
  38934. getEffect(): Effect;
  38935. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  38936. /**
  38937. * Binds the given world matrix to the active effect
  38938. *
  38939. * @param world the matrix to bind
  38940. */
  38941. bindOnlyWorldMatrix(world: Matrix): void;
  38942. /**
  38943. * Binds the given normal matrix to the active effect
  38944. *
  38945. * @param normalMatrix the matrix to bind
  38946. */
  38947. bindOnlyNormalMatrix(normalMatrix: Matrix): void;
  38948. bind(world: Matrix, mesh?: Mesh): void;
  38949. protected _afterBind(mesh: Mesh, effect?: Nullable<Effect>): void;
  38950. protected _mustRebind(scene: Scene, effect: Effect, visibility?: number): boolean;
  38951. }
  38952. }
  38953. declare module "babylonjs/Materials/materialFlags" {
  38954. /**
  38955. * This groups all the flags used to control the materials channel.
  38956. */
  38957. export class MaterialFlags {
  38958. private static _DiffuseTextureEnabled;
  38959. /**
  38960. * Are diffuse textures enabled in the application.
  38961. */
  38962. static DiffuseTextureEnabled: boolean;
  38963. private static _AmbientTextureEnabled;
  38964. /**
  38965. * Are ambient textures enabled in the application.
  38966. */
  38967. static AmbientTextureEnabled: boolean;
  38968. private static _OpacityTextureEnabled;
  38969. /**
  38970. * Are opacity textures enabled in the application.
  38971. */
  38972. static OpacityTextureEnabled: boolean;
  38973. private static _ReflectionTextureEnabled;
  38974. /**
  38975. * Are reflection textures enabled in the application.
  38976. */
  38977. static ReflectionTextureEnabled: boolean;
  38978. private static _EmissiveTextureEnabled;
  38979. /**
  38980. * Are emissive textures enabled in the application.
  38981. */
  38982. static EmissiveTextureEnabled: boolean;
  38983. private static _SpecularTextureEnabled;
  38984. /**
  38985. * Are specular textures enabled in the application.
  38986. */
  38987. static SpecularTextureEnabled: boolean;
  38988. private static _BumpTextureEnabled;
  38989. /**
  38990. * Are bump textures enabled in the application.
  38991. */
  38992. static BumpTextureEnabled: boolean;
  38993. private static _LightmapTextureEnabled;
  38994. /**
  38995. * Are lightmap textures enabled in the application.
  38996. */
  38997. static LightmapTextureEnabled: boolean;
  38998. private static _RefractionTextureEnabled;
  38999. /**
  39000. * Are refraction textures enabled in the application.
  39001. */
  39002. static RefractionTextureEnabled: boolean;
  39003. private static _ColorGradingTextureEnabled;
  39004. /**
  39005. * Are color grading textures enabled in the application.
  39006. */
  39007. static ColorGradingTextureEnabled: boolean;
  39008. private static _FresnelEnabled;
  39009. /**
  39010. * Are fresnels enabled in the application.
  39011. */
  39012. static FresnelEnabled: boolean;
  39013. private static _ClearCoatTextureEnabled;
  39014. /**
  39015. * Are clear coat textures enabled in the application.
  39016. */
  39017. static ClearCoatTextureEnabled: boolean;
  39018. private static _ClearCoatBumpTextureEnabled;
  39019. /**
  39020. * Are clear coat bump textures enabled in the application.
  39021. */
  39022. static ClearCoatBumpTextureEnabled: boolean;
  39023. private static _ClearCoatTintTextureEnabled;
  39024. /**
  39025. * Are clear coat tint textures enabled in the application.
  39026. */
  39027. static ClearCoatTintTextureEnabled: boolean;
  39028. private static _SheenTextureEnabled;
  39029. /**
  39030. * Are sheen textures enabled in the application.
  39031. */
  39032. static SheenTextureEnabled: boolean;
  39033. private static _AnisotropicTextureEnabled;
  39034. /**
  39035. * Are anisotropic textures enabled in the application.
  39036. */
  39037. static AnisotropicTextureEnabled: boolean;
  39038. }
  39039. }
  39040. declare module "babylonjs/Shaders/ShadersInclude/defaultFragmentDeclaration" {
  39041. /** @hidden */
  39042. export var defaultFragmentDeclaration: {
  39043. name: string;
  39044. shader: string;
  39045. };
  39046. }
  39047. declare module "babylonjs/Shaders/ShadersInclude/defaultUboDeclaration" {
  39048. /** @hidden */
  39049. export var defaultUboDeclaration: {
  39050. name: string;
  39051. shader: string;
  39052. };
  39053. }
  39054. declare module "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration" {
  39055. /** @hidden */
  39056. export var lightFragmentDeclaration: {
  39057. name: string;
  39058. shader: string;
  39059. };
  39060. }
  39061. declare module "babylonjs/Shaders/ShadersInclude/lightUboDeclaration" {
  39062. /** @hidden */
  39063. export var lightUboDeclaration: {
  39064. name: string;
  39065. shader: string;
  39066. };
  39067. }
  39068. declare module "babylonjs/Shaders/ShadersInclude/lightsFragmentFunctions" {
  39069. /** @hidden */
  39070. export var lightsFragmentFunctions: {
  39071. name: string;
  39072. shader: string;
  39073. };
  39074. }
  39075. declare module "babylonjs/Shaders/ShadersInclude/shadowsFragmentFunctions" {
  39076. /** @hidden */
  39077. export var shadowsFragmentFunctions: {
  39078. name: string;
  39079. shader: string;
  39080. };
  39081. }
  39082. declare module "babylonjs/Shaders/ShadersInclude/fresnelFunction" {
  39083. /** @hidden */
  39084. export var fresnelFunction: {
  39085. name: string;
  39086. shader: string;
  39087. };
  39088. }
  39089. declare module "babylonjs/Shaders/ShadersInclude/reflectionFunction" {
  39090. /** @hidden */
  39091. export var reflectionFunction: {
  39092. name: string;
  39093. shader: string;
  39094. };
  39095. }
  39096. declare module "babylonjs/Shaders/ShadersInclude/bumpFragmentFunctions" {
  39097. /** @hidden */
  39098. export var bumpFragmentFunctions: {
  39099. name: string;
  39100. shader: string;
  39101. };
  39102. }
  39103. declare module "babylonjs/Shaders/ShadersInclude/logDepthDeclaration" {
  39104. /** @hidden */
  39105. export var logDepthDeclaration: {
  39106. name: string;
  39107. shader: string;
  39108. };
  39109. }
  39110. declare module "babylonjs/Shaders/ShadersInclude/bumpFragment" {
  39111. /** @hidden */
  39112. export var bumpFragment: {
  39113. name: string;
  39114. shader: string;
  39115. };
  39116. }
  39117. declare module "babylonjs/Shaders/ShadersInclude/depthPrePass" {
  39118. /** @hidden */
  39119. export var depthPrePass: {
  39120. name: string;
  39121. shader: string;
  39122. };
  39123. }
  39124. declare module "babylonjs/Shaders/ShadersInclude/lightFragment" {
  39125. /** @hidden */
  39126. export var lightFragment: {
  39127. name: string;
  39128. shader: string;
  39129. };
  39130. }
  39131. declare module "babylonjs/Shaders/ShadersInclude/logDepthFragment" {
  39132. /** @hidden */
  39133. export var logDepthFragment: {
  39134. name: string;
  39135. shader: string;
  39136. };
  39137. }
  39138. declare module "babylonjs/Shaders/default.fragment" {
  39139. import "babylonjs/Shaders/ShadersInclude/defaultFragmentDeclaration";
  39140. import "babylonjs/Shaders/ShadersInclude/defaultUboDeclaration";
  39141. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  39142. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  39143. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  39144. import "babylonjs/Shaders/ShadersInclude/lightsFragmentFunctions";
  39145. import "babylonjs/Shaders/ShadersInclude/shadowsFragmentFunctions";
  39146. import "babylonjs/Shaders/ShadersInclude/fresnelFunction";
  39147. import "babylonjs/Shaders/ShadersInclude/reflectionFunction";
  39148. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  39149. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  39150. import "babylonjs/Shaders/ShadersInclude/bumpFragmentFunctions";
  39151. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration";
  39152. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  39153. import "babylonjs/Shaders/ShadersInclude/fogFragmentDeclaration";
  39154. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  39155. import "babylonjs/Shaders/ShadersInclude/bumpFragment";
  39156. import "babylonjs/Shaders/ShadersInclude/depthPrePass";
  39157. import "babylonjs/Shaders/ShadersInclude/lightFragment";
  39158. import "babylonjs/Shaders/ShadersInclude/logDepthFragment";
  39159. import "babylonjs/Shaders/ShadersInclude/fogFragment";
  39160. /** @hidden */
  39161. export var defaultPixelShader: {
  39162. name: string;
  39163. shader: string;
  39164. };
  39165. }
  39166. declare module "babylonjs/Shaders/ShadersInclude/defaultVertexDeclaration" {
  39167. /** @hidden */
  39168. export var defaultVertexDeclaration: {
  39169. name: string;
  39170. shader: string;
  39171. };
  39172. }
  39173. declare module "babylonjs/Shaders/ShadersInclude/bumpVertexDeclaration" {
  39174. /** @hidden */
  39175. export var bumpVertexDeclaration: {
  39176. name: string;
  39177. shader: string;
  39178. };
  39179. }
  39180. declare module "babylonjs/Shaders/ShadersInclude/bumpVertex" {
  39181. /** @hidden */
  39182. export var bumpVertex: {
  39183. name: string;
  39184. shader: string;
  39185. };
  39186. }
  39187. declare module "babylonjs/Shaders/ShadersInclude/fogVertex" {
  39188. /** @hidden */
  39189. export var fogVertex: {
  39190. name: string;
  39191. shader: string;
  39192. };
  39193. }
  39194. declare module "babylonjs/Shaders/ShadersInclude/shadowsVertex" {
  39195. /** @hidden */
  39196. export var shadowsVertex: {
  39197. name: string;
  39198. shader: string;
  39199. };
  39200. }
  39201. declare module "babylonjs/Shaders/ShadersInclude/pointCloudVertex" {
  39202. /** @hidden */
  39203. export var pointCloudVertex: {
  39204. name: string;
  39205. shader: string;
  39206. };
  39207. }
  39208. declare module "babylonjs/Shaders/ShadersInclude/logDepthVertex" {
  39209. /** @hidden */
  39210. export var logDepthVertex: {
  39211. name: string;
  39212. shader: string;
  39213. };
  39214. }
  39215. declare module "babylonjs/Shaders/default.vertex" {
  39216. import "babylonjs/Shaders/ShadersInclude/defaultVertexDeclaration";
  39217. import "babylonjs/Shaders/ShadersInclude/defaultUboDeclaration";
  39218. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  39219. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  39220. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  39221. import "babylonjs/Shaders/ShadersInclude/bumpVertexDeclaration";
  39222. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration";
  39223. import "babylonjs/Shaders/ShadersInclude/fogVertexDeclaration";
  39224. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  39225. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  39226. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  39227. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  39228. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  39229. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  39230. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  39231. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  39232. import "babylonjs/Shaders/ShadersInclude/bumpVertex";
  39233. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  39234. import "babylonjs/Shaders/ShadersInclude/fogVertex";
  39235. import "babylonjs/Shaders/ShadersInclude/shadowsVertex";
  39236. import "babylonjs/Shaders/ShadersInclude/pointCloudVertex";
  39237. import "babylonjs/Shaders/ShadersInclude/logDepthVertex";
  39238. /** @hidden */
  39239. export var defaultVertexShader: {
  39240. name: string;
  39241. shader: string;
  39242. };
  39243. }
  39244. declare module "babylonjs/Materials/standardMaterial" {
  39245. import { SmartArray } from "babylonjs/Misc/smartArray";
  39246. import { IAnimatable } from "babylonjs/Misc/tools";
  39247. import { Nullable } from "babylonjs/types";
  39248. import { Scene } from "babylonjs/scene";
  39249. import { Matrix, Color3 } from "babylonjs/Maths/math";
  39250. import { SubMesh } from "babylonjs/Meshes/subMesh";
  39251. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  39252. import { Mesh } from "babylonjs/Meshes/mesh";
  39253. import { ImageProcessingConfiguration, IImageProcessingConfigurationDefines } from "babylonjs/Materials/imageProcessingConfiguration";
  39254. import { ColorCurves } from "babylonjs/Materials/colorCurves";
  39255. import { FresnelParameters } from "babylonjs/Materials/fresnelParameters";
  39256. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  39257. import { PushMaterial } from "babylonjs/Materials/pushMaterial";
  39258. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  39259. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  39260. import "babylonjs/Shaders/default.fragment";
  39261. import "babylonjs/Shaders/default.vertex";
  39262. /** @hidden */
  39263. export class StandardMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  39264. MAINUV1: boolean;
  39265. MAINUV2: boolean;
  39266. DIFFUSE: boolean;
  39267. DIFFUSEDIRECTUV: number;
  39268. AMBIENT: boolean;
  39269. AMBIENTDIRECTUV: number;
  39270. OPACITY: boolean;
  39271. OPACITYDIRECTUV: number;
  39272. OPACITYRGB: boolean;
  39273. REFLECTION: boolean;
  39274. EMISSIVE: boolean;
  39275. EMISSIVEDIRECTUV: number;
  39276. SPECULAR: boolean;
  39277. SPECULARDIRECTUV: number;
  39278. BUMP: boolean;
  39279. BUMPDIRECTUV: number;
  39280. PARALLAX: boolean;
  39281. PARALLAXOCCLUSION: boolean;
  39282. SPECULAROVERALPHA: boolean;
  39283. CLIPPLANE: boolean;
  39284. CLIPPLANE2: boolean;
  39285. CLIPPLANE3: boolean;
  39286. CLIPPLANE4: boolean;
  39287. ALPHATEST: boolean;
  39288. DEPTHPREPASS: boolean;
  39289. ALPHAFROMDIFFUSE: boolean;
  39290. POINTSIZE: boolean;
  39291. FOG: boolean;
  39292. SPECULARTERM: boolean;
  39293. DIFFUSEFRESNEL: boolean;
  39294. OPACITYFRESNEL: boolean;
  39295. REFLECTIONFRESNEL: boolean;
  39296. REFRACTIONFRESNEL: boolean;
  39297. EMISSIVEFRESNEL: boolean;
  39298. FRESNEL: boolean;
  39299. NORMAL: boolean;
  39300. UV1: boolean;
  39301. UV2: boolean;
  39302. VERTEXCOLOR: boolean;
  39303. VERTEXALPHA: boolean;
  39304. NUM_BONE_INFLUENCERS: number;
  39305. BonesPerMesh: number;
  39306. BONETEXTURE: boolean;
  39307. INSTANCES: boolean;
  39308. GLOSSINESS: boolean;
  39309. ROUGHNESS: boolean;
  39310. EMISSIVEASILLUMINATION: boolean;
  39311. LINKEMISSIVEWITHDIFFUSE: boolean;
  39312. REFLECTIONFRESNELFROMSPECULAR: boolean;
  39313. LIGHTMAP: boolean;
  39314. LIGHTMAPDIRECTUV: number;
  39315. OBJECTSPACE_NORMALMAP: boolean;
  39316. USELIGHTMAPASSHADOWMAP: boolean;
  39317. REFLECTIONMAP_3D: boolean;
  39318. REFLECTIONMAP_SPHERICAL: boolean;
  39319. REFLECTIONMAP_PLANAR: boolean;
  39320. REFLECTIONMAP_CUBIC: boolean;
  39321. USE_LOCAL_REFLECTIONMAP_CUBIC: boolean;
  39322. REFLECTIONMAP_PROJECTION: boolean;
  39323. REFLECTIONMAP_SKYBOX: boolean;
  39324. REFLECTIONMAP_SKYBOX_TRANSFORMED: boolean;
  39325. REFLECTIONMAP_EXPLICIT: boolean;
  39326. REFLECTIONMAP_EQUIRECTANGULAR: boolean;
  39327. REFLECTIONMAP_EQUIRECTANGULAR_FIXED: boolean;
  39328. REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED: boolean;
  39329. INVERTCUBICMAP: boolean;
  39330. LOGARITHMICDEPTH: boolean;
  39331. REFRACTION: boolean;
  39332. REFRACTIONMAP_3D: boolean;
  39333. REFLECTIONOVERALPHA: boolean;
  39334. TWOSIDEDLIGHTING: boolean;
  39335. SHADOWFLOAT: boolean;
  39336. MORPHTARGETS: boolean;
  39337. MORPHTARGETS_NORMAL: boolean;
  39338. MORPHTARGETS_TANGENT: boolean;
  39339. NUM_MORPH_INFLUENCERS: number;
  39340. NONUNIFORMSCALING: boolean;
  39341. PREMULTIPLYALPHA: boolean;
  39342. IMAGEPROCESSING: boolean;
  39343. VIGNETTE: boolean;
  39344. VIGNETTEBLENDMODEMULTIPLY: boolean;
  39345. VIGNETTEBLENDMODEOPAQUE: boolean;
  39346. TONEMAPPING: boolean;
  39347. TONEMAPPING_ACES: boolean;
  39348. CONTRAST: boolean;
  39349. COLORCURVES: boolean;
  39350. COLORGRADING: boolean;
  39351. COLORGRADING3D: boolean;
  39352. SAMPLER3DGREENDEPTH: boolean;
  39353. SAMPLER3DBGRMAP: boolean;
  39354. IMAGEPROCESSINGPOSTPROCESS: boolean;
  39355. /**
  39356. * If the reflection texture on this material is in linear color space
  39357. * @hidden
  39358. */
  39359. IS_REFLECTION_LINEAR: boolean;
  39360. /**
  39361. * If the refraction texture on this material is in linear color space
  39362. * @hidden
  39363. */
  39364. IS_REFRACTION_LINEAR: boolean;
  39365. EXPOSURE: boolean;
  39366. constructor();
  39367. setReflectionMode(modeToEnable: string): void;
  39368. }
  39369. /**
  39370. * This is the default material used in Babylon. It is the best trade off between quality
  39371. * and performances.
  39372. * @see http://doc.babylonjs.com/babylon101/materials
  39373. */
  39374. export class StandardMaterial extends PushMaterial {
  39375. private _diffuseTexture;
  39376. /**
  39377. * The basic texture of the material as viewed under a light.
  39378. */
  39379. diffuseTexture: Nullable<BaseTexture>;
  39380. private _ambientTexture;
  39381. /**
  39382. * AKA Occlusion Texture in other nomenclature, it helps adding baked shadows into your material.
  39383. */
  39384. ambientTexture: Nullable<BaseTexture>;
  39385. private _opacityTexture;
  39386. /**
  39387. * Define the transparency of the material from a texture.
  39388. * The final alpha value can be read either from the red channel (if texture.getAlphaFromRGB is false)
  39389. * or from the luminance or the current texel (if texture.getAlphaFromRGB is true)
  39390. */
  39391. opacityTexture: Nullable<BaseTexture>;
  39392. private _reflectionTexture;
  39393. /**
  39394. * Define the texture used to display the reflection.
  39395. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  39396. */
  39397. reflectionTexture: Nullable<BaseTexture>;
  39398. private _emissiveTexture;
  39399. /**
  39400. * Define texture of the material as if self lit.
  39401. * This will be mixed in the final result even in the absence of light.
  39402. */
  39403. emissiveTexture: Nullable<BaseTexture>;
  39404. private _specularTexture;
  39405. /**
  39406. * Define how the color and intensity of the highlight given by the light in the material.
  39407. */
  39408. specularTexture: Nullable<BaseTexture>;
  39409. private _bumpTexture;
  39410. /**
  39411. * Bump mapping is a technique to simulate bump and dents on a rendered surface.
  39412. * 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.
  39413. * @see http://doc.babylonjs.com/how_to/more_materials#bump-map
  39414. */
  39415. bumpTexture: Nullable<BaseTexture>;
  39416. private _lightmapTexture;
  39417. /**
  39418. * Complex lighting can be computationally expensive to compute at runtime.
  39419. * To save on computation, lightmaps may be used to store calculated lighting in a texture which will be applied to a given mesh.
  39420. * @see http://doc.babylonjs.com/babylon101/lights#lightmaps
  39421. */
  39422. lightmapTexture: Nullable<BaseTexture>;
  39423. private _refractionTexture;
  39424. /**
  39425. * Define the texture used to display the refraction.
  39426. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  39427. */
  39428. refractionTexture: Nullable<BaseTexture>;
  39429. /**
  39430. * The color of the material lit by the environmental background lighting.
  39431. * @see http://doc.babylonjs.com/babylon101/materials#ambient-color-example
  39432. */
  39433. ambientColor: Color3;
  39434. /**
  39435. * The basic color of the material as viewed under a light.
  39436. */
  39437. diffuseColor: Color3;
  39438. /**
  39439. * Define how the color and intensity of the highlight given by the light in the material.
  39440. */
  39441. specularColor: Color3;
  39442. /**
  39443. * Define the color of the material as if self lit.
  39444. * This will be mixed in the final result even in the absence of light.
  39445. */
  39446. emissiveColor: Color3;
  39447. /**
  39448. * Defines how sharp are the highlights in the material.
  39449. * The bigger the value the sharper giving a more glossy feeling to the result.
  39450. * Reversely, the smaller the value the blurrier giving a more rough feeling to the result.
  39451. */
  39452. specularPower: number;
  39453. private _useAlphaFromDiffuseTexture;
  39454. /**
  39455. * Does the transparency come from the diffuse texture alpha channel.
  39456. */
  39457. useAlphaFromDiffuseTexture: boolean;
  39458. private _useEmissiveAsIllumination;
  39459. /**
  39460. * If true, the emissive value is added into the end result, otherwise it is multiplied in.
  39461. */
  39462. useEmissiveAsIllumination: boolean;
  39463. private _linkEmissiveWithDiffuse;
  39464. /**
  39465. * If true, some kind of energy conservation will prevent the end result to be more than 1 by reducing
  39466. * the emissive level when the final color is close to one.
  39467. */
  39468. linkEmissiveWithDiffuse: boolean;
  39469. private _useSpecularOverAlpha;
  39470. /**
  39471. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  39472. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  39473. */
  39474. useSpecularOverAlpha: boolean;
  39475. private _useReflectionOverAlpha;
  39476. /**
  39477. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  39478. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  39479. */
  39480. useReflectionOverAlpha: boolean;
  39481. private _disableLighting;
  39482. /**
  39483. * Does lights from the scene impacts this material.
  39484. * It can be a nice trick for performance to disable lighting on a fully emissive material.
  39485. */
  39486. disableLighting: boolean;
  39487. private _useObjectSpaceNormalMap;
  39488. /**
  39489. * Allows using an object space normal map (instead of tangent space).
  39490. */
  39491. useObjectSpaceNormalMap: boolean;
  39492. private _useParallax;
  39493. /**
  39494. * Is parallax enabled or not.
  39495. * @see http://doc.babylonjs.com/how_to/using_parallax_mapping
  39496. */
  39497. useParallax: boolean;
  39498. private _useParallaxOcclusion;
  39499. /**
  39500. * Is parallax occlusion enabled or not.
  39501. * If true, the outcome is way more realistic than traditional Parallax but you can expect a performance hit that worthes consideration.
  39502. * @see http://doc.babylonjs.com/how_to/using_parallax_mapping
  39503. */
  39504. useParallaxOcclusion: boolean;
  39505. /**
  39506. * 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.
  39507. */
  39508. parallaxScaleBias: number;
  39509. private _roughness;
  39510. /**
  39511. * Helps to define how blurry the reflections should appears in the material.
  39512. */
  39513. roughness: number;
  39514. /**
  39515. * In case of refraction, define the value of the indice of refraction.
  39516. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  39517. */
  39518. indexOfRefraction: number;
  39519. /**
  39520. * Invert the refraction texture alongside the y axis.
  39521. * It can be useful with procedural textures or probe for instance.
  39522. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  39523. */
  39524. invertRefractionY: boolean;
  39525. /**
  39526. * Defines the alpha limits in alpha test mode.
  39527. */
  39528. alphaCutOff: number;
  39529. private _useLightmapAsShadowmap;
  39530. /**
  39531. * In case of light mapping, define whether the map contains light or shadow informations.
  39532. */
  39533. useLightmapAsShadowmap: boolean;
  39534. private _diffuseFresnelParameters;
  39535. /**
  39536. * Define the diffuse fresnel parameters of the material.
  39537. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  39538. */
  39539. diffuseFresnelParameters: FresnelParameters;
  39540. private _opacityFresnelParameters;
  39541. /**
  39542. * Define the opacity fresnel parameters of the material.
  39543. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  39544. */
  39545. opacityFresnelParameters: FresnelParameters;
  39546. private _reflectionFresnelParameters;
  39547. /**
  39548. * Define the reflection fresnel parameters of the material.
  39549. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  39550. */
  39551. reflectionFresnelParameters: FresnelParameters;
  39552. private _refractionFresnelParameters;
  39553. /**
  39554. * Define the refraction fresnel parameters of the material.
  39555. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  39556. */
  39557. refractionFresnelParameters: FresnelParameters;
  39558. private _emissiveFresnelParameters;
  39559. /**
  39560. * Define the emissive fresnel parameters of the material.
  39561. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  39562. */
  39563. emissiveFresnelParameters: FresnelParameters;
  39564. private _useReflectionFresnelFromSpecular;
  39565. /**
  39566. * If true automatically deducts the fresnels values from the material specularity.
  39567. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  39568. */
  39569. useReflectionFresnelFromSpecular: boolean;
  39570. private _useGlossinessFromSpecularMapAlpha;
  39571. /**
  39572. * Defines if the glossiness/roughness of the material should be read from the specular map alpha channel
  39573. */
  39574. useGlossinessFromSpecularMapAlpha: boolean;
  39575. private _maxSimultaneousLights;
  39576. /**
  39577. * Defines the maximum number of lights that can be used in the material
  39578. */
  39579. maxSimultaneousLights: number;
  39580. private _invertNormalMapX;
  39581. /**
  39582. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  39583. */
  39584. invertNormalMapX: boolean;
  39585. private _invertNormalMapY;
  39586. /**
  39587. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  39588. */
  39589. invertNormalMapY: boolean;
  39590. private _twoSidedLighting;
  39591. /**
  39592. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  39593. */
  39594. twoSidedLighting: boolean;
  39595. /**
  39596. * Default configuration related to image processing available in the standard Material.
  39597. */
  39598. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  39599. /**
  39600. * Gets the image processing configuration used either in this material.
  39601. */
  39602. /**
  39603. * Sets the Default image processing configuration used either in the this material.
  39604. *
  39605. * If sets to null, the scene one is in use.
  39606. */
  39607. imageProcessingConfiguration: ImageProcessingConfiguration;
  39608. /**
  39609. * Keep track of the image processing observer to allow dispose and replace.
  39610. */
  39611. private _imageProcessingObserver;
  39612. /**
  39613. * Attaches a new image processing configuration to the Standard Material.
  39614. * @param configuration
  39615. */
  39616. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  39617. /**
  39618. * Gets wether the color curves effect is enabled.
  39619. */
  39620. /**
  39621. * Sets wether the color curves effect is enabled.
  39622. */
  39623. cameraColorCurvesEnabled: boolean;
  39624. /**
  39625. * Gets wether the color grading effect is enabled.
  39626. */
  39627. /**
  39628. * Gets wether the color grading effect is enabled.
  39629. */
  39630. cameraColorGradingEnabled: boolean;
  39631. /**
  39632. * Gets wether tonemapping is enabled or not.
  39633. */
  39634. /**
  39635. * Sets wether tonemapping is enabled or not
  39636. */
  39637. cameraToneMappingEnabled: boolean;
  39638. /**
  39639. * The camera exposure used on this material.
  39640. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  39641. * This corresponds to a photographic exposure.
  39642. */
  39643. /**
  39644. * The camera exposure used on this material.
  39645. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  39646. * This corresponds to a photographic exposure.
  39647. */
  39648. cameraExposure: number;
  39649. /**
  39650. * Gets The camera contrast used on this material.
  39651. */
  39652. /**
  39653. * Sets The camera contrast used on this material.
  39654. */
  39655. cameraContrast: number;
  39656. /**
  39657. * Gets the Color Grading 2D Lookup Texture.
  39658. */
  39659. /**
  39660. * Sets the Color Grading 2D Lookup Texture.
  39661. */
  39662. cameraColorGradingTexture: Nullable<BaseTexture>;
  39663. /**
  39664. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  39665. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  39666. * 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;
  39667. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  39668. */
  39669. /**
  39670. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  39671. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  39672. * 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;
  39673. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  39674. */
  39675. cameraColorCurves: Nullable<ColorCurves>;
  39676. /**
  39677. * Custom callback helping to override the default shader used in the material.
  39678. */
  39679. customShaderNameResolve: (shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: StandardMaterialDefines) => string;
  39680. protected _renderTargets: SmartArray<RenderTargetTexture>;
  39681. protected _worldViewProjectionMatrix: Matrix;
  39682. protected _globalAmbientColor: Color3;
  39683. protected _useLogarithmicDepth: boolean;
  39684. /**
  39685. * Instantiates a new standard material.
  39686. * This is the default material used in Babylon. It is the best trade off between quality
  39687. * and performances.
  39688. * @see http://doc.babylonjs.com/babylon101/materials
  39689. * @param name Define the name of the material in the scene
  39690. * @param scene Define the scene the material belong to
  39691. */
  39692. constructor(name: string, scene: Scene);
  39693. /**
  39694. * Gets a boolean indicating that current material needs to register RTT
  39695. */
  39696. readonly hasRenderTargetTextures: boolean;
  39697. /**
  39698. * Gets the current class name of the material e.g. "StandardMaterial"
  39699. * Mainly use in serialization.
  39700. * @returns the class name
  39701. */
  39702. getClassName(): string;
  39703. /**
  39704. * In case the depth buffer does not allow enough depth precision for your scene (might be the case in large scenes)
  39705. * You can try switching to logarithmic depth.
  39706. * @see http://doc.babylonjs.com/how_to/using_logarithmic_depth_buffer
  39707. */
  39708. useLogarithmicDepth: boolean;
  39709. /**
  39710. * Specifies if the material will require alpha blending
  39711. * @returns a boolean specifying if alpha blending is needed
  39712. */
  39713. needAlphaBlending(): boolean;
  39714. /**
  39715. * Specifies if this material should be rendered in alpha test mode
  39716. * @returns a boolean specifying if an alpha test is needed.
  39717. */
  39718. needAlphaTesting(): boolean;
  39719. protected _shouldUseAlphaFromDiffuseTexture(): boolean;
  39720. /**
  39721. * Get the texture used for alpha test purpose.
  39722. * @returns the diffuse texture in case of the standard material.
  39723. */
  39724. getAlphaTestTexture(): Nullable<BaseTexture>;
  39725. /**
  39726. * Get if the submesh is ready to be used and all its information available.
  39727. * Child classes can use it to update shaders
  39728. * @param mesh defines the mesh to check
  39729. * @param subMesh defines which submesh to check
  39730. * @param useInstances specifies that instances should be used
  39731. * @returns a boolean indicating that the submesh is ready or not
  39732. */
  39733. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  39734. /**
  39735. * Builds the material UBO layouts.
  39736. * Used internally during the effect preparation.
  39737. */
  39738. buildUniformLayout(): void;
  39739. /**
  39740. * Unbinds the material from the mesh
  39741. */
  39742. unbind(): void;
  39743. /**
  39744. * Binds the submesh to this material by preparing the effect and shader to draw
  39745. * @param world defines the world transformation matrix
  39746. * @param mesh defines the mesh containing the submesh
  39747. * @param subMesh defines the submesh to bind the material to
  39748. */
  39749. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  39750. /**
  39751. * Get the list of animatables in the material.
  39752. * @returns the list of animatables object used in the material
  39753. */
  39754. getAnimatables(): IAnimatable[];
  39755. /**
  39756. * Gets the active textures from the material
  39757. * @returns an array of textures
  39758. */
  39759. getActiveTextures(): BaseTexture[];
  39760. /**
  39761. * Specifies if the material uses a texture
  39762. * @param texture defines the texture to check against the material
  39763. * @returns a boolean specifying if the material uses the texture
  39764. */
  39765. hasTexture(texture: BaseTexture): boolean;
  39766. /**
  39767. * Disposes the material
  39768. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  39769. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  39770. */
  39771. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  39772. /**
  39773. * Makes a duplicate of the material, and gives it a new name
  39774. * @param name defines the new name for the duplicated material
  39775. * @returns the cloned material
  39776. */
  39777. clone(name: string): StandardMaterial;
  39778. /**
  39779. * Serializes this material in a JSON representation
  39780. * @returns the serialized material object
  39781. */
  39782. serialize(): any;
  39783. /**
  39784. * Creates a standard material from parsed material data
  39785. * @param source defines the JSON representation of the material
  39786. * @param scene defines the hosting scene
  39787. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  39788. * @returns a new standard material
  39789. */
  39790. static Parse(source: any, scene: Scene, rootUrl: string): StandardMaterial;
  39791. /**
  39792. * Are diffuse textures enabled in the application.
  39793. */
  39794. static DiffuseTextureEnabled: boolean;
  39795. /**
  39796. * Are ambient textures enabled in the application.
  39797. */
  39798. static AmbientTextureEnabled: boolean;
  39799. /**
  39800. * Are opacity textures enabled in the application.
  39801. */
  39802. static OpacityTextureEnabled: boolean;
  39803. /**
  39804. * Are reflection textures enabled in the application.
  39805. */
  39806. static ReflectionTextureEnabled: boolean;
  39807. /**
  39808. * Are emissive textures enabled in the application.
  39809. */
  39810. static EmissiveTextureEnabled: boolean;
  39811. /**
  39812. * Are specular textures enabled in the application.
  39813. */
  39814. static SpecularTextureEnabled: boolean;
  39815. /**
  39816. * Are bump textures enabled in the application.
  39817. */
  39818. static BumpTextureEnabled: boolean;
  39819. /**
  39820. * Are lightmap textures enabled in the application.
  39821. */
  39822. static LightmapTextureEnabled: boolean;
  39823. /**
  39824. * Are refraction textures enabled in the application.
  39825. */
  39826. static RefractionTextureEnabled: boolean;
  39827. /**
  39828. * Are color grading textures enabled in the application.
  39829. */
  39830. static ColorGradingTextureEnabled: boolean;
  39831. /**
  39832. * Are fresnels enabled in the application.
  39833. */
  39834. static FresnelEnabled: boolean;
  39835. }
  39836. }
  39837. declare module "babylonjs/Materials/Textures/dynamicTexture" {
  39838. import { Scene } from "babylonjs/scene";
  39839. import { Texture } from "babylonjs/Materials/Textures/texture";
  39840. /**
  39841. * A class extending Texture allowing drawing on a texture
  39842. * @see http://doc.babylonjs.com/how_to/dynamictexture
  39843. */
  39844. export class DynamicTexture extends Texture {
  39845. private _generateMipMaps;
  39846. private _canvas;
  39847. private _context;
  39848. private _engine;
  39849. /**
  39850. * Creates a DynamicTexture
  39851. * @param name defines the name of the texture
  39852. * @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
  39853. * @param scene defines the scene where you want the texture
  39854. * @param generateMipMaps defines the use of MinMaps or not (default is false)
  39855. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  39856. * @param format defines the texture format to use (default is Engine.TEXTUREFORMAT_RGBA)
  39857. */
  39858. constructor(name: string, options: any, scene: Scene | null | undefined, generateMipMaps: boolean, samplingMode?: number, format?: number);
  39859. /**
  39860. * Get the current class name of the texture useful for serialization or dynamic coding.
  39861. * @returns "DynamicTexture"
  39862. */
  39863. getClassName(): string;
  39864. /**
  39865. * Gets the current state of canRescale
  39866. */
  39867. readonly canRescale: boolean;
  39868. private _recreate;
  39869. /**
  39870. * Scales the texture
  39871. * @param ratio the scale factor to apply to both width and height
  39872. */
  39873. scale(ratio: number): void;
  39874. /**
  39875. * Resizes the texture
  39876. * @param width the new width
  39877. * @param height the new height
  39878. */
  39879. scaleTo(width: number, height: number): void;
  39880. /**
  39881. * Gets the context of the canvas used by the texture
  39882. * @returns the canvas context of the dynamic texture
  39883. */
  39884. getContext(): CanvasRenderingContext2D;
  39885. /**
  39886. * Clears the texture
  39887. */
  39888. clear(): void;
  39889. /**
  39890. * Updates the texture
  39891. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  39892. * @param premulAlpha defines if alpha is stored as premultiplied (default is false)
  39893. */
  39894. update(invertY?: boolean, premulAlpha?: boolean): void;
  39895. /**
  39896. * Draws text onto the texture
  39897. * @param text defines the text to be drawn
  39898. * @param x defines the placement of the text from the left
  39899. * @param y defines the placement of the text from the top when invertY is true and from the bottom when false
  39900. * @param font defines the font to be used with font-style, font-size, font-name
  39901. * @param color defines the color used for the text
  39902. * @param clearColor defines the color for the canvas, use null to not overwrite canvas
  39903. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  39904. * @param update defines whether texture is immediately update (default is true)
  39905. */
  39906. drawText(text: string, x: number, y: number, font: string, color: string, clearColor: string, invertY?: boolean, update?: boolean): void;
  39907. /**
  39908. * Clones the texture
  39909. * @returns the clone of the texture.
  39910. */
  39911. clone(): DynamicTexture;
  39912. /**
  39913. * Serializes the dynamic texture. The scene should be ready before the dynamic texture is serialized
  39914. * @returns a serialized dynamic texture object
  39915. */
  39916. serialize(): any;
  39917. /** @hidden */
  39918. _rebuild(): void;
  39919. }
  39920. }
  39921. declare module "babylonjs/Shaders/imageProcessing.fragment" {
  39922. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  39923. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  39924. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  39925. /** @hidden */
  39926. export var imageProcessingPixelShader: {
  39927. name: string;
  39928. shader: string;
  39929. };
  39930. }
  39931. declare module "babylonjs/PostProcesses/imageProcessingPostProcess" {
  39932. import { Nullable } from "babylonjs/types";
  39933. import { Color4 } from "babylonjs/Maths/math";
  39934. import { Camera } from "babylonjs/Cameras/camera";
  39935. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  39936. import { ColorCurves } from "babylonjs/Materials/colorCurves";
  39937. import { ImageProcessingConfiguration } from "babylonjs/Materials/imageProcessingConfiguration";
  39938. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  39939. import { Engine } from "babylonjs/Engines/engine";
  39940. import "babylonjs/Shaders/imageProcessing.fragment";
  39941. import "babylonjs/Shaders/postprocess.vertex";
  39942. /**
  39943. * ImageProcessingPostProcess
  39944. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#imageprocessing
  39945. */
  39946. export class ImageProcessingPostProcess extends PostProcess {
  39947. /**
  39948. * Default configuration related to image processing available in the PBR Material.
  39949. */
  39950. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  39951. /**
  39952. * Gets the image processing configuration used either in this material.
  39953. */
  39954. /**
  39955. * Sets the Default image processing configuration used either in the this material.
  39956. *
  39957. * If sets to null, the scene one is in use.
  39958. */
  39959. imageProcessingConfiguration: ImageProcessingConfiguration;
  39960. /**
  39961. * Keep track of the image processing observer to allow dispose and replace.
  39962. */
  39963. private _imageProcessingObserver;
  39964. /**
  39965. * Attaches a new image processing configuration to the PBR Material.
  39966. * @param configuration
  39967. */
  39968. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>, doNotBuild?: boolean): void;
  39969. /**
  39970. * Gets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  39971. */
  39972. /**
  39973. * Sets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  39974. */
  39975. colorCurves: Nullable<ColorCurves>;
  39976. /**
  39977. * Gets wether the color curves effect is enabled.
  39978. */
  39979. /**
  39980. * Sets wether the color curves effect is enabled.
  39981. */
  39982. colorCurvesEnabled: boolean;
  39983. /**
  39984. * Gets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  39985. */
  39986. /**
  39987. * Sets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  39988. */
  39989. colorGradingTexture: Nullable<BaseTexture>;
  39990. /**
  39991. * Gets wether the color grading effect is enabled.
  39992. */
  39993. /**
  39994. * Gets wether the color grading effect is enabled.
  39995. */
  39996. colorGradingEnabled: boolean;
  39997. /**
  39998. * Gets exposure used in the effect.
  39999. */
  40000. /**
  40001. * Sets exposure used in the effect.
  40002. */
  40003. exposure: number;
  40004. /**
  40005. * Gets wether tonemapping is enabled or not.
  40006. */
  40007. /**
  40008. * Sets wether tonemapping is enabled or not
  40009. */
  40010. toneMappingEnabled: boolean;
  40011. /**
  40012. * Gets the type of tone mapping effect.
  40013. */
  40014. /**
  40015. * Sets the type of tone mapping effect.
  40016. */
  40017. toneMappingType: number;
  40018. /**
  40019. * Gets contrast used in the effect.
  40020. */
  40021. /**
  40022. * Sets contrast used in the effect.
  40023. */
  40024. contrast: number;
  40025. /**
  40026. * Gets Vignette stretch size.
  40027. */
  40028. /**
  40029. * Sets Vignette stretch size.
  40030. */
  40031. vignetteStretch: number;
  40032. /**
  40033. * Gets Vignette centre X Offset.
  40034. */
  40035. /**
  40036. * Sets Vignette centre X Offset.
  40037. */
  40038. vignetteCentreX: number;
  40039. /**
  40040. * Gets Vignette centre Y Offset.
  40041. */
  40042. /**
  40043. * Sets Vignette centre Y Offset.
  40044. */
  40045. vignetteCentreY: number;
  40046. /**
  40047. * Gets Vignette weight or intensity of the vignette effect.
  40048. */
  40049. /**
  40050. * Sets Vignette weight or intensity of the vignette effect.
  40051. */
  40052. vignetteWeight: number;
  40053. /**
  40054. * Gets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  40055. * if vignetteEnabled is set to true.
  40056. */
  40057. /**
  40058. * Sets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  40059. * if vignetteEnabled is set to true.
  40060. */
  40061. vignetteColor: Color4;
  40062. /**
  40063. * Gets Camera field of view used by the Vignette effect.
  40064. */
  40065. /**
  40066. * Sets Camera field of view used by the Vignette effect.
  40067. */
  40068. vignetteCameraFov: number;
  40069. /**
  40070. * Gets the vignette blend mode allowing different kind of effect.
  40071. */
  40072. /**
  40073. * Sets the vignette blend mode allowing different kind of effect.
  40074. */
  40075. vignetteBlendMode: number;
  40076. /**
  40077. * Gets wether the vignette effect is enabled.
  40078. */
  40079. /**
  40080. * Sets wether the vignette effect is enabled.
  40081. */
  40082. vignetteEnabled: boolean;
  40083. private _fromLinearSpace;
  40084. /**
  40085. * Gets wether the input of the processing is in Gamma or Linear Space.
  40086. */
  40087. /**
  40088. * Sets wether the input of the processing is in Gamma or Linear Space.
  40089. */
  40090. fromLinearSpace: boolean;
  40091. /**
  40092. * Defines cache preventing GC.
  40093. */
  40094. private _defines;
  40095. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, imageProcessingConfiguration?: ImageProcessingConfiguration);
  40096. /**
  40097. * "ImageProcessingPostProcess"
  40098. * @returns "ImageProcessingPostProcess"
  40099. */
  40100. getClassName(): string;
  40101. protected _updateParameters(): void;
  40102. dispose(camera?: Camera): void;
  40103. }
  40104. }
  40105. declare module "babylonjs/Meshes/Builders/groundBuilder" {
  40106. import { Scene } from "babylonjs/scene";
  40107. import { Color3 } from "babylonjs/Maths/math";
  40108. import { Mesh } from "babylonjs/Meshes/mesh";
  40109. import { GroundMesh } from "babylonjs/Meshes/groundMesh";
  40110. /**
  40111. * Class containing static functions to help procedurally build meshes
  40112. */
  40113. export class GroundBuilder {
  40114. /**
  40115. * Creates a ground mesh
  40116. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  40117. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  40118. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  40119. * @param name defines the name of the mesh
  40120. * @param options defines the options used to create the mesh
  40121. * @param scene defines the hosting scene
  40122. * @returns the ground mesh
  40123. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  40124. */
  40125. static CreateGround(name: string, options: {
  40126. width?: number;
  40127. height?: number;
  40128. subdivisions?: number;
  40129. subdivisionsX?: number;
  40130. subdivisionsY?: number;
  40131. updatable?: boolean;
  40132. }, scene: any): Mesh;
  40133. /**
  40134. * Creates a tiled ground mesh
  40135. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  40136. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  40137. * * 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
  40138. * * 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
  40139. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  40140. * @param name defines the name of the mesh
  40141. * @param options defines the options used to create the mesh
  40142. * @param scene defines the hosting scene
  40143. * @returns the tiled ground mesh
  40144. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  40145. */
  40146. static CreateTiledGround(name: string, options: {
  40147. xmin: number;
  40148. zmin: number;
  40149. xmax: number;
  40150. zmax: number;
  40151. subdivisions?: {
  40152. w: number;
  40153. h: number;
  40154. };
  40155. precision?: {
  40156. w: number;
  40157. h: number;
  40158. };
  40159. updatable?: boolean;
  40160. }, scene: Scene): Mesh;
  40161. /**
  40162. * Creates a ground mesh from a height map
  40163. * * The parameter `url` sets the URL of the height map image resource.
  40164. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  40165. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  40166. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  40167. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  40168. * * 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.
  40169. * * 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).
  40170. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  40171. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  40172. * @param name defines the name of the mesh
  40173. * @param url defines the url to the height map
  40174. * @param options defines the options used to create the mesh
  40175. * @param scene defines the hosting scene
  40176. * @returns the ground mesh
  40177. * @see https://doc.babylonjs.com/babylon101/height_map
  40178. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  40179. */
  40180. static CreateGroundFromHeightMap(name: string, url: string, options: {
  40181. width?: number;
  40182. height?: number;
  40183. subdivisions?: number;
  40184. minHeight?: number;
  40185. maxHeight?: number;
  40186. colorFilter?: Color3;
  40187. alphaFilter?: number;
  40188. updatable?: boolean;
  40189. onReady?: (mesh: GroundMesh) => void;
  40190. }, scene: Scene): GroundMesh;
  40191. }
  40192. }
  40193. declare module "babylonjs/Meshes/Builders/torusBuilder" {
  40194. import { Vector4 } from "babylonjs/Maths/math";
  40195. import { Mesh } from "babylonjs/Meshes/mesh";
  40196. /**
  40197. * Class containing static functions to help procedurally build meshes
  40198. */
  40199. export class TorusBuilder {
  40200. /**
  40201. * Creates a torus mesh
  40202. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  40203. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  40204. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  40205. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  40206. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  40207. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  40208. * @param name defines the name of the mesh
  40209. * @param options defines the options used to create the mesh
  40210. * @param scene defines the hosting scene
  40211. * @returns the torus mesh
  40212. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  40213. */
  40214. static CreateTorus(name: string, options: {
  40215. diameter?: number;
  40216. thickness?: number;
  40217. tessellation?: number;
  40218. updatable?: boolean;
  40219. sideOrientation?: number;
  40220. frontUVs?: Vector4;
  40221. backUVs?: Vector4;
  40222. }, scene: any): Mesh;
  40223. }
  40224. }
  40225. declare module "babylonjs/Meshes/Builders/cylinderBuilder" {
  40226. import { Color4, Vector4 } from "babylonjs/Maths/math";
  40227. import { Mesh } from "babylonjs/Meshes/mesh";
  40228. /**
  40229. * Class containing static functions to help procedurally build meshes
  40230. */
  40231. export class CylinderBuilder {
  40232. /**
  40233. * Creates a cylinder or a cone mesh
  40234. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  40235. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  40236. * * 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.
  40237. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  40238. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  40239. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  40240. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  40241. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  40242. * * 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).
  40243. * * 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
  40244. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  40245. * * 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
  40246. * * 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.
  40247. * * If `enclose` is false, a ring surface is one element.
  40248. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  40249. * * 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
  40250. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  40251. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  40252. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  40253. * @param name defines the name of the mesh
  40254. * @param options defines the options used to create the mesh
  40255. * @param scene defines the hosting scene
  40256. * @returns the cylinder mesh
  40257. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  40258. */
  40259. static CreateCylinder(name: string, options: {
  40260. height?: number;
  40261. diameterTop?: number;
  40262. diameterBottom?: number;
  40263. diameter?: number;
  40264. tessellation?: number;
  40265. subdivisions?: number;
  40266. arc?: number;
  40267. faceColors?: Color4[];
  40268. faceUV?: Vector4[];
  40269. updatable?: boolean;
  40270. hasRings?: boolean;
  40271. enclose?: boolean;
  40272. sideOrientation?: number;
  40273. frontUVs?: Vector4;
  40274. backUVs?: Vector4;
  40275. }, scene: any): Mesh;
  40276. }
  40277. }
  40278. declare module "babylonjs/Gamepads/gamepadManager" {
  40279. import { Observable } from "babylonjs/Misc/observable";
  40280. import { Nullable } from "babylonjs/types";
  40281. import { Scene } from "babylonjs/scene";
  40282. import { Gamepad } from "babylonjs/Gamepads/gamepad";
  40283. /**
  40284. * Manager for handling gamepads
  40285. */
  40286. export class GamepadManager {
  40287. private _scene?;
  40288. private _babylonGamepads;
  40289. private _oneGamepadConnected;
  40290. /** @hidden */
  40291. _isMonitoring: boolean;
  40292. private _gamepadEventSupported;
  40293. private _gamepadSupport;
  40294. /**
  40295. * observable to be triggered when the gamepad controller has been connected
  40296. */
  40297. onGamepadConnectedObservable: Observable<Gamepad>;
  40298. /**
  40299. * observable to be triggered when the gamepad controller has been disconnected
  40300. */
  40301. onGamepadDisconnectedObservable: Observable<Gamepad>;
  40302. private _onGamepadConnectedEvent;
  40303. private _onGamepadDisconnectedEvent;
  40304. /**
  40305. * Initializes the gamepad manager
  40306. * @param _scene BabylonJS scene
  40307. */
  40308. constructor(_scene?: Scene | undefined);
  40309. /**
  40310. * The gamepads in the game pad manager
  40311. */
  40312. readonly gamepads: Gamepad[];
  40313. /**
  40314. * Get the gamepad controllers based on type
  40315. * @param type The type of gamepad controller
  40316. * @returns Nullable gamepad
  40317. */
  40318. getGamepadByType(type?: number): Nullable<Gamepad>;
  40319. /**
  40320. * Disposes the gamepad manager
  40321. */
  40322. dispose(): void;
  40323. private _addNewGamepad;
  40324. private _startMonitoringGamepads;
  40325. private _stopMonitoringGamepads;
  40326. /** @hidden */
  40327. _checkGamepadsStatus(): void;
  40328. private _updateGamepadObjects;
  40329. }
  40330. }
  40331. declare module "babylonjs/Gamepads/gamepadSceneComponent" {
  40332. import { Nullable } from "babylonjs/types";
  40333. import { Scene } from "babylonjs/scene";
  40334. import { ISceneComponent } from "babylonjs/sceneComponent";
  40335. import { GamepadManager } from "babylonjs/Gamepads/gamepadManager";
  40336. module "babylonjs/scene" {
  40337. interface Scene {
  40338. /** @hidden */
  40339. _gamepadManager: Nullable<GamepadManager>;
  40340. /**
  40341. * Gets the gamepad manager associated with the scene
  40342. * @see http://doc.babylonjs.com/how_to/how_to_use_gamepads
  40343. */
  40344. gamepadManager: GamepadManager;
  40345. }
  40346. }
  40347. module "babylonjs/Cameras/freeCameraInputsManager" {
  40348. /**
  40349. * Interface representing a free camera inputs manager
  40350. */
  40351. interface FreeCameraInputsManager {
  40352. /**
  40353. * Adds gamepad input support to the FreeCameraInputsManager.
  40354. * @returns the FreeCameraInputsManager
  40355. */
  40356. addGamepad(): FreeCameraInputsManager;
  40357. }
  40358. }
  40359. module "babylonjs/Cameras/arcRotateCameraInputsManager" {
  40360. /**
  40361. * Interface representing an arc rotate camera inputs manager
  40362. */
  40363. interface ArcRotateCameraInputsManager {
  40364. /**
  40365. * Adds gamepad input support to the ArcRotateCamera InputManager.
  40366. * @returns the camera inputs manager
  40367. */
  40368. addGamepad(): ArcRotateCameraInputsManager;
  40369. }
  40370. }
  40371. /**
  40372. * Defines the gamepad scene component responsible to manage gamepads in a given scene
  40373. */
  40374. export class GamepadSystemSceneComponent implements ISceneComponent {
  40375. /**
  40376. * The component name helpfull to identify the component in the list of scene components.
  40377. */
  40378. readonly name: string;
  40379. /**
  40380. * The scene the component belongs to.
  40381. */
  40382. scene: Scene;
  40383. /**
  40384. * Creates a new instance of the component for the given scene
  40385. * @param scene Defines the scene to register the component in
  40386. */
  40387. constructor(scene: Scene);
  40388. /**
  40389. * Registers the component in a given scene
  40390. */
  40391. register(): void;
  40392. /**
  40393. * Rebuilds the elements related to this component in case of
  40394. * context lost for instance.
  40395. */
  40396. rebuild(): void;
  40397. /**
  40398. * Disposes the component and the associated ressources
  40399. */
  40400. dispose(): void;
  40401. private _beforeCameraUpdate;
  40402. }
  40403. }
  40404. declare module "babylonjs/Cameras/VR/vrExperienceHelper" {
  40405. import { Observable } from "babylonjs/Misc/observable";
  40406. import { Nullable } from "babylonjs/types";
  40407. import { Camera } from "babylonjs/Cameras/camera";
  40408. import { DeviceOrientationCamera } from "babylonjs/Cameras/deviceOrientationCamera";
  40409. import { VRDeviceOrientationFreeCamera } from "babylonjs/Cameras/VR/vrDeviceOrientationFreeCamera";
  40410. import { WebVROptions, WebVRFreeCamera } from "babylonjs/Cameras/VR/webVRCamera";
  40411. import { Scene } from "babylonjs/scene";
  40412. import { Vector3, Color3 } from "babylonjs/Maths/math";
  40413. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  40414. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  40415. import { Mesh } from "babylonjs/Meshes/mesh";
  40416. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  40417. import { VRCameraMetrics } from "babylonjs/Cameras/VR/vrCameraMetrics";
  40418. import "babylonjs/Meshes/Builders/groundBuilder";
  40419. import "babylonjs/Meshes/Builders/torusBuilder";
  40420. import "babylonjs/Meshes/Builders/cylinderBuilder";
  40421. import "babylonjs/Gamepads/gamepadSceneComponent";
  40422. import "babylonjs/Animations/animatable";
  40423. /**
  40424. * Options to modify the vr teleportation behavior.
  40425. */
  40426. export interface VRTeleportationOptions {
  40427. /**
  40428. * The name of the mesh which should be used as the teleportation floor. (default: null)
  40429. */
  40430. floorMeshName?: string;
  40431. /**
  40432. * A list of meshes to be used as the teleportation floor. (default: empty)
  40433. */
  40434. floorMeshes?: Mesh[];
  40435. }
  40436. /**
  40437. * Options to modify the vr experience helper's behavior.
  40438. */
  40439. export interface VRExperienceHelperOptions extends WebVROptions {
  40440. /**
  40441. * Create a DeviceOrientationCamera to be used as your out of vr camera. (default: true)
  40442. */
  40443. createDeviceOrientationCamera?: boolean;
  40444. /**
  40445. * Create a VRDeviceOrientationFreeCamera to be used for VR when no external HMD is found. (default: true)
  40446. */
  40447. createFallbackVRDeviceOrientationFreeCamera?: boolean;
  40448. /**
  40449. * Uses the main button on the controller to toggle the laser casted. (default: true)
  40450. */
  40451. laserToggle?: boolean;
  40452. /**
  40453. * A list of meshes to be used as the teleportation floor. If specified, teleportation will be enabled (default: undefined)
  40454. */
  40455. floorMeshes?: Mesh[];
  40456. /**
  40457. * Distortion metrics for the fallback vrDeviceOrientationCamera (default: VRCameraMetrics.Default)
  40458. */
  40459. vrDeviceOrientationCameraMetrics?: VRCameraMetrics;
  40460. }
  40461. /**
  40462. * Event containing information after VR has been entered
  40463. */
  40464. export class OnAfterEnteringVRObservableEvent {
  40465. /**
  40466. * If entering vr was successful
  40467. */
  40468. success: boolean;
  40469. }
  40470. /**
  40471. * Helps to quickly add VR support to an existing scene.
  40472. * See http://doc.babylonjs.com/how_to/webvr_helper
  40473. */
  40474. export class VRExperienceHelper {
  40475. /** Options to modify the vr experience helper's behavior. */
  40476. webVROptions: VRExperienceHelperOptions;
  40477. private _scene;
  40478. private _position;
  40479. private _btnVR;
  40480. private _btnVRDisplayed;
  40481. private _webVRsupported;
  40482. private _webVRready;
  40483. private _webVRrequesting;
  40484. private _webVRpresenting;
  40485. private _hasEnteredVR;
  40486. private _fullscreenVRpresenting;
  40487. private _canvas;
  40488. private _webVRCamera;
  40489. private _vrDeviceOrientationCamera;
  40490. private _deviceOrientationCamera;
  40491. private _existingCamera;
  40492. private _onKeyDown;
  40493. private _onVrDisplayPresentChange;
  40494. private _onVRDisplayChanged;
  40495. private _onVRRequestPresentStart;
  40496. private _onVRRequestPresentComplete;
  40497. /**
  40498. * Observable raised right before entering VR.
  40499. */
  40500. onEnteringVRObservable: Observable<VRExperienceHelper>;
  40501. /**
  40502. * Observable raised when entering VR has completed.
  40503. */
  40504. onAfterEnteringVRObservable: Observable<OnAfterEnteringVRObservableEvent>;
  40505. /**
  40506. * Observable raised when exiting VR.
  40507. */
  40508. onExitingVRObservable: Observable<VRExperienceHelper>;
  40509. /**
  40510. * Observable raised when controller mesh is loaded.
  40511. */
  40512. onControllerMeshLoadedObservable: Observable<WebVRController>;
  40513. /** Return this.onEnteringVRObservable
  40514. * Note: This one is for backward compatibility. Please use onEnteringVRObservable directly
  40515. */
  40516. readonly onEnteringVR: Observable<VRExperienceHelper>;
  40517. /** Return this.onExitingVRObservable
  40518. * Note: This one is for backward compatibility. Please use onExitingVRObservable directly
  40519. */
  40520. readonly onExitingVR: Observable<VRExperienceHelper>;
  40521. /** Return this.onControllerMeshLoadedObservable
  40522. * Note: This one is for backward compatibility. Please use onControllerMeshLoadedObservable directly
  40523. */
  40524. readonly onControllerMeshLoaded: Observable<WebVRController>;
  40525. private _rayLength;
  40526. private _useCustomVRButton;
  40527. private _teleportationRequested;
  40528. private _teleportActive;
  40529. private _floorMeshName;
  40530. private _floorMeshesCollection;
  40531. private _rotationAllowed;
  40532. private _teleportBackwardsVector;
  40533. private _teleportationTarget;
  40534. private _isDefaultTeleportationTarget;
  40535. private _postProcessMove;
  40536. private _teleportationFillColor;
  40537. private _teleportationBorderColor;
  40538. private _rotationAngle;
  40539. private _haloCenter;
  40540. private _cameraGazer;
  40541. private _padSensibilityUp;
  40542. private _padSensibilityDown;
  40543. private _leftController;
  40544. private _rightController;
  40545. /**
  40546. * Observable raised when a new mesh is selected based on meshSelectionPredicate
  40547. */
  40548. onNewMeshSelected: Observable<AbstractMesh>;
  40549. /**
  40550. * Observable raised when a new mesh is picked based on meshSelectionPredicate
  40551. */
  40552. onNewMeshPicked: Observable<PickingInfo>;
  40553. private _circleEase;
  40554. /**
  40555. * Observable raised before camera teleportation
  40556. */
  40557. onBeforeCameraTeleport: Observable<Vector3>;
  40558. /**
  40559. * Observable raised after camera teleportation
  40560. */
  40561. onAfterCameraTeleport: Observable<Vector3>;
  40562. /**
  40563. * Observable raised when current selected mesh gets unselected
  40564. */
  40565. onSelectedMeshUnselected: Observable<AbstractMesh>;
  40566. private _raySelectionPredicate;
  40567. /**
  40568. * To be optionaly changed by user to define custom ray selection
  40569. */
  40570. raySelectionPredicate: (mesh: AbstractMesh) => boolean;
  40571. /**
  40572. * To be optionaly changed by user to define custom selection logic (after ray selection)
  40573. */
  40574. meshSelectionPredicate: (mesh: AbstractMesh) => boolean;
  40575. /**
  40576. * Set teleportation enabled. If set to false camera teleportation will be disabled but camera rotation will be kept.
  40577. */
  40578. teleportationEnabled: boolean;
  40579. private _defaultHeight;
  40580. private _teleportationInitialized;
  40581. private _interactionsEnabled;
  40582. private _interactionsRequested;
  40583. private _displayGaze;
  40584. private _displayLaserPointer;
  40585. /**
  40586. * The mesh used to display where the user is going to teleport.
  40587. */
  40588. /**
  40589. * Sets the mesh to be used to display where the user is going to teleport.
  40590. */
  40591. teleportationTarget: Mesh;
  40592. /**
  40593. * 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
  40594. * when set bakeCurrentTransformIntoVertices will be called on the mesh.
  40595. * See http://doc.babylonjs.com/resources/baking_transformations
  40596. */
  40597. gazeTrackerMesh: Mesh;
  40598. /**
  40599. * If the gaze trackers scale should be updated to be constant size when pointing at near/far meshes
  40600. */
  40601. updateGazeTrackerScale: boolean;
  40602. /**
  40603. * If the gaze trackers color should be updated when selecting meshes
  40604. */
  40605. updateGazeTrackerColor: boolean;
  40606. /**
  40607. * The gaze tracking mesh corresponding to the left controller
  40608. */
  40609. readonly leftControllerGazeTrackerMesh: Nullable<Mesh>;
  40610. /**
  40611. * The gaze tracking mesh corresponding to the right controller
  40612. */
  40613. readonly rightControllerGazeTrackerMesh: Nullable<Mesh>;
  40614. /**
  40615. * If the ray of the gaze should be displayed.
  40616. */
  40617. /**
  40618. * Sets if the ray of the gaze should be displayed.
  40619. */
  40620. displayGaze: boolean;
  40621. /**
  40622. * If the ray of the LaserPointer should be displayed.
  40623. */
  40624. /**
  40625. * Sets if the ray of the LaserPointer should be displayed.
  40626. */
  40627. displayLaserPointer: boolean;
  40628. /**
  40629. * The deviceOrientationCamera used as the camera when not in VR.
  40630. */
  40631. readonly deviceOrientationCamera: Nullable<DeviceOrientationCamera>;
  40632. /**
  40633. * Based on the current WebVR support, returns the current VR camera used.
  40634. */
  40635. readonly currentVRCamera: Nullable<Camera>;
  40636. /**
  40637. * The webVRCamera which is used when in VR.
  40638. */
  40639. readonly webVRCamera: WebVRFreeCamera;
  40640. /**
  40641. * The deviceOrientationCamera that is used as a fallback when vr device is not connected.
  40642. */
  40643. readonly vrDeviceOrientationCamera: Nullable<VRDeviceOrientationFreeCamera>;
  40644. private readonly _teleportationRequestInitiated;
  40645. /**
  40646. * Defines wether or not Pointer lock should be requested when switching to
  40647. * full screen.
  40648. */
  40649. requestPointerLockOnFullScreen: boolean;
  40650. /**
  40651. * Instantiates a VRExperienceHelper.
  40652. * Helps to quickly add VR support to an existing scene.
  40653. * @param scene The scene the VRExperienceHelper belongs to.
  40654. * @param webVROptions Options to modify the vr experience helper's behavior.
  40655. */
  40656. constructor(scene: Scene,
  40657. /** Options to modify the vr experience helper's behavior. */
  40658. webVROptions?: VRExperienceHelperOptions);
  40659. private _onDefaultMeshLoaded;
  40660. private _onResize;
  40661. private _onFullscreenChange;
  40662. /**
  40663. * Gets a value indicating if we are currently in VR mode.
  40664. */
  40665. readonly isInVRMode: boolean;
  40666. private onVrDisplayPresentChange;
  40667. private onVRDisplayChanged;
  40668. private moveButtonToBottomRight;
  40669. private displayVRButton;
  40670. private updateButtonVisibility;
  40671. private _cachedAngularSensibility;
  40672. /**
  40673. * Attempt to enter VR. If a headset is connected and ready, will request present on that.
  40674. * Otherwise, will use the fullscreen API.
  40675. */
  40676. enterVR(): void;
  40677. /**
  40678. * Attempt to exit VR, or fullscreen.
  40679. */
  40680. exitVR(): void;
  40681. /**
  40682. * The position of the vr experience helper.
  40683. */
  40684. /**
  40685. * Sets the position of the vr experience helper.
  40686. */
  40687. position: Vector3;
  40688. /**
  40689. * Enables controllers and user interactions such as selecting and object or clicking on an object.
  40690. */
  40691. enableInteractions(): void;
  40692. private readonly _noControllerIsActive;
  40693. private beforeRender;
  40694. private _isTeleportationFloor;
  40695. /**
  40696. * Adds a floor mesh to be used for teleportation.
  40697. * @param floorMesh the mesh to be used for teleportation.
  40698. */
  40699. addFloorMesh(floorMesh: Mesh): void;
  40700. /**
  40701. * Removes a floor mesh from being used for teleportation.
  40702. * @param floorMesh the mesh to be removed.
  40703. */
  40704. removeFloorMesh(floorMesh: Mesh): void;
  40705. /**
  40706. * Enables interactions and teleportation using the VR controllers and gaze.
  40707. * @param vrTeleportationOptions options to modify teleportation behavior.
  40708. */
  40709. enableTeleportation(vrTeleportationOptions?: VRTeleportationOptions): void;
  40710. private _onNewGamepadConnected;
  40711. private _tryEnableInteractionOnController;
  40712. private _onNewGamepadDisconnected;
  40713. private _enableInteractionOnController;
  40714. private _checkTeleportWithRay;
  40715. private _checkRotate;
  40716. private _checkTeleportBackwards;
  40717. private _enableTeleportationOnController;
  40718. private _createTeleportationCircles;
  40719. private _displayTeleportationTarget;
  40720. private _hideTeleportationTarget;
  40721. private _rotateCamera;
  40722. private _moveTeleportationSelectorTo;
  40723. private _workingVector;
  40724. private _workingQuaternion;
  40725. private _workingMatrix;
  40726. /**
  40727. * Teleports the users feet to the desired location
  40728. * @param location The location where the user's feet should be placed
  40729. */
  40730. teleportCamera(location: Vector3): void;
  40731. private _convertNormalToDirectionOfRay;
  40732. private _castRayAndSelectObject;
  40733. private _notifySelectedMeshUnselected;
  40734. /**
  40735. * Sets the color of the laser ray from the vr controllers.
  40736. * @param color new color for the ray.
  40737. */
  40738. changeLaserColor(color: Color3): void;
  40739. /**
  40740. * Sets the color of the ray from the vr headsets gaze.
  40741. * @param color new color for the ray.
  40742. */
  40743. changeGazeColor(color: Color3): void;
  40744. /**
  40745. * Exits VR and disposes of the vr experience helper
  40746. */
  40747. dispose(): void;
  40748. /**
  40749. * Gets the name of the VRExperienceHelper class
  40750. * @returns "VRExperienceHelper"
  40751. */
  40752. getClassName(): string;
  40753. }
  40754. }
  40755. declare module "babylonjs/Cameras/VR/index" {
  40756. export * from "babylonjs/Cameras/VR/vrCameraMetrics";
  40757. export * from "babylonjs/Cameras/VR/vrDeviceOrientationArcRotateCamera";
  40758. export * from "babylonjs/Cameras/VR/vrDeviceOrientationFreeCamera";
  40759. export * from "babylonjs/Cameras/VR/vrDeviceOrientationGamepadCamera";
  40760. export * from "babylonjs/Cameras/VR/vrExperienceHelper";
  40761. export * from "babylonjs/Cameras/VR/webVRCamera";
  40762. }
  40763. declare module "babylonjs/Cameras/XR/webXRSessionManager" {
  40764. import { Observable } from "babylonjs/Misc/observable";
  40765. import { Nullable } from "babylonjs/types";
  40766. import { IDisposable, Scene } from "babylonjs/scene";
  40767. import { Vector3 } from "babylonjs/Maths/math";
  40768. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  40769. import { Ray } from "babylonjs/Culling/ray";
  40770. /**
  40771. * Manages an XRSession
  40772. * @see https://doc.babylonjs.com/how_to/webxr
  40773. */
  40774. export class WebXRSessionManager implements IDisposable {
  40775. private scene;
  40776. /**
  40777. * Fires every time a new xrFrame arrives which can be used to update the camera
  40778. */
  40779. onXRFrameObservable: Observable<any>;
  40780. /**
  40781. * Fires when the xr session is ended either by the device or manually done
  40782. */
  40783. onXRSessionEnded: Observable<any>;
  40784. /** @hidden */
  40785. _xrSession: XRSession;
  40786. /** @hidden */
  40787. _frameOfReference: XRFrameOfReference;
  40788. /** @hidden */
  40789. _sessionRenderTargetTexture: Nullable<RenderTargetTexture>;
  40790. /** @hidden */
  40791. _currentXRFrame: Nullable<XRFrame>;
  40792. private _xrNavigator;
  40793. private _xrDevice;
  40794. private _tmpMatrix;
  40795. /**
  40796. * Constructs a WebXRSessionManager, this must be initialized within a user action before usage
  40797. * @param scene The scene which the session should be created for
  40798. */
  40799. constructor(scene: Scene);
  40800. /**
  40801. * Initializes the manager
  40802. * After initialization enterXR can be called to start an XR session
  40803. * @returns Promise which resolves after it is initialized
  40804. */
  40805. initializeAsync(): Promise<void>;
  40806. /**
  40807. * Enters XR with the desired XR session options, this must be done with a user action (eg. button click event)
  40808. * @param sessionCreationOptions xr options to create the session with
  40809. * @param frameOfReferenceType option to configure how the xr pose is expressed
  40810. * @returns Promise which resolves after it enters XR
  40811. */
  40812. enterXRAsync(sessionCreationOptions: XRSessionCreationOptions, frameOfReferenceType: string): Promise<void>;
  40813. /**
  40814. * Stops the xrSession and restores the renderloop
  40815. * @returns Promise which resolves after it exits XR
  40816. */
  40817. exitXRAsync(): Promise<void>;
  40818. /**
  40819. * Fires a ray and returns the closest hit in the xr sessions enviornment, useful to place objects in AR
  40820. * @param ray ray to cast into the environment
  40821. * @returns Promise which resolves with a collision point in the environment if it exists
  40822. */
  40823. environmentPointHitTestAsync(ray: Ray): Promise<Nullable<Vector3>>;
  40824. /**
  40825. * Checks if a session would be supported for the creation options specified
  40826. * @param options creation options to check if they are supported
  40827. * @returns true if supported
  40828. */
  40829. supportsSessionAsync(options: XRSessionCreationOptions): Promise<boolean>;
  40830. /**
  40831. * @hidden
  40832. * Converts the render layer of xrSession to a render target
  40833. * @param session session to create render target for
  40834. * @param scene scene the new render target should be created for
  40835. */
  40836. static _CreateRenderTargetTextureFromSession(session: XRSession, scene: Scene): RenderTargetTexture;
  40837. /**
  40838. * Disposes of the session manager
  40839. */
  40840. dispose(): void;
  40841. }
  40842. }
  40843. declare module "babylonjs/Cameras/XR/webXRCamera" {
  40844. import { Scene } from "babylonjs/scene";
  40845. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  40846. import { WebXRSessionManager } from "babylonjs/Cameras/XR/webXRSessionManager";
  40847. /**
  40848. * WebXR Camera which holds the views for the xrSession
  40849. * @see https://doc.babylonjs.com/how_to/webxr
  40850. */
  40851. export class WebXRCamera extends FreeCamera {
  40852. private static _TmpMatrix;
  40853. /**
  40854. * Creates a new webXRCamera, this should only be set at the camera after it has been updated by the xrSessionManager
  40855. * @param name the name of the camera
  40856. * @param scene the scene to add the camera to
  40857. */
  40858. constructor(name: string, scene: Scene);
  40859. private _updateNumberOfRigCameras;
  40860. /** @hidden */
  40861. _updateForDualEyeDebugging(pupilDistance?: number): void;
  40862. /**
  40863. * Updates the cameras position from the current pose information of the XR session
  40864. * @param xrSessionManager the session containing pose information
  40865. * @returns true if the camera has been updated, false if the session did not contain pose or frame data
  40866. */
  40867. updateFromXRSessionManager(xrSessionManager: WebXRSessionManager): boolean;
  40868. }
  40869. }
  40870. declare module "babylonjs/Cameras/XR/webXRExperienceHelper" {
  40871. import { Nullable } from "babylonjs/types";
  40872. import { Observable } from "babylonjs/Misc/observable";
  40873. import { IDisposable, Scene } from "babylonjs/scene";
  40874. import { Quaternion, Vector3 } from "babylonjs/Maths/math";
  40875. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  40876. import { Ray } from "babylonjs/Culling/ray";
  40877. import { WebXRSessionManager } from "babylonjs/Cameras/XR/webXRSessionManager";
  40878. import { WebXRCamera } from "babylonjs/Cameras/XR/webXRCamera";
  40879. /**
  40880. * States of the webXR experience
  40881. */
  40882. export enum WebXRState {
  40883. /**
  40884. * Transitioning to being in XR mode
  40885. */
  40886. ENTERING_XR = 0,
  40887. /**
  40888. * Transitioning to non XR mode
  40889. */
  40890. EXITING_XR = 1,
  40891. /**
  40892. * In XR mode and presenting
  40893. */
  40894. IN_XR = 2,
  40895. /**
  40896. * Not entered XR mode
  40897. */
  40898. NOT_IN_XR = 3
  40899. }
  40900. /**
  40901. * Helper class used to enable XR
  40902. * @see https://doc.babylonjs.com/how_to/webxr
  40903. */
  40904. export class WebXRExperienceHelper implements IDisposable {
  40905. private scene;
  40906. /**
  40907. * 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
  40908. */
  40909. container: AbstractMesh;
  40910. /**
  40911. * Camera used to render xr content
  40912. */
  40913. camera: WebXRCamera;
  40914. /**
  40915. * The current state of the XR experience (eg. transitioning, in XR or not in XR)
  40916. */
  40917. state: WebXRState;
  40918. private _setState;
  40919. private static _TmpVector;
  40920. /**
  40921. * Fires when the state of the experience helper has changed
  40922. */
  40923. onStateChangedObservable: Observable<WebXRState>;
  40924. /** @hidden */
  40925. _sessionManager: WebXRSessionManager;
  40926. private _nonVRCamera;
  40927. private _originalSceneAutoClear;
  40928. private _supported;
  40929. /**
  40930. * Creates the experience helper
  40931. * @param scene the scene to attach the experience helper to
  40932. * @returns a promise for the experience helper
  40933. */
  40934. static CreateAsync(scene: Scene): Promise<WebXRExperienceHelper>;
  40935. /**
  40936. * Creates a WebXRExperienceHelper
  40937. * @param scene The scene the helper should be created in
  40938. */
  40939. private constructor();
  40940. /**
  40941. * Exits XR mode and returns the scene to its original state
  40942. * @returns promise that resolves after xr mode has exited
  40943. */
  40944. exitXRAsync(): Promise<void>;
  40945. /**
  40946. * Enters XR mode (This must be done within a user interaction in most browsers eg. button click)
  40947. * @param sessionCreationOptions options for the XR session
  40948. * @param frameOfReference frame of reference of the XR session
  40949. * @returns promise that resolves after xr mode has entered
  40950. */
  40951. enterXRAsync(sessionCreationOptions: XRSessionCreationOptions, frameOfReference: string): Promise<void>;
  40952. /**
  40953. * Fires a ray and returns the closest hit in the xr sessions enviornment, useful to place objects in AR
  40954. * @param ray ray to cast into the environment
  40955. * @returns Promise which resolves with a collision point in the environment if it exists
  40956. */
  40957. environmentPointHitTestAsync(ray: Ray): Promise<Nullable<Vector3>>;
  40958. /**
  40959. * Updates the global position of the camera by moving the camera's container
  40960. * This should be used instead of modifying the camera's position as it will be overwritten by an xrSessions's update frame
  40961. * @param position The desired global position of the camera
  40962. */
  40963. setPositionOfCameraUsingContainer(position: Vector3): void;
  40964. /**
  40965. * Rotates the xr camera by rotating the camera's container around the camera's position
  40966. * This should be used instead of modifying the camera's rotation as it will be overwritten by an xrSessions's update frame
  40967. * @param rotation the desired quaternion rotation to apply to the camera
  40968. */
  40969. rotateCameraByQuaternionUsingContainer(rotation: Quaternion): void;
  40970. /**
  40971. * Checks if the creation options are supported by the xr session
  40972. * @param options creation options
  40973. * @returns true if supported
  40974. */
  40975. supportsSessionAsync(options: XRSessionCreationOptions): Promise<boolean>;
  40976. /**
  40977. * Disposes of the experience helper
  40978. */
  40979. dispose(): void;
  40980. }
  40981. }
  40982. declare module "babylonjs/Cameras/XR/webXREnterExitUI" {
  40983. import { Nullable } from "babylonjs/types";
  40984. import { Observable } from "babylonjs/Misc/observable";
  40985. import { IDisposable, Scene } from "babylonjs/scene";
  40986. import { WebXRExperienceHelper } from "babylonjs/Cameras/XR/webXRExperienceHelper";
  40987. /**
  40988. * Button which can be used to enter a different mode of XR
  40989. */
  40990. export class WebXREnterExitUIButton {
  40991. /** button element */
  40992. element: HTMLElement;
  40993. /** XR initialization options for the button */
  40994. initializationOptions: XRSessionCreationOptions;
  40995. /**
  40996. * Creates a WebXREnterExitUIButton
  40997. * @param element button element
  40998. * @param initializationOptions XR initialization options for the button
  40999. */
  41000. constructor(
  41001. /** button element */
  41002. element: HTMLElement,
  41003. /** XR initialization options for the button */
  41004. initializationOptions: XRSessionCreationOptions);
  41005. /**
  41006. * Overwritable function which can be used to update the button's visuals when the state changes
  41007. * @param activeButton the current active button in the UI
  41008. */
  41009. update(activeButton: Nullable<WebXREnterExitUIButton>): void;
  41010. }
  41011. /**
  41012. * Options to create the webXR UI
  41013. */
  41014. export class WebXREnterExitUIOptions {
  41015. /**
  41016. * Context to enter xr with
  41017. */
  41018. outputCanvasContext?: Nullable<WebGLRenderingContext>;
  41019. /**
  41020. * User provided buttons to enable/disable WebXR. The system will provide default if not set
  41021. */
  41022. customButtons?: Array<WebXREnterExitUIButton>;
  41023. }
  41024. /**
  41025. * UI to allow the user to enter/exit XR mode
  41026. */
  41027. export class WebXREnterExitUI implements IDisposable {
  41028. private scene;
  41029. private _overlay;
  41030. private _buttons;
  41031. private _activeButton;
  41032. /**
  41033. * Fired every time the active button is changed.
  41034. *
  41035. * When xr is entered via a button that launches xr that button will be the callback parameter
  41036. *
  41037. * When exiting xr the callback parameter will be null)
  41038. */
  41039. activeButtonChangedObservable: Observable<Nullable<WebXREnterExitUIButton>>;
  41040. /**
  41041. * Creates UI to allow the user to enter/exit XR mode
  41042. * @param scene the scene to add the ui to
  41043. * @param helper the xr experience helper to enter/exit xr with
  41044. * @param options options to configure the UI
  41045. * @returns the created ui
  41046. */
  41047. static CreateAsync(scene: Scene, helper: WebXRExperienceHelper, options: WebXREnterExitUIOptions): Promise<WebXREnterExitUI>;
  41048. private constructor();
  41049. private _updateButtons;
  41050. /**
  41051. * Disposes of the object
  41052. */
  41053. dispose(): void;
  41054. }
  41055. }
  41056. declare module "babylonjs/Cameras/XR/webXRInput" {
  41057. import { IDisposable, Scene } from "babylonjs/scene";
  41058. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  41059. import { WebXRExperienceHelper } from "babylonjs/Cameras/XR/webXRExperienceHelper";
  41060. /**
  41061. * Represents an XR input
  41062. */
  41063. export class WebXRController {
  41064. /**
  41065. * 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
  41066. */
  41067. grip?: AbstractMesh;
  41068. /**
  41069. * Pointer which can be used to select objects or attach a visible laser to
  41070. */
  41071. pointer: AbstractMesh;
  41072. /**
  41073. * Creates the controller
  41074. * @see https://doc.babylonjs.com/how_to/webxr
  41075. * @param scene the scene which the controller should be associated to
  41076. */
  41077. constructor(scene: Scene);
  41078. /**
  41079. * Disposes of the object
  41080. */
  41081. dispose(): void;
  41082. }
  41083. /**
  41084. * XR input used to track XR inputs such as controllers/rays
  41085. */
  41086. export class WebXRInput implements IDisposable {
  41087. private helper;
  41088. /**
  41089. * XR controllers being tracked
  41090. */
  41091. controllers: Array<WebXRController>;
  41092. private _tmpMatrix;
  41093. private _frameObserver;
  41094. /**
  41095. * Initializes the WebXRInput
  41096. * @param helper experience helper which the input should be created for
  41097. */
  41098. constructor(helper: WebXRExperienceHelper);
  41099. /**
  41100. * Disposes of the object
  41101. */
  41102. dispose(): void;
  41103. }
  41104. }
  41105. declare module "babylonjs/Cameras/XR/webXRManagedOutputCanvas" {
  41106. import { Nullable } from "babylonjs/types";
  41107. import { IDisposable } from "babylonjs/scene";
  41108. import { WebXRExperienceHelper } from "babylonjs/Cameras/XR/webXRExperienceHelper";
  41109. /**
  41110. * Creates a canvas that is added/removed from the webpage when entering/exiting XR
  41111. */
  41112. export class WebXRManagedOutputCanvas implements IDisposable {
  41113. private _canvas;
  41114. /**
  41115. * xrpresent context of the canvas which can be used to display/mirror xr content
  41116. */
  41117. canvasContext: Nullable<WebGLRenderingContext>;
  41118. /**
  41119. * Initializes the canvas to be added/removed upon entering/exiting xr
  41120. * @param helper the xr experience helper used to trigger adding/removing of the canvas
  41121. * @param canvas The canvas to be added/removed (If not specified a full screen canvas will be created)
  41122. */
  41123. constructor(helper: WebXRExperienceHelper, canvas?: HTMLCanvasElement);
  41124. /**
  41125. * Disposes of the object
  41126. */
  41127. dispose(): void;
  41128. private _setManagedOutputCanvas;
  41129. private _addCanvas;
  41130. private _removeCanvas;
  41131. }
  41132. }
  41133. declare module "babylonjs/Cameras/XR/index" {
  41134. export * from "babylonjs/Cameras/XR/webXRCamera";
  41135. export * from "babylonjs/Cameras/XR/webXREnterExitUI";
  41136. export * from "babylonjs/Cameras/XR/webXRExperienceHelper";
  41137. export * from "babylonjs/Cameras/XR/webXRInput";
  41138. export * from "babylonjs/Cameras/XR/webXRManagedOutputCanvas";
  41139. export * from "babylonjs/Cameras/XR/webXRSessionManager";
  41140. }
  41141. declare module "babylonjs/Cameras/RigModes/index" {
  41142. export * from "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode";
  41143. export * from "babylonjs/Cameras/RigModes/stereoscopicRigMode";
  41144. export * from "babylonjs/Cameras/RigModes/vrRigMode";
  41145. export * from "babylonjs/Cameras/RigModes/webVRRigMode";
  41146. }
  41147. declare module "babylonjs/Cameras/index" {
  41148. export * from "babylonjs/Cameras/Inputs/index";
  41149. export * from "babylonjs/Cameras/cameraInputsManager";
  41150. export * from "babylonjs/Cameras/camera";
  41151. export * from "babylonjs/Cameras/targetCamera";
  41152. export * from "babylonjs/Cameras/freeCamera";
  41153. export * from "babylonjs/Cameras/freeCameraInputsManager";
  41154. export * from "babylonjs/Cameras/touchCamera";
  41155. export * from "babylonjs/Cameras/arcRotateCamera";
  41156. export * from "babylonjs/Cameras/arcRotateCameraInputsManager";
  41157. export * from "babylonjs/Cameras/deviceOrientationCamera";
  41158. export * from "babylonjs/Cameras/flyCamera";
  41159. export * from "babylonjs/Cameras/flyCameraInputsManager";
  41160. export * from "babylonjs/Cameras/followCamera";
  41161. export * from "babylonjs/Cameras/gamepadCamera";
  41162. export * from "babylonjs/Cameras/Stereoscopic/index";
  41163. export * from "babylonjs/Cameras/universalCamera";
  41164. export * from "babylonjs/Cameras/virtualJoysticksCamera";
  41165. export * from "babylonjs/Cameras/VR/index";
  41166. export * from "babylonjs/Cameras/XR/index";
  41167. export * from "babylonjs/Cameras/RigModes/index";
  41168. }
  41169. declare module "babylonjs/Collisions/index" {
  41170. export * from "babylonjs/Collisions/collider";
  41171. export * from "babylonjs/Collisions/collisionCoordinator";
  41172. export * from "babylonjs/Collisions/pickingInfo";
  41173. export * from "babylonjs/Collisions/intersectionInfo";
  41174. }
  41175. declare module "babylonjs/Culling/Octrees/octreeBlock" {
  41176. import { SmartArrayNoDuplicate } from "babylonjs/Misc/smartArray";
  41177. import { Vector3, Plane } from "babylonjs/Maths/math";
  41178. import { Ray } from "babylonjs/Culling/ray";
  41179. /**
  41180. * Contains an array of blocks representing the octree
  41181. */
  41182. export interface IOctreeContainer<T> {
  41183. /**
  41184. * Blocks within the octree
  41185. */
  41186. blocks: Array<OctreeBlock<T>>;
  41187. }
  41188. /**
  41189. * Class used to store a cell in an octree
  41190. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  41191. */
  41192. export class OctreeBlock<T> {
  41193. /**
  41194. * Gets the content of the current block
  41195. */
  41196. entries: T[];
  41197. /**
  41198. * Gets the list of block children
  41199. */
  41200. blocks: Array<OctreeBlock<T>>;
  41201. private _depth;
  41202. private _maxDepth;
  41203. private _capacity;
  41204. private _minPoint;
  41205. private _maxPoint;
  41206. private _boundingVectors;
  41207. private _creationFunc;
  41208. /**
  41209. * Creates a new block
  41210. * @param minPoint defines the minimum vector (in world space) of the block's bounding box
  41211. * @param maxPoint defines the maximum vector (in world space) of the block's bounding box
  41212. * @param capacity defines the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  41213. * @param depth defines the current depth of this block in the octree
  41214. * @param maxDepth defines the maximal depth allowed (beyond this value, the capacity is ignored)
  41215. * @param creationFunc defines a callback to call when an element is added to the block
  41216. */
  41217. constructor(minPoint: Vector3, maxPoint: Vector3, capacity: number, depth: number, maxDepth: number, creationFunc: (entry: T, block: OctreeBlock<T>) => void);
  41218. /**
  41219. * Gets the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  41220. */
  41221. readonly capacity: number;
  41222. /**
  41223. * Gets the minimum vector (in world space) of the block's bounding box
  41224. */
  41225. readonly minPoint: Vector3;
  41226. /**
  41227. * Gets the maximum vector (in world space) of the block's bounding box
  41228. */
  41229. readonly maxPoint: Vector3;
  41230. /**
  41231. * Add a new element to this block
  41232. * @param entry defines the element to add
  41233. */
  41234. addEntry(entry: T): void;
  41235. /**
  41236. * Remove an element from this block
  41237. * @param entry defines the element to remove
  41238. */
  41239. removeEntry(entry: T): void;
  41240. /**
  41241. * Add an array of elements to this block
  41242. * @param entries defines the array of elements to add
  41243. */
  41244. addEntries(entries: T[]): void;
  41245. /**
  41246. * Test if the current block intersects the furstum planes and if yes, then add its content to the selection array
  41247. * @param frustumPlanes defines the frustum planes to test
  41248. * @param selection defines the array to store current content if selection is positive
  41249. * @param allowDuplicate defines if the selection array can contains duplicated entries
  41250. */
  41251. select(frustumPlanes: Plane[], selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  41252. /**
  41253. * Test if the current block intersect with the given bounding sphere and if yes, then add its content to the selection array
  41254. * @param sphereCenter defines the bounding sphere center
  41255. * @param sphereRadius defines the bounding sphere radius
  41256. * @param selection defines the array to store current content if selection is positive
  41257. * @param allowDuplicate defines if the selection array can contains duplicated entries
  41258. */
  41259. intersects(sphereCenter: Vector3, sphereRadius: number, selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  41260. /**
  41261. * Test if the current block intersect with the given ray and if yes, then add its content to the selection array
  41262. * @param ray defines the ray to test with
  41263. * @param selection defines the array to store current content if selection is positive
  41264. */
  41265. intersectsRay(ray: Ray, selection: SmartArrayNoDuplicate<T>): void;
  41266. /**
  41267. * Subdivide the content into child blocks (this block will then be empty)
  41268. */
  41269. createInnerBlocks(): void;
  41270. /**
  41271. * @hidden
  41272. */
  41273. 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;
  41274. }
  41275. }
  41276. declare module "babylonjs/Culling/Octrees/octree" {
  41277. import { SmartArray } from "babylonjs/Misc/smartArray";
  41278. import { Vector3, Plane } from "babylonjs/Maths/math";
  41279. import { SubMesh } from "babylonjs/Meshes/subMesh";
  41280. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  41281. import { Ray } from "babylonjs/Culling/ray";
  41282. import { OctreeBlock } from "babylonjs/Culling/Octrees/octreeBlock";
  41283. /**
  41284. * Octrees are a really powerful data structure that can quickly select entities based on space coordinates.
  41285. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  41286. */
  41287. export class Octree<T> {
  41288. /** 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.) */
  41289. maxDepth: number;
  41290. /**
  41291. * Blocks within the octree containing objects
  41292. */
  41293. blocks: Array<OctreeBlock<T>>;
  41294. /**
  41295. * Content stored in the octree
  41296. */
  41297. dynamicContent: T[];
  41298. private _maxBlockCapacity;
  41299. private _selectionContent;
  41300. private _creationFunc;
  41301. /**
  41302. * Creates a octree
  41303. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  41304. * @param creationFunc function to be used to instatiate the octree
  41305. * @param maxBlockCapacity defines the maximum number of meshes you want on your octree's leaves (default: 64)
  41306. * @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.)
  41307. */
  41308. constructor(creationFunc: (entry: T, block: OctreeBlock<T>) => void, maxBlockCapacity?: number,
  41309. /** 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.) */
  41310. maxDepth?: number);
  41311. /**
  41312. * Updates the octree by adding blocks for the passed in meshes within the min and max world parameters
  41313. * @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);
  41314. * @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);
  41315. * @param entries meshes to be added to the octree blocks
  41316. */
  41317. update(worldMin: Vector3, worldMax: Vector3, entries: T[]): void;
  41318. /**
  41319. * Adds a mesh to the octree
  41320. * @param entry Mesh to add to the octree
  41321. */
  41322. addMesh(entry: T): void;
  41323. /**
  41324. * Remove an element from the octree
  41325. * @param entry defines the element to remove
  41326. */
  41327. removeMesh(entry: T): void;
  41328. /**
  41329. * Selects an array of meshes within the frustum
  41330. * @param frustumPlanes The frustum planes to use which will select all meshes within it
  41331. * @param allowDuplicate If duplicate objects are allowed in the resulting object array
  41332. * @returns array of meshes within the frustum
  41333. */
  41334. select(frustumPlanes: Plane[], allowDuplicate?: boolean): SmartArray<T>;
  41335. /**
  41336. * Test if the octree intersect with the given bounding sphere and if yes, then add its content to the selection array
  41337. * @param sphereCenter defines the bounding sphere center
  41338. * @param sphereRadius defines the bounding sphere radius
  41339. * @param allowDuplicate defines if the selection array can contains duplicated entries
  41340. * @returns an array of objects that intersect the sphere
  41341. */
  41342. intersects(sphereCenter: Vector3, sphereRadius: number, allowDuplicate?: boolean): SmartArray<T>;
  41343. /**
  41344. * Test if the octree intersect with the given ray and if yes, then add its content to resulting array
  41345. * @param ray defines the ray to test with
  41346. * @returns array of intersected objects
  41347. */
  41348. intersectsRay(ray: Ray): SmartArray<T>;
  41349. /**
  41350. * Adds a mesh into the octree block if it intersects the block
  41351. */
  41352. static CreationFuncForMeshes: (entry: AbstractMesh, block: OctreeBlock<AbstractMesh>) => void;
  41353. /**
  41354. * Adds a submesh into the octree block if it intersects the block
  41355. */
  41356. static CreationFuncForSubMeshes: (entry: SubMesh, block: OctreeBlock<SubMesh>) => void;
  41357. }
  41358. }
  41359. declare module "babylonjs/Culling/Octrees/octreeSceneComponent" {
  41360. import { ISmartArrayLike } from "babylonjs/Misc/smartArray";
  41361. import { Scene } from "babylonjs/scene";
  41362. import { SubMesh } from "babylonjs/Meshes/subMesh";
  41363. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  41364. import { Ray } from "babylonjs/Culling/ray";
  41365. import { Octree } from "babylonjs/Culling/Octrees/octree";
  41366. import { Collider } from "babylonjs/Collisions/collider";
  41367. module "babylonjs/scene" {
  41368. interface Scene {
  41369. /**
  41370. * @hidden
  41371. * Backing Filed
  41372. */
  41373. _selectionOctree: Octree<AbstractMesh>;
  41374. /**
  41375. * Gets the octree used to boost mesh selection (picking)
  41376. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  41377. */
  41378. selectionOctree: Octree<AbstractMesh>;
  41379. /**
  41380. * Creates or updates the octree used to boost selection (picking)
  41381. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  41382. * @param maxCapacity defines the maximum capacity per leaf
  41383. * @param maxDepth defines the maximum depth of the octree
  41384. * @returns an octree of AbstractMesh
  41385. */
  41386. createOrUpdateSelectionOctree(maxCapacity?: number, maxDepth?: number): Octree<AbstractMesh>;
  41387. }
  41388. }
  41389. module "babylonjs/Meshes/abstractMesh" {
  41390. interface AbstractMesh {
  41391. /**
  41392. * @hidden
  41393. * Backing Field
  41394. */
  41395. _submeshesOctree: Octree<SubMesh>;
  41396. /**
  41397. * This function will create an octree to help to select the right submeshes for rendering, picking and collision computations.
  41398. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  41399. * @param maxCapacity defines the maximum size of each block (64 by default)
  41400. * @param maxDepth defines the maximum depth to use (no more than 2 levels by default)
  41401. * @returns the new octree
  41402. * @see https://www.babylonjs-playground.com/#NA4OQ#12
  41403. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  41404. */
  41405. createOrUpdateSubmeshesOctree(maxCapacity?: number, maxDepth?: number): Octree<SubMesh>;
  41406. }
  41407. }
  41408. /**
  41409. * Defines the octree scene component responsible to manage any octrees
  41410. * in a given scene.
  41411. */
  41412. export class OctreeSceneComponent {
  41413. /**
  41414. * The component name helpfull to identify the component in the list of scene components.
  41415. */
  41416. readonly name: string;
  41417. /**
  41418. * The scene the component belongs to.
  41419. */
  41420. scene: Scene;
  41421. /**
  41422. * Indicates if the meshes have been checked to make sure they are isEnabled()
  41423. */
  41424. readonly checksIsEnabled: boolean;
  41425. /**
  41426. * Creates a new instance of the component for the given scene
  41427. * @param scene Defines the scene to register the component in
  41428. */
  41429. constructor(scene: Scene);
  41430. /**
  41431. * Registers the component in a given scene
  41432. */
  41433. register(): void;
  41434. /**
  41435. * Return the list of active meshes
  41436. * @returns the list of active meshes
  41437. */
  41438. getActiveMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  41439. /**
  41440. * Return the list of active sub meshes
  41441. * @param mesh The mesh to get the candidates sub meshes from
  41442. * @returns the list of active sub meshes
  41443. */
  41444. getActiveSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  41445. private _tempRay;
  41446. /**
  41447. * Return the list of sub meshes intersecting with a given local ray
  41448. * @param mesh defines the mesh to find the submesh for
  41449. * @param localRay defines the ray in local space
  41450. * @returns the list of intersecting sub meshes
  41451. */
  41452. getIntersectingSubMeshCandidates(mesh: AbstractMesh, localRay: Ray): ISmartArrayLike<SubMesh>;
  41453. /**
  41454. * Return the list of sub meshes colliding with a collider
  41455. * @param mesh defines the mesh to find the submesh for
  41456. * @param collider defines the collider to evaluate the collision against
  41457. * @returns the list of colliding sub meshes
  41458. */
  41459. getCollidingSubMeshCandidates(mesh: AbstractMesh, collider: Collider): ISmartArrayLike<SubMesh>;
  41460. /**
  41461. * Rebuilds the elements related to this component in case of
  41462. * context lost for instance.
  41463. */
  41464. rebuild(): void;
  41465. /**
  41466. * Disposes the component and the associated ressources.
  41467. */
  41468. dispose(): void;
  41469. }
  41470. }
  41471. declare module "babylonjs/Culling/Octrees/index" {
  41472. export * from "babylonjs/Culling/Octrees/octree";
  41473. export * from "babylonjs/Culling/Octrees/octreeBlock";
  41474. export * from "babylonjs/Culling/Octrees/octreeSceneComponent";
  41475. }
  41476. declare module "babylonjs/Culling/index" {
  41477. export * from "babylonjs/Culling/boundingBox";
  41478. export * from "babylonjs/Culling/boundingInfo";
  41479. export * from "babylonjs/Culling/boundingSphere";
  41480. export * from "babylonjs/Culling/Octrees/index";
  41481. export * from "babylonjs/Culling/ray";
  41482. }
  41483. declare module "babylonjs/Meshes/Builders/linesBuilder" {
  41484. import { Vector3, Color4 } from "babylonjs/Maths/math";
  41485. import { Nullable } from "babylonjs/types";
  41486. import { LinesMesh } from "babylonjs/Meshes/linesMesh";
  41487. import { Scene } from "babylonjs/scene";
  41488. /**
  41489. * Class containing static functions to help procedurally build meshes
  41490. */
  41491. export class LinesBuilder {
  41492. /**
  41493. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  41494. * * 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
  41495. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  41496. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  41497. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  41498. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  41499. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  41500. * * 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
  41501. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  41502. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  41503. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  41504. * @param name defines the name of the new line system
  41505. * @param options defines the options used to create the line system
  41506. * @param scene defines the hosting scene
  41507. * @returns a new line system mesh
  41508. */
  41509. static CreateLineSystem(name: string, options: {
  41510. lines: Vector3[][];
  41511. updatable?: boolean;
  41512. instance?: Nullable<LinesMesh>;
  41513. colors?: Nullable<Color4[][]>;
  41514. useVertexAlpha?: boolean;
  41515. }, scene: Nullable<Scene>): LinesMesh;
  41516. /**
  41517. * Creates a line mesh
  41518. * 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
  41519. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  41520. * * The parameter `points` is an array successive Vector3
  41521. * * 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
  41522. * * The optional parameter `colors` is an array of successive Color4, one per line point
  41523. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  41524. * * When updating an instance, remember that only point positions can change, not the number of points
  41525. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  41526. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  41527. * @param name defines the name of the new line system
  41528. * @param options defines the options used to create the line system
  41529. * @param scene defines the hosting scene
  41530. * @returns a new line mesh
  41531. */
  41532. static CreateLines(name: string, options: {
  41533. points: Vector3[];
  41534. updatable?: boolean;
  41535. instance?: Nullable<LinesMesh>;
  41536. colors?: Color4[];
  41537. useVertexAlpha?: boolean;
  41538. }, scene?: Nullable<Scene>): LinesMesh;
  41539. /**
  41540. * Creates a dashed line mesh
  41541. * * 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
  41542. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  41543. * * The parameter `points` is an array successive Vector3
  41544. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  41545. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  41546. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  41547. * * 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
  41548. * * When updating an instance, remember that only point positions can change, not the number of points
  41549. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  41550. * @param name defines the name of the mesh
  41551. * @param options defines the options used to create the mesh
  41552. * @param scene defines the hosting scene
  41553. * @returns the dashed line mesh
  41554. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  41555. */
  41556. static CreateDashedLines(name: string, options: {
  41557. points: Vector3[];
  41558. dashSize?: number;
  41559. gapSize?: number;
  41560. dashNb?: number;
  41561. updatable?: boolean;
  41562. instance?: LinesMesh;
  41563. }, scene?: Nullable<Scene>): LinesMesh;
  41564. }
  41565. }
  41566. declare module "babylonjs/Rendering/utilityLayerRenderer" {
  41567. import { IDisposable, Scene } from "babylonjs/scene";
  41568. import { Nullable } from "babylonjs/types";
  41569. import { Observable } from "babylonjs/Misc/observable";
  41570. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  41571. /**
  41572. * Renders a layer on top of an existing scene
  41573. */
  41574. export class UtilityLayerRenderer implements IDisposable {
  41575. /** the original scene that will be rendered on top of */
  41576. originalScene: Scene;
  41577. private _pointerCaptures;
  41578. private _lastPointerEvents;
  41579. private static _DefaultUtilityLayer;
  41580. private static _DefaultKeepDepthUtilityLayer;
  41581. /**
  41582. * If the picking should be done on the utility layer prior to the actual scene (Default: true)
  41583. */
  41584. pickUtilitySceneFirst: boolean;
  41585. /**
  41586. * 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)
  41587. */
  41588. static readonly DefaultUtilityLayer: UtilityLayerRenderer;
  41589. /**
  41590. * 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)
  41591. */
  41592. static readonly DefaultKeepDepthUtilityLayer: UtilityLayerRenderer;
  41593. /**
  41594. * The scene that is rendered on top of the original scene
  41595. */
  41596. utilityLayerScene: Scene;
  41597. /**
  41598. * If the utility layer should automatically be rendered on top of existing scene
  41599. */
  41600. shouldRender: boolean;
  41601. /**
  41602. * If set to true, only pointer down onPointerObservable events will be blocked when picking is occluded by original scene
  41603. */
  41604. onlyCheckPointerDownEvents: boolean;
  41605. /**
  41606. * If set to false, only pointerUp, pointerDown and pointerMove will be sent to the utilityLayerScene (false by default)
  41607. */
  41608. processAllEvents: boolean;
  41609. /**
  41610. * Observable raised when the pointer move from the utility layer scene to the main scene
  41611. */
  41612. onPointerOutObservable: Observable<number>;
  41613. /** Gets or sets a predicate that will be used to indicate utility meshes present in the main scene */
  41614. mainSceneTrackerPredicate: (mesh: Nullable<AbstractMesh>) => boolean;
  41615. private _afterRenderObserver;
  41616. private _sceneDisposeObserver;
  41617. private _originalPointerObserver;
  41618. /**
  41619. * Instantiates a UtilityLayerRenderer
  41620. * @param originalScene the original scene that will be rendered on top of
  41621. * @param handleEvents boolean indicating if the utility layer should handle events
  41622. */
  41623. constructor(
  41624. /** the original scene that will be rendered on top of */
  41625. originalScene: Scene, handleEvents?: boolean);
  41626. private _notifyObservers;
  41627. /**
  41628. * Renders the utility layers scene on top of the original scene
  41629. */
  41630. render(): void;
  41631. /**
  41632. * Disposes of the renderer
  41633. */
  41634. dispose(): void;
  41635. private _updateCamera;
  41636. }
  41637. }
  41638. declare module "babylonjs/Gizmos/gizmo" {
  41639. import { Nullable } from "babylonjs/types";
  41640. import { IDisposable } from "babylonjs/scene";
  41641. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  41642. import { Mesh } from "babylonjs/Meshes/mesh";
  41643. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  41644. /**
  41645. * Renders gizmos on top of an existing scene which provide controls for position, rotation, etc.
  41646. */
  41647. export class Gizmo implements IDisposable {
  41648. /** The utility layer the gizmo will be added to */
  41649. gizmoLayer: UtilityLayerRenderer;
  41650. /**
  41651. * The root mesh of the gizmo
  41652. */
  41653. _rootMesh: Mesh;
  41654. private _attachedMesh;
  41655. /**
  41656. * Ratio for the scale of the gizmo (Default: 1)
  41657. */
  41658. scaleRatio: number;
  41659. private _tmpMatrix;
  41660. /**
  41661. * If a custom mesh has been set (Default: false)
  41662. */
  41663. protected _customMeshSet: boolean;
  41664. /**
  41665. * Mesh that the gizmo will be attached to. (eg. on a drag gizmo the mesh that will be dragged)
  41666. * * When set, interactions will be enabled
  41667. */
  41668. attachedMesh: Nullable<AbstractMesh>;
  41669. /**
  41670. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  41671. * @param mesh The mesh to replace the default mesh of the gizmo
  41672. */
  41673. setCustomMesh(mesh: Mesh): void;
  41674. /**
  41675. * If set the gizmo's rotation will be updated to match the attached mesh each frame (Default: true)
  41676. */
  41677. updateGizmoRotationToMatchAttachedMesh: boolean;
  41678. /**
  41679. * If set the gizmo's position will be updated to match the attached mesh each frame (Default: true)
  41680. */
  41681. updateGizmoPositionToMatchAttachedMesh: boolean;
  41682. /**
  41683. * When set, the gizmo will always appear the same size no matter where the camera is (default: false)
  41684. */
  41685. protected _updateScale: boolean;
  41686. protected _interactionsEnabled: boolean;
  41687. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  41688. private _beforeRenderObserver;
  41689. /**
  41690. * Creates a gizmo
  41691. * @param gizmoLayer The utility layer the gizmo will be added to
  41692. */
  41693. constructor(
  41694. /** The utility layer the gizmo will be added to */
  41695. gizmoLayer?: UtilityLayerRenderer);
  41696. private _tempVector;
  41697. /**
  41698. * @hidden
  41699. * Updates the gizmo to match the attached mesh's position/rotation
  41700. */
  41701. protected _update(): void;
  41702. /**
  41703. * Disposes of the gizmo
  41704. */
  41705. dispose(): void;
  41706. }
  41707. }
  41708. declare module "babylonjs/Gizmos/axisDragGizmo" {
  41709. import { Observable } from "babylonjs/Misc/observable";
  41710. import { Nullable } from "babylonjs/types";
  41711. import { Vector3, Color3 } from "babylonjs/Maths/math";
  41712. import { TransformNode } from "babylonjs/Meshes/transformNode";
  41713. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  41714. import { PointerDragBehavior } from "babylonjs/Behaviors/Meshes/pointerDragBehavior";
  41715. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  41716. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  41717. import { StandardMaterial } from "babylonjs/Materials/standardMaterial";
  41718. import { Scene } from "babylonjs/scene";
  41719. /**
  41720. * Single axis drag gizmo
  41721. */
  41722. export class AxisDragGizmo extends Gizmo {
  41723. /**
  41724. * Drag behavior responsible for the gizmos dragging interactions
  41725. */
  41726. dragBehavior: PointerDragBehavior;
  41727. private _pointerObserver;
  41728. /**
  41729. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  41730. */
  41731. snapDistance: number;
  41732. /**
  41733. * Event that fires each time the gizmo snaps to a new location.
  41734. * * snapDistance is the the change in distance
  41735. */
  41736. onSnapObservable: Observable<{
  41737. snapDistance: number;
  41738. }>;
  41739. /** @hidden */
  41740. static _CreateArrow(scene: Scene, material: StandardMaterial): TransformNode;
  41741. /** @hidden */
  41742. static _CreateArrowInstance(scene: Scene, arrow: TransformNode): TransformNode;
  41743. /**
  41744. * Creates an AxisDragGizmo
  41745. * @param gizmoLayer The utility layer the gizmo will be added to
  41746. * @param dragAxis The axis which the gizmo will be able to drag on
  41747. * @param color The color of the gizmo
  41748. */
  41749. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer);
  41750. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  41751. /**
  41752. * Disposes of the gizmo
  41753. */
  41754. dispose(): void;
  41755. }
  41756. }
  41757. declare module "babylonjs/Debug/axesViewer" {
  41758. import { Vector3 } from "babylonjs/Maths/math";
  41759. import { Nullable } from "babylonjs/types";
  41760. import { Scene } from "babylonjs/scene";
  41761. import { TransformNode } from "babylonjs/Meshes/transformNode";
  41762. /**
  41763. * The Axes viewer will show 3 axes in a specific point in space
  41764. */
  41765. export class AxesViewer {
  41766. private _xAxis;
  41767. private _yAxis;
  41768. private _zAxis;
  41769. private _scaleLinesFactor;
  41770. private _instanced;
  41771. /**
  41772. * Gets the hosting scene
  41773. */
  41774. scene: Scene;
  41775. /**
  41776. * Gets or sets a number used to scale line length
  41777. */
  41778. scaleLines: number;
  41779. /** Gets the node hierarchy used to render x-axis */
  41780. readonly xAxis: TransformNode;
  41781. /** Gets the node hierarchy used to render y-axis */
  41782. readonly yAxis: TransformNode;
  41783. /** Gets the node hierarchy used to render z-axis */
  41784. readonly zAxis: TransformNode;
  41785. /**
  41786. * Creates a new AxesViewer
  41787. * @param scene defines the hosting scene
  41788. * @param scaleLines defines a number used to scale line length (1 by default)
  41789. * @param renderingGroupId defines a number used to set the renderingGroupId of the meshes (2 by default)
  41790. * @param xAxis defines the node hierarchy used to render the x-axis
  41791. * @param yAxis defines the node hierarchy used to render the y-axis
  41792. * @param zAxis defines the node hierarchy used to render the z-axis
  41793. */
  41794. constructor(scene: Scene, scaleLines?: number, renderingGroupId?: Nullable<number>, xAxis?: TransformNode, yAxis?: TransformNode, zAxis?: TransformNode);
  41795. /**
  41796. * Force the viewer to update
  41797. * @param position defines the position of the viewer
  41798. * @param xaxis defines the x axis of the viewer
  41799. * @param yaxis defines the y axis of the viewer
  41800. * @param zaxis defines the z axis of the viewer
  41801. */
  41802. update(position: Vector3, xaxis: Vector3, yaxis: Vector3, zaxis: Vector3): void;
  41803. /**
  41804. * Creates an instance of this axes viewer.
  41805. * @returns a new axes viewer with instanced meshes
  41806. */
  41807. createInstance(): AxesViewer;
  41808. /** Releases resources */
  41809. dispose(): void;
  41810. private static _SetRenderingGroupId;
  41811. }
  41812. }
  41813. declare module "babylonjs/Debug/boneAxesViewer" {
  41814. import { Nullable } from "babylonjs/types";
  41815. import { AxesViewer } from "babylonjs/Debug/axesViewer";
  41816. import { Vector3 } from "babylonjs/Maths/math";
  41817. import { Mesh } from "babylonjs/Meshes/mesh";
  41818. import { Bone } from "babylonjs/Bones/bone";
  41819. import { Scene } from "babylonjs/scene";
  41820. /**
  41821. * The BoneAxesViewer will attach 3 axes to a specific bone of a specific mesh
  41822. * @see demo here: https://www.babylonjs-playground.com/#0DE8F4#8
  41823. */
  41824. export class BoneAxesViewer extends AxesViewer {
  41825. /**
  41826. * Gets or sets the target mesh where to display the axes viewer
  41827. */
  41828. mesh: Nullable<Mesh>;
  41829. /**
  41830. * Gets or sets the target bone where to display the axes viewer
  41831. */
  41832. bone: Nullable<Bone>;
  41833. /** Gets current position */
  41834. pos: Vector3;
  41835. /** Gets direction of X axis */
  41836. xaxis: Vector3;
  41837. /** Gets direction of Y axis */
  41838. yaxis: Vector3;
  41839. /** Gets direction of Z axis */
  41840. zaxis: Vector3;
  41841. /**
  41842. * Creates a new BoneAxesViewer
  41843. * @param scene defines the hosting scene
  41844. * @param bone defines the target bone
  41845. * @param mesh defines the target mesh
  41846. * @param scaleLines defines a scaling factor for line length (1 by default)
  41847. */
  41848. constructor(scene: Scene, bone: Bone, mesh: Mesh, scaleLines?: number);
  41849. /**
  41850. * Force the viewer to update
  41851. */
  41852. update(): void;
  41853. /** Releases resources */
  41854. dispose(): void;
  41855. }
  41856. }
  41857. declare module "babylonjs/Debug/debugLayer" {
  41858. import { Observable } from "babylonjs/Misc/observable";
  41859. import { Scene } from "babylonjs/scene";
  41860. /**
  41861. * Interface used to define scene explorer extensibility option
  41862. */
  41863. export interface IExplorerExtensibilityOption {
  41864. /**
  41865. * Define the option label
  41866. */
  41867. label: string;
  41868. /**
  41869. * Defines the action to execute on click
  41870. */
  41871. action: (entity: any) => void;
  41872. }
  41873. /**
  41874. * Defines a group of actions associated with a predicate to use when extending the Inspector scene explorer
  41875. */
  41876. export interface IExplorerExtensibilityGroup {
  41877. /**
  41878. * Defines a predicate to test if a given type mut be extended
  41879. */
  41880. predicate: (entity: any) => boolean;
  41881. /**
  41882. * Gets the list of options added to a type
  41883. */
  41884. entries: IExplorerExtensibilityOption[];
  41885. }
  41886. /**
  41887. * Interface used to define the options to use to create the Inspector
  41888. */
  41889. export interface IInspectorOptions {
  41890. /**
  41891. * Display in overlay mode (default: false)
  41892. */
  41893. overlay?: boolean;
  41894. /**
  41895. * HTML element to use as root (the parent of the rendering canvas will be used as default value)
  41896. */
  41897. globalRoot?: HTMLElement;
  41898. /**
  41899. * Display the Scene explorer
  41900. */
  41901. showExplorer?: boolean;
  41902. /**
  41903. * Display the property inspector
  41904. */
  41905. showInspector?: boolean;
  41906. /**
  41907. * Display in embed mode (both panes on the right)
  41908. */
  41909. embedMode?: boolean;
  41910. /**
  41911. * let the Inspector handles resize of the canvas when panes are resized (default to true)
  41912. */
  41913. handleResize?: boolean;
  41914. /**
  41915. * Allow the panes to popup (default: true)
  41916. */
  41917. enablePopup?: boolean;
  41918. /**
  41919. * Allow the panes to be closed by users (default: true)
  41920. */
  41921. enableClose?: boolean;
  41922. /**
  41923. * Optional list of extensibility entries
  41924. */
  41925. explorerExtensibility?: IExplorerExtensibilityGroup[];
  41926. /**
  41927. * Optional URL to get the inspector script from (by default it uses the babylonjs CDN).
  41928. */
  41929. inspectorURL?: string;
  41930. }
  41931. module "babylonjs/scene" {
  41932. interface Scene {
  41933. /**
  41934. * @hidden
  41935. * Backing field
  41936. */
  41937. _debugLayer: DebugLayer;
  41938. /**
  41939. * Gets the debug layer (aka Inspector) associated with the scene
  41940. * @see http://doc.babylonjs.com/features/playground_debuglayer
  41941. */
  41942. debugLayer: DebugLayer;
  41943. }
  41944. }
  41945. /**
  41946. * The debug layer (aka Inspector) is the go to tool in order to better understand
  41947. * what is happening in your scene
  41948. * @see http://doc.babylonjs.com/features/playground_debuglayer
  41949. */
  41950. export class DebugLayer {
  41951. /**
  41952. * Define the url to get the inspector script from.
  41953. * By default it uses the babylonjs CDN.
  41954. * @ignoreNaming
  41955. */
  41956. static InspectorURL: string;
  41957. private _scene;
  41958. private BJSINSPECTOR;
  41959. /**
  41960. * Observable triggered when a property is changed through the inspector.
  41961. */
  41962. onPropertyChangedObservable: Observable<{
  41963. object: any;
  41964. property: string;
  41965. value: any;
  41966. initialValue: any;
  41967. }>;
  41968. /**
  41969. * Instantiates a new debug layer.
  41970. * The debug layer (aka Inspector) is the go to tool in order to better understand
  41971. * what is happening in your scene
  41972. * @see http://doc.babylonjs.com/features/playground_debuglayer
  41973. * @param scene Defines the scene to inspect
  41974. */
  41975. constructor(scene: Scene);
  41976. /** Creates the inspector window. */
  41977. private _createInspector;
  41978. /**
  41979. * Select a specific entity in the scene explorer and highlight a specific block in that entity property grid
  41980. * @param entity defines the entity to select
  41981. * @param lineContainerTitle defines the specific block to highlight
  41982. */
  41983. select(entity: any, lineContainerTitle?: string): void;
  41984. /** Get the inspector from bundle or global */
  41985. private _getGlobalInspector;
  41986. /**
  41987. * Get if the inspector is visible or not.
  41988. * @returns true if visible otherwise, false
  41989. */
  41990. isVisible(): boolean;
  41991. /**
  41992. * Hide the inspector and close its window.
  41993. */
  41994. hide(): void;
  41995. /**
  41996. * Launch the debugLayer.
  41997. * @param config Define the configuration of the inspector
  41998. * @return a promise fulfilled when the debug layer is visible
  41999. */
  42000. show(config?: IInspectorOptions): Promise<DebugLayer>;
  42001. }
  42002. }
  42003. declare module "babylonjs/Meshes/Builders/boxBuilder" {
  42004. import { Nullable } from "babylonjs/types";
  42005. import { Scene } from "babylonjs/scene";
  42006. import { Vector4, Color4 } from "babylonjs/Maths/math";
  42007. import { Mesh } from "babylonjs/Meshes/mesh";
  42008. /**
  42009. * Class containing static functions to help procedurally build meshes
  42010. */
  42011. export class BoxBuilder {
  42012. /**
  42013. * Creates a box mesh
  42014. * * The parameter `size` sets the size (float) of each box side (default 1)
  42015. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  42016. * * 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)
  42017. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  42018. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  42019. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  42020. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  42021. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  42022. * @param name defines the name of the mesh
  42023. * @param options defines the options used to create the mesh
  42024. * @param scene defines the hosting scene
  42025. * @returns the box mesh
  42026. */
  42027. static CreateBox(name: string, options: {
  42028. size?: number;
  42029. width?: number;
  42030. height?: number;
  42031. depth?: number;
  42032. faceUV?: Vector4[];
  42033. faceColors?: Color4[];
  42034. sideOrientation?: number;
  42035. frontUVs?: Vector4;
  42036. backUVs?: Vector4;
  42037. updatable?: boolean;
  42038. }, scene?: Nullable<Scene>): Mesh;
  42039. }
  42040. }
  42041. declare module "babylonjs/Meshes/Builders/sphereBuilder" {
  42042. import { Vector4 } from "babylonjs/Maths/math";
  42043. import { Mesh } from "babylonjs/Meshes/mesh";
  42044. /**
  42045. * Class containing static functions to help procedurally build meshes
  42046. */
  42047. export class SphereBuilder {
  42048. /**
  42049. * Creates a sphere mesh
  42050. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  42051. * * 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`)
  42052. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  42053. * * 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
  42054. * * 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)
  42055. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  42056. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  42057. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  42058. * @param name defines the name of the mesh
  42059. * @param options defines the options used to create the mesh
  42060. * @param scene defines the hosting scene
  42061. * @returns the sphere mesh
  42062. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  42063. */
  42064. static CreateSphere(name: string, options: {
  42065. segments?: number;
  42066. diameter?: number;
  42067. diameterX?: number;
  42068. diameterY?: number;
  42069. diameterZ?: number;
  42070. arc?: number;
  42071. slice?: number;
  42072. sideOrientation?: number;
  42073. frontUVs?: Vector4;
  42074. backUVs?: Vector4;
  42075. updatable?: boolean;
  42076. }, scene: any): Mesh;
  42077. }
  42078. }
  42079. declare module "babylonjs/Debug/physicsViewer" {
  42080. import { Nullable } from "babylonjs/types";
  42081. import { Scene } from "babylonjs/scene";
  42082. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  42083. import { IPhysicsEnginePlugin } from "babylonjs/Physics/IPhysicsEngine";
  42084. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  42085. /**
  42086. * Used to show the physics impostor around the specific mesh
  42087. */
  42088. export class PhysicsViewer {
  42089. /** @hidden */
  42090. protected _impostors: Array<Nullable<PhysicsImpostor>>;
  42091. /** @hidden */
  42092. protected _meshes: Array<Nullable<AbstractMesh>>;
  42093. /** @hidden */
  42094. protected _scene: Nullable<Scene>;
  42095. /** @hidden */
  42096. protected _numMeshes: number;
  42097. /** @hidden */
  42098. protected _physicsEnginePlugin: Nullable<IPhysicsEnginePlugin>;
  42099. private _renderFunction;
  42100. private _utilityLayer;
  42101. private _debugBoxMesh;
  42102. private _debugSphereMesh;
  42103. private _debugMaterial;
  42104. /**
  42105. * Creates a new PhysicsViewer
  42106. * @param scene defines the hosting scene
  42107. */
  42108. constructor(scene: Scene);
  42109. /** @hidden */
  42110. protected _updateDebugMeshes(): void;
  42111. /**
  42112. * Renders a specified physic impostor
  42113. * @param impostor defines the impostor to render
  42114. * @returns the new debug mesh used to render the impostor
  42115. */
  42116. showImpostor(impostor: PhysicsImpostor): Nullable<AbstractMesh>;
  42117. /**
  42118. * Hides a specified physic impostor
  42119. * @param impostor defines the impostor to hide
  42120. */
  42121. hideImpostor(impostor: Nullable<PhysicsImpostor>): void;
  42122. private _getDebugMaterial;
  42123. private _getDebugBoxMesh;
  42124. private _getDebugSphereMesh;
  42125. private _getDebugMesh;
  42126. /** Releases all resources */
  42127. dispose(): void;
  42128. }
  42129. }
  42130. declare module "babylonjs/Debug/rayHelper" {
  42131. import { Nullable } from "babylonjs/types";
  42132. import { Ray } from "babylonjs/Culling/ray";
  42133. import { Vector3, Color3 } from "babylonjs/Maths/math";
  42134. import { Scene } from "babylonjs/scene";
  42135. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  42136. import "babylonjs/Meshes/Builders/linesBuilder";
  42137. /**
  42138. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  42139. * in order to better appreciate the issue one might have.
  42140. * @see http://doc.babylonjs.com/babylon101/raycasts#debugging
  42141. */
  42142. export class RayHelper {
  42143. /**
  42144. * Defines the ray we are currently tryin to visualize.
  42145. */
  42146. ray: Nullable<Ray>;
  42147. private _renderPoints;
  42148. private _renderLine;
  42149. private _renderFunction;
  42150. private _scene;
  42151. private _updateToMeshFunction;
  42152. private _attachedToMesh;
  42153. private _meshSpaceDirection;
  42154. private _meshSpaceOrigin;
  42155. /**
  42156. * Helper function to create a colored helper in a scene in one line.
  42157. * @param ray Defines the ray we are currently tryin to visualize
  42158. * @param scene Defines the scene the ray is used in
  42159. * @param color Defines the color we want to see the ray in
  42160. * @returns The newly created ray helper.
  42161. */
  42162. static CreateAndShow(ray: Ray, scene: Scene, color: Color3): RayHelper;
  42163. /**
  42164. * Instantiate a new ray helper.
  42165. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  42166. * in order to better appreciate the issue one might have.
  42167. * @see http://doc.babylonjs.com/babylon101/raycasts#debugging
  42168. * @param ray Defines the ray we are currently tryin to visualize
  42169. */
  42170. constructor(ray: Ray);
  42171. /**
  42172. * Shows the ray we are willing to debug.
  42173. * @param scene Defines the scene the ray needs to be rendered in
  42174. * @param color Defines the color the ray needs to be rendered in
  42175. */
  42176. show(scene: Scene, color?: Color3): void;
  42177. /**
  42178. * Hides the ray we are debugging.
  42179. */
  42180. hide(): void;
  42181. private _render;
  42182. /**
  42183. * Attach a ray helper to a mesh so that we can easily see its orientation for instance or information like its normals.
  42184. * @param mesh Defines the mesh we want the helper attached to
  42185. * @param meshSpaceDirection Defines the direction of the Ray in mesh space (local space of the mesh node)
  42186. * @param meshSpaceOrigin Defines the origin of the Ray in mesh space (local space of the mesh node)
  42187. * @param length Defines the length of the ray
  42188. */
  42189. attachToMesh(mesh: AbstractMesh, meshSpaceDirection?: Vector3, meshSpaceOrigin?: Vector3, length?: number): void;
  42190. /**
  42191. * Detach the ray helper from the mesh it has previously been attached to.
  42192. */
  42193. detachFromMesh(): void;
  42194. private _updateToMesh;
  42195. /**
  42196. * Dispose the helper and release its associated resources.
  42197. */
  42198. dispose(): void;
  42199. }
  42200. }
  42201. declare module "babylonjs/Debug/skeletonViewer" {
  42202. import { Color3 } from "babylonjs/Maths/math";
  42203. import { Scene } from "babylonjs/scene";
  42204. import { Nullable } from "babylonjs/types";
  42205. import { Skeleton } from "babylonjs/Bones/skeleton";
  42206. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  42207. import { LinesMesh } from "babylonjs/Meshes/linesMesh";
  42208. /**
  42209. * Class used to render a debug view of a given skeleton
  42210. * @see http://www.babylonjs-playground.com/#1BZJVJ#8
  42211. */
  42212. export class SkeletonViewer {
  42213. /** defines the skeleton to render */
  42214. skeleton: Skeleton;
  42215. /** defines the mesh attached to the skeleton */
  42216. mesh: AbstractMesh;
  42217. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  42218. autoUpdateBonesMatrices: boolean;
  42219. /** defines the rendering group id to use with the viewer */
  42220. renderingGroupId: number;
  42221. /** Gets or sets the color used to render the skeleton */
  42222. color: Color3;
  42223. private _scene;
  42224. private _debugLines;
  42225. private _debugMesh;
  42226. private _isEnabled;
  42227. private _renderFunction;
  42228. private _utilityLayer;
  42229. /**
  42230. * Returns the mesh used to render the bones
  42231. */
  42232. readonly debugMesh: Nullable<LinesMesh>;
  42233. /**
  42234. * Creates a new SkeletonViewer
  42235. * @param skeleton defines the skeleton to render
  42236. * @param mesh defines the mesh attached to the skeleton
  42237. * @param scene defines the hosting scene
  42238. * @param autoUpdateBonesMatrices defines a boolean indicating if bones matrices must be forced to update before rendering (true by default)
  42239. * @param renderingGroupId defines the rendering group id to use with the viewer
  42240. */
  42241. constructor(
  42242. /** defines the skeleton to render */
  42243. skeleton: Skeleton,
  42244. /** defines the mesh attached to the skeleton */
  42245. mesh: AbstractMesh, scene: Scene,
  42246. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  42247. autoUpdateBonesMatrices?: boolean,
  42248. /** defines the rendering group id to use with the viewer */
  42249. renderingGroupId?: number);
  42250. /** Gets or sets a boolean indicating if the viewer is enabled */
  42251. isEnabled: boolean;
  42252. private _getBonePosition;
  42253. private _getLinesForBonesWithLength;
  42254. private _getLinesForBonesNoLength;
  42255. /** Update the viewer to sync with current skeleton state */
  42256. update(): void;
  42257. /** Release associated resources */
  42258. dispose(): void;
  42259. }
  42260. }
  42261. declare module "babylonjs/Debug/index" {
  42262. export * from "babylonjs/Debug/axesViewer";
  42263. export * from "babylonjs/Debug/boneAxesViewer";
  42264. export * from "babylonjs/Debug/debugLayer";
  42265. export * from "babylonjs/Debug/physicsViewer";
  42266. export * from "babylonjs/Debug/rayHelper";
  42267. export * from "babylonjs/Debug/skeletonViewer";
  42268. }
  42269. declare module "babylonjs/Engines/nullEngine" {
  42270. import { Nullable, FloatArray, IndicesArray } from "babylonjs/types";
  42271. import { Scene } from "babylonjs/scene";
  42272. import { Matrix, Color3, Color4, Viewport } from "babylonjs/Maths/math";
  42273. import { Engine } from "babylonjs/Engines/engine";
  42274. import { RenderTargetCreationOptions } from "babylonjs/Materials/Textures/renderTargetCreationOptions";
  42275. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  42276. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  42277. import { Effect } from "babylonjs/Materials/effect";
  42278. /**
  42279. * Options to create the null engine
  42280. */
  42281. export class NullEngineOptions {
  42282. /**
  42283. * Render width (Default: 512)
  42284. */
  42285. renderWidth: number;
  42286. /**
  42287. * Render height (Default: 256)
  42288. */
  42289. renderHeight: number;
  42290. /**
  42291. * Texture size (Default: 512)
  42292. */
  42293. textureSize: number;
  42294. /**
  42295. * If delta time between frames should be constant
  42296. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  42297. */
  42298. deterministicLockstep: boolean;
  42299. /**
  42300. * Maximum about of steps between frames (Default: 4)
  42301. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  42302. */
  42303. lockstepMaxSteps: number;
  42304. }
  42305. /**
  42306. * The null engine class provides support for headless version of babylon.js.
  42307. * This can be used in server side scenario or for testing purposes
  42308. */
  42309. export class NullEngine extends Engine {
  42310. private _options;
  42311. /**
  42312. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  42313. */
  42314. isDeterministicLockStep(): boolean;
  42315. /** @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep */
  42316. getLockstepMaxSteps(): number;
  42317. /**
  42318. * Sets hardware scaling, used to save performance if needed
  42319. * @see https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  42320. */
  42321. getHardwareScalingLevel(): number;
  42322. constructor(options?: NullEngineOptions);
  42323. createVertexBuffer(vertices: FloatArray): WebGLBuffer;
  42324. createIndexBuffer(indices: IndicesArray): WebGLBuffer;
  42325. clear(color: Color4, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  42326. getRenderWidth(useScreen?: boolean): number;
  42327. getRenderHeight(useScreen?: boolean): number;
  42328. setViewport(viewport: Viewport, requiredWidth?: number, requiredHeight?: number): void;
  42329. createShaderProgram(vertexCode: string, fragmentCode: string, defines: string, context?: WebGLRenderingContext): WebGLProgram;
  42330. getUniforms(shaderProgram: WebGLProgram, uniformsNames: string[]): WebGLUniformLocation[];
  42331. getAttributes(shaderProgram: WebGLProgram, attributesNames: string[]): number[];
  42332. bindSamplers(effect: Effect): void;
  42333. enableEffect(effect: Effect): void;
  42334. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  42335. setIntArray(uniform: WebGLUniformLocation, array: Int32Array): void;
  42336. setIntArray2(uniform: WebGLUniformLocation, array: Int32Array): void;
  42337. setIntArray3(uniform: WebGLUniformLocation, array: Int32Array): void;
  42338. setIntArray4(uniform: WebGLUniformLocation, array: Int32Array): void;
  42339. setFloatArray(uniform: WebGLUniformLocation, array: Float32Array): void;
  42340. setFloatArray2(uniform: WebGLUniformLocation, array: Float32Array): void;
  42341. setFloatArray3(uniform: WebGLUniformLocation, array: Float32Array): void;
  42342. setFloatArray4(uniform: WebGLUniformLocation, array: Float32Array): void;
  42343. setArray(uniform: WebGLUniformLocation, array: number[]): void;
  42344. setArray2(uniform: WebGLUniformLocation, array: number[]): void;
  42345. setArray3(uniform: WebGLUniformLocation, array: number[]): void;
  42346. setArray4(uniform: WebGLUniformLocation, array: number[]): void;
  42347. setMatrices(uniform: WebGLUniformLocation, matrices: Float32Array): void;
  42348. setMatrix(uniform: WebGLUniformLocation, matrix: Matrix): void;
  42349. setMatrix3x3(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  42350. setMatrix2x2(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  42351. setFloat(uniform: WebGLUniformLocation, value: number): void;
  42352. setFloat2(uniform: WebGLUniformLocation, x: number, y: number): void;
  42353. setFloat3(uniform: WebGLUniformLocation, x: number, y: number, z: number): void;
  42354. setBool(uniform: WebGLUniformLocation, bool: number): void;
  42355. setFloat4(uniform: WebGLUniformLocation, x: number, y: number, z: number, w: number): void;
  42356. setColor3(uniform: WebGLUniformLocation, color3: Color3): void;
  42357. setColor4(uniform: WebGLUniformLocation, color3: Color3, alpha: number): void;
  42358. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  42359. bindBuffers(vertexBuffers: {
  42360. [key: string]: VertexBuffer;
  42361. }, indexBuffer: WebGLBuffer, effect: Effect): void;
  42362. wipeCaches(bruteForce?: boolean): void;
  42363. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  42364. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  42365. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  42366. /** @hidden */
  42367. _createTexture(): WebGLTexture;
  42368. /** @hidden */
  42369. _releaseTexture(texture: InternalTexture): void;
  42370. 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;
  42371. createRenderTargetTexture(size: any, options: boolean | RenderTargetCreationOptions): InternalTexture;
  42372. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  42373. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean): void;
  42374. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  42375. createDynamicVertexBuffer(vertices: FloatArray): WebGLBuffer;
  42376. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement, invertY: boolean, premulAlpha?: boolean, format?: number): void;
  42377. areAllEffectsReady(): boolean;
  42378. /**
  42379. * @hidden
  42380. * Get the current error code of the webGL context
  42381. * @returns the error code
  42382. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  42383. */
  42384. getError(): number;
  42385. /** @hidden */
  42386. _getUnpackAlignement(): number;
  42387. /** @hidden */
  42388. _unpackFlipY(value: boolean): void;
  42389. updateDynamicIndexBuffer(indexBuffer: WebGLBuffer, indices: IndicesArray, offset?: number): void;
  42390. /**
  42391. * Updates a dynamic vertex buffer.
  42392. * @param vertexBuffer the vertex buffer to update
  42393. * @param data the data used to update the vertex buffer
  42394. * @param byteOffset the byte offset of the data (optional)
  42395. * @param byteLength the byte length of the data (optional)
  42396. */
  42397. updateDynamicVertexBuffer(vertexBuffer: WebGLBuffer, vertices: FloatArray, byteOffset?: number, byteLength?: number): void;
  42398. _bindTextureDirectly(target: number, texture: InternalTexture): boolean;
  42399. /** @hidden */
  42400. _bindTexture(channel: number, texture: InternalTexture): void;
  42401. /** @hidden */
  42402. _releaseBuffer(buffer: WebGLBuffer): boolean;
  42403. releaseEffects(): void;
  42404. displayLoadingUI(): void;
  42405. hideLoadingUI(): void;
  42406. /** @hidden */
  42407. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  42408. /** @hidden */
  42409. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  42410. /** @hidden */
  42411. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  42412. /** @hidden */
  42413. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  42414. }
  42415. }
  42416. declare module "babylonjs/Engines/Extensions/engine.occlusionQuery" {
  42417. import { Nullable, int } from "babylonjs/types";
  42418. import { _TimeToken } from "babylonjs/Instrumentation/timeToken";
  42419. /** @hidden */
  42420. export class _OcclusionDataStorage {
  42421. /** @hidden */
  42422. occlusionInternalRetryCounter: number;
  42423. /** @hidden */
  42424. isOcclusionQueryInProgress: boolean;
  42425. /** @hidden */
  42426. isOccluded: boolean;
  42427. /** @hidden */
  42428. occlusionRetryCount: number;
  42429. /** @hidden */
  42430. occlusionType: number;
  42431. /** @hidden */
  42432. occlusionQueryAlgorithmType: number;
  42433. }
  42434. module "babylonjs/Engines/engine" {
  42435. interface Engine {
  42436. /**
  42437. * Create a new webGL query (you must be sure that queries are supported by checking getCaps() function)
  42438. * @return the new query
  42439. */
  42440. createQuery(): WebGLQuery;
  42441. /**
  42442. * Delete and release a webGL query
  42443. * @param query defines the query to delete
  42444. * @return the current engine
  42445. */
  42446. deleteQuery(query: WebGLQuery): Engine;
  42447. /**
  42448. * Check if a given query has resolved and got its value
  42449. * @param query defines the query to check
  42450. * @returns true if the query got its value
  42451. */
  42452. isQueryResultAvailable(query: WebGLQuery): boolean;
  42453. /**
  42454. * Gets the value of a given query
  42455. * @param query defines the query to check
  42456. * @returns the value of the query
  42457. */
  42458. getQueryResult(query: WebGLQuery): number;
  42459. /**
  42460. * Initiates an occlusion query
  42461. * @param algorithmType defines the algorithm to use
  42462. * @param query defines the query to use
  42463. * @returns the current engine
  42464. * @see http://doc.babylonjs.com/features/occlusionquery
  42465. */
  42466. beginOcclusionQuery(algorithmType: number, query: WebGLQuery): Engine;
  42467. /**
  42468. * Ends an occlusion query
  42469. * @see http://doc.babylonjs.com/features/occlusionquery
  42470. * @param algorithmType defines the algorithm to use
  42471. * @returns the current engine
  42472. */
  42473. endOcclusionQuery(algorithmType: number): Engine;
  42474. /**
  42475. * Starts a time query (used to measure time spent by the GPU on a specific frame)
  42476. * Please note that only one query can be issued at a time
  42477. * @returns a time token used to track the time span
  42478. */
  42479. startTimeQuery(): Nullable<_TimeToken>;
  42480. /**
  42481. * Ends a time query
  42482. * @param token defines the token used to measure the time span
  42483. * @returns the time spent (in ns)
  42484. */
  42485. endTimeQuery(token: _TimeToken): int;
  42486. /** @hidden */
  42487. _currentNonTimestampToken: Nullable<_TimeToken>;
  42488. /** @hidden */
  42489. _createTimeQuery(): WebGLQuery;
  42490. /** @hidden */
  42491. _deleteTimeQuery(query: WebGLQuery): void;
  42492. /** @hidden */
  42493. _getGlAlgorithmType(algorithmType: number): number;
  42494. /** @hidden */
  42495. _getTimeQueryResult(query: WebGLQuery): any;
  42496. /** @hidden */
  42497. _getTimeQueryAvailability(query: WebGLQuery): any;
  42498. }
  42499. }
  42500. module "babylonjs/Meshes/abstractMesh" {
  42501. interface AbstractMesh {
  42502. /**
  42503. * Backing filed
  42504. * @hidden
  42505. */
  42506. __occlusionDataStorage: _OcclusionDataStorage;
  42507. /**
  42508. * Access property
  42509. * @hidden
  42510. */
  42511. _occlusionDataStorage: _OcclusionDataStorage;
  42512. /**
  42513. * 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.
  42514. * The default value is -1 which means don't break the query and wait till the result
  42515. * @see http://doc.babylonjs.com/features/occlusionquery
  42516. */
  42517. occlusionRetryCount: number;
  42518. /**
  42519. * 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:
  42520. * * OCCLUSION_TYPE_NONE (Default Value): this option means no occlusion query whith the Mesh.
  42521. * * OCCLUSION_TYPE_OPTIMISTIC: this option is means use occlusion query and if occlusionRetryCount is reached and the query is broken show the mesh.
  42522. * * 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.
  42523. * @see http://doc.babylonjs.com/features/occlusionquery
  42524. */
  42525. occlusionType: number;
  42526. /**
  42527. * This property determines the type of occlusion query algorithm to run in WebGl, you can use:
  42528. * * AbstractMesh.OCCLUSION_ALGORITHM_TYPE_ACCURATE which is mapped to GL_ANY_SAMPLES_PASSED.
  42529. * * 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.
  42530. * @see http://doc.babylonjs.com/features/occlusionquery
  42531. */
  42532. occlusionQueryAlgorithmType: number;
  42533. /**
  42534. * 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
  42535. * @see http://doc.babylonjs.com/features/occlusionquery
  42536. */
  42537. isOccluded: boolean;
  42538. /**
  42539. * Flag to check the progress status of the query
  42540. * @see http://doc.babylonjs.com/features/occlusionquery
  42541. */
  42542. isOcclusionQueryInProgress: boolean;
  42543. }
  42544. }
  42545. }
  42546. declare module "babylonjs/Engines/Extensions/engine.transformFeedback" {
  42547. import { Nullable } from "babylonjs/types";
  42548. /** @hidden */
  42549. export var _forceTransformFeedbackToBundle: boolean;
  42550. module "babylonjs/Engines/engine" {
  42551. interface Engine {
  42552. /**
  42553. * Creates a webGL transform feedback object
  42554. * Please makes sure to check webGLVersion property to check if you are running webGL 2+
  42555. * @returns the webGL transform feedback object
  42556. */
  42557. createTransformFeedback(): WebGLTransformFeedback;
  42558. /**
  42559. * Delete a webGL transform feedback object
  42560. * @param value defines the webGL transform feedback object to delete
  42561. */
  42562. deleteTransformFeedback(value: WebGLTransformFeedback): void;
  42563. /**
  42564. * Bind a webGL transform feedback object to the webgl context
  42565. * @param value defines the webGL transform feedback object to bind
  42566. */
  42567. bindTransformFeedback(value: Nullable<WebGLTransformFeedback>): void;
  42568. /**
  42569. * Begins a transform feedback operation
  42570. * @param usePoints defines if points or triangles must be used
  42571. */
  42572. beginTransformFeedback(usePoints: boolean): void;
  42573. /**
  42574. * Ends a transform feedback operation
  42575. */
  42576. endTransformFeedback(): void;
  42577. /**
  42578. * Specify the varyings to use with transform feedback
  42579. * @param program defines the associated webGL program
  42580. * @param value defines the list of strings representing the varying names
  42581. */
  42582. setTranformFeedbackVaryings(program: WebGLProgram, value: string[]): void;
  42583. /**
  42584. * Bind a webGL buffer for a transform feedback operation
  42585. * @param value defines the webGL buffer to bind
  42586. */
  42587. bindTransformFeedbackBuffer(value: Nullable<WebGLBuffer>): void;
  42588. }
  42589. }
  42590. }
  42591. declare module "babylonjs/Engines/Extensions/index" {
  42592. export * from "babylonjs/Engines/Extensions/engine.occlusionQuery";
  42593. export * from "babylonjs/Engines/Extensions/engine.transformFeedback";
  42594. }
  42595. declare module "babylonjs/Engines/index" {
  42596. export * from "babylonjs/Engines/constants";
  42597. export * from "babylonjs/Engines/engine";
  42598. export * from "babylonjs/Engines/engineStore";
  42599. export * from "babylonjs/Engines/nullEngine";
  42600. export * from "babylonjs/Engines/Extensions/index";
  42601. }
  42602. declare module "babylonjs/Events/clipboardEvents" {
  42603. /**
  42604. * Gather the list of clipboard event types as constants.
  42605. */
  42606. export class ClipboardEventTypes {
  42607. /**
  42608. * The clipboard event is fired when a copy command is active (pressed).
  42609. */
  42610. static readonly COPY: number;
  42611. /**
  42612. * The clipboard event is fired when a cut command is active (pressed).
  42613. */
  42614. static readonly CUT: number;
  42615. /**
  42616. * The clipboard event is fired when a paste command is active (pressed).
  42617. */
  42618. static readonly PASTE: number;
  42619. }
  42620. /**
  42621. * This class is used to store clipboard related info for the onClipboardObservable event.
  42622. */
  42623. export class ClipboardInfo {
  42624. /**
  42625. * Defines the type of event (BABYLON.ClipboardEventTypes)
  42626. */
  42627. type: number;
  42628. /**
  42629. * Defines the related dom event
  42630. */
  42631. event: ClipboardEvent;
  42632. /**
  42633. *Creates an instance of ClipboardInfo.
  42634. * @param type Defines the type of event (BABYLON.ClipboardEventTypes)
  42635. * @param event Defines the related dom event
  42636. */
  42637. constructor(
  42638. /**
  42639. * Defines the type of event (BABYLON.ClipboardEventTypes)
  42640. */
  42641. type: number,
  42642. /**
  42643. * Defines the related dom event
  42644. */
  42645. event: ClipboardEvent);
  42646. /**
  42647. * Get the clipboard event's type from the keycode.
  42648. * @param keyCode Defines the keyCode for the current keyboard event.
  42649. * @return {number}
  42650. */
  42651. static GetTypeFromCharacter(keyCode: number): number;
  42652. }
  42653. }
  42654. declare module "babylonjs/Events/index" {
  42655. export * from "babylonjs/Events/keyboardEvents";
  42656. export * from "babylonjs/Events/pointerEvents";
  42657. export * from "babylonjs/Events/clipboardEvents";
  42658. }
  42659. declare module "babylonjs/Loading/sceneLoader" {
  42660. import { Observable } from "babylonjs/Misc/observable";
  42661. import { Nullable } from "babylonjs/types";
  42662. import { Scene } from "babylonjs/scene";
  42663. import { Engine } from "babylonjs/Engines/engine";
  42664. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  42665. import { AnimationGroup } from "babylonjs/Animations/animationGroup";
  42666. import { AssetContainer } from "babylonjs/assetContainer";
  42667. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  42668. import { Skeleton } from "babylonjs/Bones/skeleton";
  42669. /**
  42670. * Class used to represent data loading progression
  42671. */
  42672. export class SceneLoaderProgressEvent {
  42673. /** defines if data length to load can be evaluated */
  42674. readonly lengthComputable: boolean;
  42675. /** defines the loaded data length */
  42676. readonly loaded: number;
  42677. /** defines the data length to load */
  42678. readonly total: number;
  42679. /**
  42680. * Create a new progress event
  42681. * @param lengthComputable defines if data length to load can be evaluated
  42682. * @param loaded defines the loaded data length
  42683. * @param total defines the data length to load
  42684. */
  42685. constructor(
  42686. /** defines if data length to load can be evaluated */
  42687. lengthComputable: boolean,
  42688. /** defines the loaded data length */
  42689. loaded: number,
  42690. /** defines the data length to load */
  42691. total: number);
  42692. /**
  42693. * Creates a new SceneLoaderProgressEvent from a ProgressEvent
  42694. * @param event defines the source event
  42695. * @returns a new SceneLoaderProgressEvent
  42696. */
  42697. static FromProgressEvent(event: ProgressEvent): SceneLoaderProgressEvent;
  42698. }
  42699. /**
  42700. * Interface used by SceneLoader plugins to define supported file extensions
  42701. */
  42702. export interface ISceneLoaderPluginExtensions {
  42703. /**
  42704. * Defines the list of supported extensions
  42705. */
  42706. [extension: string]: {
  42707. isBinary: boolean;
  42708. };
  42709. }
  42710. /**
  42711. * Interface used by SceneLoader plugin factory
  42712. */
  42713. export interface ISceneLoaderPluginFactory {
  42714. /**
  42715. * Defines the name of the factory
  42716. */
  42717. name: string;
  42718. /**
  42719. * Function called to create a new plugin
  42720. * @return the new plugin
  42721. */
  42722. createPlugin(): ISceneLoaderPlugin | ISceneLoaderPluginAsync;
  42723. /**
  42724. * Boolean indicating if the plugin can direct load specific data
  42725. */
  42726. canDirectLoad?: (data: string) => boolean;
  42727. }
  42728. /**
  42729. * Interface used to define a SceneLoader plugin
  42730. */
  42731. export interface ISceneLoaderPlugin {
  42732. /**
  42733. * The friendly name of this plugin.
  42734. */
  42735. name: string;
  42736. /**
  42737. * The file extensions supported by this plugin.
  42738. */
  42739. extensions: string | ISceneLoaderPluginExtensions;
  42740. /**
  42741. * Import meshes into a scene.
  42742. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  42743. * @param scene The scene to import into
  42744. * @param data The data to import
  42745. * @param rootUrl The root url for scene and resources
  42746. * @param meshes The meshes array to import into
  42747. * @param particleSystems The particle systems array to import into
  42748. * @param skeletons The skeletons array to import into
  42749. * @param onError The callback when import fails
  42750. * @returns True if successful or false otherwise
  42751. */
  42752. importMesh(meshesNames: any, scene: Scene, data: any, rootUrl: string, meshes: AbstractMesh[], particleSystems: IParticleSystem[], skeletons: Skeleton[], onError?: (message: string, exception?: any) => void): boolean;
  42753. /**
  42754. * Load into a scene.
  42755. * @param scene The scene to load into
  42756. * @param data The data to import
  42757. * @param rootUrl The root url for scene and resources
  42758. * @param onError The callback when import fails
  42759. * @returns true if successful or false otherwise
  42760. */
  42761. load(scene: Scene, data: string, rootUrl: string, onError?: (message: string, exception?: any) => void): boolean;
  42762. /**
  42763. * The callback that returns true if the data can be directly loaded.
  42764. */
  42765. canDirectLoad?: (data: string) => boolean;
  42766. /**
  42767. * The callback that allows custom handling of the root url based on the response url.
  42768. */
  42769. rewriteRootURL?: (rootUrl: string, responseURL?: string) => string;
  42770. /**
  42771. * Load into an asset container.
  42772. * @param scene The scene to load into
  42773. * @param data The data to import
  42774. * @param rootUrl The root url for scene and resources
  42775. * @param onError The callback when import fails
  42776. * @returns The loaded asset container
  42777. */
  42778. loadAssetContainer(scene: Scene, data: string, rootUrl: string, onError?: (message: string, exception?: any) => void): AssetContainer;
  42779. }
  42780. /**
  42781. * Interface used to define an async SceneLoader plugin
  42782. */
  42783. export interface ISceneLoaderPluginAsync {
  42784. /**
  42785. * The friendly name of this plugin.
  42786. */
  42787. name: string;
  42788. /**
  42789. * The file extensions supported by this plugin.
  42790. */
  42791. extensions: string | ISceneLoaderPluginExtensions;
  42792. /**
  42793. * Import meshes into a scene.
  42794. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  42795. * @param scene The scene to import into
  42796. * @param data The data to import
  42797. * @param rootUrl The root url for scene and resources
  42798. * @param onProgress The callback when the load progresses
  42799. * @param fileName Defines the name of the file to load
  42800. * @returns The loaded meshes, particle systems, skeletons, and animation groups
  42801. */
  42802. importMeshAsync(meshesNames: any, scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<{
  42803. meshes: AbstractMesh[];
  42804. particleSystems: IParticleSystem[];
  42805. skeletons: Skeleton[];
  42806. animationGroups: AnimationGroup[];
  42807. }>;
  42808. /**
  42809. * Load into a scene.
  42810. * @param scene The scene to load into
  42811. * @param data The data to import
  42812. * @param rootUrl The root url for scene and resources
  42813. * @param onProgress The callback when the load progresses
  42814. * @param fileName Defines the name of the file to load
  42815. * @returns Nothing
  42816. */
  42817. loadAsync(scene: Scene, data: string, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<void>;
  42818. /**
  42819. * The callback that returns true if the data can be directly loaded.
  42820. */
  42821. canDirectLoad?: (data: string) => boolean;
  42822. /**
  42823. * The callback that allows custom handling of the root url based on the response url.
  42824. */
  42825. rewriteRootURL?: (rootUrl: string, responseURL?: string) => string;
  42826. /**
  42827. * Load into an asset container.
  42828. * @param scene The scene to load into
  42829. * @param data The data to import
  42830. * @param rootUrl The root url for scene and resources
  42831. * @param onProgress The callback when the load progresses
  42832. * @param fileName Defines the name of the file to load
  42833. * @returns The loaded asset container
  42834. */
  42835. loadAssetContainerAsync(scene: Scene, data: string, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<AssetContainer>;
  42836. }
  42837. /**
  42838. * Class used to load scene from various file formats using registered plugins
  42839. * @see http://doc.babylonjs.com/how_to/load_from_any_file_type
  42840. */
  42841. export class SceneLoader {
  42842. /**
  42843. * No logging while loading
  42844. */
  42845. static readonly NO_LOGGING: number;
  42846. /**
  42847. * Minimal logging while loading
  42848. */
  42849. static readonly MINIMAL_LOGGING: number;
  42850. /**
  42851. * Summary logging while loading
  42852. */
  42853. static readonly SUMMARY_LOGGING: number;
  42854. /**
  42855. * Detailled logging while loading
  42856. */
  42857. static readonly DETAILED_LOGGING: number;
  42858. /**
  42859. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  42860. */
  42861. static ForceFullSceneLoadingForIncremental: boolean;
  42862. /**
  42863. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  42864. */
  42865. static ShowLoadingScreen: boolean;
  42866. /**
  42867. * Defines the current logging level (while loading the scene)
  42868. * @ignorenaming
  42869. */
  42870. static loggingLevel: number;
  42871. /**
  42872. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  42873. */
  42874. static CleanBoneMatrixWeights: boolean;
  42875. /**
  42876. * Event raised when a plugin is used to load a scene
  42877. */
  42878. static OnPluginActivatedObservable: Observable<ISceneLoaderPlugin | ISceneLoaderPluginAsync>;
  42879. private static _registeredPlugins;
  42880. private static _getDefaultPlugin;
  42881. private static _getPluginForExtension;
  42882. private static _getPluginForDirectLoad;
  42883. private static _getPluginForFilename;
  42884. private static _getDirectLoad;
  42885. private static _loadData;
  42886. private static _getFileInfo;
  42887. /**
  42888. * Gets a plugin that can load the given extension
  42889. * @param extension defines the extension to load
  42890. * @returns a plugin or null if none works
  42891. */
  42892. static GetPluginForExtension(extension: string): ISceneLoaderPlugin | ISceneLoaderPluginAsync | ISceneLoaderPluginFactory;
  42893. /**
  42894. * Gets a boolean indicating that the given extension can be loaded
  42895. * @param extension defines the extension to load
  42896. * @returns true if the extension is supported
  42897. */
  42898. static IsPluginForExtensionAvailable(extension: string): boolean;
  42899. /**
  42900. * Adds a new plugin to the list of registered plugins
  42901. * @param plugin defines the plugin to add
  42902. */
  42903. static RegisterPlugin(plugin: ISceneLoaderPlugin | ISceneLoaderPluginAsync): void;
  42904. /**
  42905. * Import meshes into a scene
  42906. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  42907. * @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)
  42908. * @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)
  42909. * @param scene the instance of BABYLON.Scene to append to
  42910. * @param onSuccess a callback with a list of imported meshes, particleSystems, and skeletons when import succeeds
  42911. * @param onProgress a callback with a progress event for each file being loaded
  42912. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  42913. * @param pluginExtension the extension used to determine the plugin
  42914. * @returns The loaded plugin
  42915. */
  42916. 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>;
  42917. /**
  42918. * Import meshes into a scene
  42919. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  42920. * @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)
  42921. * @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)
  42922. * @param scene the instance of BABYLON.Scene to append to
  42923. * @param onProgress a callback with a progress event for each file being loaded
  42924. * @param pluginExtension the extension used to determine the plugin
  42925. * @returns The loaded list of imported meshes, particle systems, skeletons, and animation groups
  42926. */
  42927. static ImportMeshAsync(meshNames: any, rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<{
  42928. meshes: AbstractMesh[];
  42929. particleSystems: IParticleSystem[];
  42930. skeletons: Skeleton[];
  42931. animationGroups: AnimationGroup[];
  42932. }>;
  42933. /**
  42934. * Load a scene
  42935. * @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)
  42936. * @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)
  42937. * @param engine is the instance of BABYLON.Engine to use to create the scene
  42938. * @param onSuccess a callback with the scene when import succeeds
  42939. * @param onProgress a callback with a progress event for each file being loaded
  42940. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  42941. * @param pluginExtension the extension used to determine the plugin
  42942. * @returns The loaded plugin
  42943. */
  42944. 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>;
  42945. /**
  42946. * Load a scene
  42947. * @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)
  42948. * @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)
  42949. * @param engine is the instance of BABYLON.Engine to use to create the scene
  42950. * @param onProgress a callback with a progress event for each file being loaded
  42951. * @param pluginExtension the extension used to determine the plugin
  42952. * @returns The loaded scene
  42953. */
  42954. static LoadAsync(rootUrl: string, sceneFilename?: string | File, engine?: Nullable<Engine>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  42955. /**
  42956. * Append a scene
  42957. * @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)
  42958. * @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)
  42959. * @param scene is the instance of BABYLON.Scene to append to
  42960. * @param onSuccess a callback with the scene when import succeeds
  42961. * @param onProgress a callback with a progress event for each file being loaded
  42962. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  42963. * @param pluginExtension the extension used to determine the plugin
  42964. * @returns The loaded plugin
  42965. */
  42966. 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>;
  42967. /**
  42968. * Append a scene
  42969. * @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)
  42970. * @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)
  42971. * @param scene is the instance of BABYLON.Scene to append to
  42972. * @param onProgress a callback with a progress event for each file being loaded
  42973. * @param pluginExtension the extension used to determine the plugin
  42974. * @returns The given scene
  42975. */
  42976. static AppendAsync(rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  42977. /**
  42978. * Load a scene into an asset container
  42979. * @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)
  42980. * @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)
  42981. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  42982. * @param onSuccess a callback with the scene when import succeeds
  42983. * @param onProgress a callback with a progress event for each file being loaded
  42984. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  42985. * @param pluginExtension the extension used to determine the plugin
  42986. * @returns The loaded plugin
  42987. */
  42988. 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>;
  42989. /**
  42990. * Load a scene into an asset container
  42991. * @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)
  42992. * @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)
  42993. * @param scene is the instance of Scene to append to
  42994. * @param onProgress a callback with a progress event for each file being loaded
  42995. * @param pluginExtension the extension used to determine the plugin
  42996. * @returns The loaded asset container
  42997. */
  42998. static LoadAssetContainerAsync(rootUrl: string, sceneFilename?: string, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<AssetContainer>;
  42999. }
  43000. }
  43001. declare module "babylonjs/Gamepads/Controllers/daydreamController" {
  43002. import { Scene } from "babylonjs/scene";
  43003. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  43004. import { GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  43005. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  43006. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  43007. /**
  43008. * Google Daydream controller
  43009. */
  43010. export class DaydreamController extends WebVRController {
  43011. /**
  43012. * Base Url for the controller model.
  43013. */
  43014. static MODEL_BASE_URL: string;
  43015. /**
  43016. * File name for the controller model.
  43017. */
  43018. static MODEL_FILENAME: string;
  43019. /**
  43020. * Gamepad Id prefix used to identify Daydream Controller.
  43021. */
  43022. static readonly GAMEPAD_ID_PREFIX: string;
  43023. /**
  43024. * Creates a new DaydreamController from a gamepad
  43025. * @param vrGamepad the gamepad that the controller should be created from
  43026. */
  43027. constructor(vrGamepad: any);
  43028. /**
  43029. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  43030. * @param scene scene in which to add meshes
  43031. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  43032. */
  43033. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  43034. /**
  43035. * Called once for each button that changed state since the last frame
  43036. * @param buttonIdx Which button index changed
  43037. * @param state New state of the button
  43038. * @param changes Which properties on the state changed since last frame
  43039. */
  43040. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  43041. }
  43042. }
  43043. declare module "babylonjs/Gamepads/Controllers/gearVRController" {
  43044. import { Scene } from "babylonjs/scene";
  43045. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  43046. import { GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  43047. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  43048. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  43049. /**
  43050. * Gear VR Controller
  43051. */
  43052. export class GearVRController extends WebVRController {
  43053. /**
  43054. * Base Url for the controller model.
  43055. */
  43056. static MODEL_BASE_URL: string;
  43057. /**
  43058. * File name for the controller model.
  43059. */
  43060. static MODEL_FILENAME: string;
  43061. /**
  43062. * Gamepad Id prefix used to identify this controller.
  43063. */
  43064. static readonly GAMEPAD_ID_PREFIX: string;
  43065. private readonly _buttonIndexToObservableNameMap;
  43066. /**
  43067. * Creates a new GearVRController from a gamepad
  43068. * @param vrGamepad the gamepad that the controller should be created from
  43069. */
  43070. constructor(vrGamepad: any);
  43071. /**
  43072. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  43073. * @param scene scene in which to add meshes
  43074. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  43075. */
  43076. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  43077. /**
  43078. * Called once for each button that changed state since the last frame
  43079. * @param buttonIdx Which button index changed
  43080. * @param state New state of the button
  43081. * @param changes Which properties on the state changed since last frame
  43082. */
  43083. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  43084. }
  43085. }
  43086. declare module "babylonjs/Gamepads/Controllers/genericController" {
  43087. import { Scene } from "babylonjs/scene";
  43088. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  43089. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  43090. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  43091. import { GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  43092. /**
  43093. * Generic Controller
  43094. */
  43095. export class GenericController extends WebVRController {
  43096. /**
  43097. * Base Url for the controller model.
  43098. */
  43099. static readonly MODEL_BASE_URL: string;
  43100. /**
  43101. * File name for the controller model.
  43102. */
  43103. static readonly MODEL_FILENAME: string;
  43104. /**
  43105. * Creates a new GenericController from a gamepad
  43106. * @param vrGamepad the gamepad that the controller should be created from
  43107. */
  43108. constructor(vrGamepad: any);
  43109. /**
  43110. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  43111. * @param scene scene in which to add meshes
  43112. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  43113. */
  43114. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  43115. /**
  43116. * Called once for each button that changed state since the last frame
  43117. * @param buttonIdx Which button index changed
  43118. * @param state New state of the button
  43119. * @param changes Which properties on the state changed since last frame
  43120. */
  43121. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  43122. }
  43123. }
  43124. declare module "babylonjs/Gamepads/Controllers/oculusTouchController" {
  43125. import { Observable } from "babylonjs/Misc/observable";
  43126. import { Scene } from "babylonjs/scene";
  43127. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  43128. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  43129. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  43130. import { GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  43131. /**
  43132. * Oculus Touch Controller
  43133. */
  43134. export class OculusTouchController extends WebVRController {
  43135. /**
  43136. * Base Url for the controller model.
  43137. */
  43138. static MODEL_BASE_URL: string;
  43139. /**
  43140. * File name for the left controller model.
  43141. */
  43142. static MODEL_LEFT_FILENAME: string;
  43143. /**
  43144. * File name for the right controller model.
  43145. */
  43146. static MODEL_RIGHT_FILENAME: string;
  43147. /**
  43148. * Fired when the secondary trigger on this controller is modified
  43149. */
  43150. onSecondaryTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  43151. /**
  43152. * Fired when the thumb rest on this controller is modified
  43153. */
  43154. onThumbRestChangedObservable: Observable<ExtendedGamepadButton>;
  43155. /**
  43156. * Creates a new OculusTouchController from a gamepad
  43157. * @param vrGamepad the gamepad that the controller should be created from
  43158. */
  43159. constructor(vrGamepad: any);
  43160. /**
  43161. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  43162. * @param scene scene in which to add meshes
  43163. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  43164. */
  43165. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  43166. /**
  43167. * Fired when the A button on this controller is modified
  43168. */
  43169. readonly onAButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  43170. /**
  43171. * Fired when the B button on this controller is modified
  43172. */
  43173. readonly onBButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  43174. /**
  43175. * Fired when the X button on this controller is modified
  43176. */
  43177. readonly onXButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  43178. /**
  43179. * Fired when the Y button on this controller is modified
  43180. */
  43181. readonly onYButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  43182. /**
  43183. * Called once for each button that changed state since the last frame
  43184. * 0) thumb stick (touch, press, value = pressed (0,1)). value is in this.leftStick
  43185. * 1) index trigger (touch (?), press (only when value > 0.1), value 0 to 1)
  43186. * 2) secondary trigger (same)
  43187. * 3) A (right) X (left), touch, pressed = value
  43188. * 4) B / Y
  43189. * 5) thumb rest
  43190. * @param buttonIdx Which button index changed
  43191. * @param state New state of the button
  43192. * @param changes Which properties on the state changed since last frame
  43193. */
  43194. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  43195. }
  43196. }
  43197. declare module "babylonjs/Gamepads/Controllers/viveController" {
  43198. import { Scene } from "babylonjs/scene";
  43199. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  43200. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  43201. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  43202. import { GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  43203. import { Observable } from "babylonjs/Misc/observable";
  43204. /**
  43205. * Vive Controller
  43206. */
  43207. export class ViveController extends WebVRController {
  43208. /**
  43209. * Base Url for the controller model.
  43210. */
  43211. static MODEL_BASE_URL: string;
  43212. /**
  43213. * File name for the controller model.
  43214. */
  43215. static MODEL_FILENAME: string;
  43216. /**
  43217. * Creates a new ViveController from a gamepad
  43218. * @param vrGamepad the gamepad that the controller should be created from
  43219. */
  43220. constructor(vrGamepad: any);
  43221. /**
  43222. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  43223. * @param scene scene in which to add meshes
  43224. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  43225. */
  43226. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  43227. /**
  43228. * Fired when the left button on this controller is modified
  43229. */
  43230. readonly onLeftButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  43231. /**
  43232. * Fired when the right button on this controller is modified
  43233. */
  43234. readonly onRightButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  43235. /**
  43236. * Fired when the menu button on this controller is modified
  43237. */
  43238. readonly onMenuButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  43239. /**
  43240. * Called once for each button that changed state since the last frame
  43241. * Vive mapping:
  43242. * 0: touchpad
  43243. * 1: trigger
  43244. * 2: left AND right buttons
  43245. * 3: menu button
  43246. * @param buttonIdx Which button index changed
  43247. * @param state New state of the button
  43248. * @param changes Which properties on the state changed since last frame
  43249. */
  43250. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  43251. }
  43252. }
  43253. declare module "babylonjs/Gamepads/Controllers/windowsMotionController" {
  43254. import { Observable } from "babylonjs/Misc/observable";
  43255. import { Scene } from "babylonjs/scene";
  43256. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  43257. import { Ray } from "babylonjs/Culling/ray";
  43258. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  43259. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  43260. import { StickValues, GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  43261. /**
  43262. * Defines the WindowsMotionController object that the state of the windows motion controller
  43263. */
  43264. export class WindowsMotionController extends WebVRController {
  43265. /**
  43266. * The base url used to load the left and right controller models
  43267. */
  43268. static MODEL_BASE_URL: string;
  43269. /**
  43270. * The name of the left controller model file
  43271. */
  43272. static MODEL_LEFT_FILENAME: string;
  43273. /**
  43274. * The name of the right controller model file
  43275. */
  43276. static MODEL_RIGHT_FILENAME: string;
  43277. /**
  43278. * The controller name prefix for this controller type
  43279. */
  43280. static readonly GAMEPAD_ID_PREFIX: string;
  43281. /**
  43282. * The controller id pattern for this controller type
  43283. */
  43284. private static readonly GAMEPAD_ID_PATTERN;
  43285. private _loadedMeshInfo;
  43286. private readonly _mapping;
  43287. /**
  43288. * Fired when the trackpad on this controller is clicked
  43289. */
  43290. onTrackpadChangedObservable: Observable<ExtendedGamepadButton>;
  43291. /**
  43292. * Fired when the trackpad on this controller is modified
  43293. */
  43294. onTrackpadValuesChangedObservable: Observable<StickValues>;
  43295. /**
  43296. * The current x and y values of this controller's trackpad
  43297. */
  43298. trackpad: StickValues;
  43299. /**
  43300. * Creates a new WindowsMotionController from a gamepad
  43301. * @param vrGamepad the gamepad that the controller should be created from
  43302. */
  43303. constructor(vrGamepad: any);
  43304. /**
  43305. * Fired when the trigger on this controller is modified
  43306. */
  43307. readonly onTriggerButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  43308. /**
  43309. * Fired when the menu button on this controller is modified
  43310. */
  43311. readonly onMenuButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  43312. /**
  43313. * Fired when the grip button on this controller is modified
  43314. */
  43315. readonly onGripButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  43316. /**
  43317. * Fired when the thumbstick button on this controller is modified
  43318. */
  43319. readonly onThumbstickButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  43320. /**
  43321. * Fired when the touchpad button on this controller is modified
  43322. */
  43323. readonly onTouchpadButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  43324. /**
  43325. * Fired when the touchpad values on this controller are modified
  43326. */
  43327. readonly onTouchpadValuesChangedObservable: Observable<StickValues>;
  43328. private _updateTrackpad;
  43329. /**
  43330. * Called once per frame by the engine.
  43331. */
  43332. update(): void;
  43333. /**
  43334. * Called once for each button that changed state since the last frame
  43335. * @param buttonIdx Which button index changed
  43336. * @param state New state of the button
  43337. * @param changes Which properties on the state changed since last frame
  43338. */
  43339. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  43340. /**
  43341. * Moves the buttons on the controller mesh based on their current state
  43342. * @param buttonName the name of the button to move
  43343. * @param buttonValue the value of the button which determines the buttons new position
  43344. */
  43345. protected _lerpButtonTransform(buttonName: string, buttonValue: number): void;
  43346. /**
  43347. * Moves the axis on the controller mesh based on its current state
  43348. * @param axis the index of the axis
  43349. * @param axisValue the value of the axis which determines the meshes new position
  43350. * @hidden
  43351. */
  43352. protected _lerpAxisTransform(axis: number, axisValue: number): void;
  43353. /**
  43354. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  43355. * @param scene scene in which to add meshes
  43356. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  43357. */
  43358. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void, forceDefault?: boolean): void;
  43359. /**
  43360. * Takes a list of meshes (as loaded from the glTF file) and finds the root node, as well as nodes that
  43361. * can be transformed by button presses and axes values, based on this._mapping.
  43362. *
  43363. * @param scene scene in which the meshes exist
  43364. * @param meshes list of meshes that make up the controller model to process
  43365. * @return structured view of the given meshes, with mapping of buttons and axes to meshes that can be transformed.
  43366. */
  43367. private processModel;
  43368. private createMeshInfo;
  43369. /**
  43370. * Gets the ray of the controller in the direction the controller is pointing
  43371. * @param length the length the resulting ray should be
  43372. * @returns a ray in the direction the controller is pointing
  43373. */
  43374. getForwardRay(length?: number): Ray;
  43375. /**
  43376. * Disposes of the controller
  43377. */
  43378. dispose(): void;
  43379. }
  43380. }
  43381. declare module "babylonjs/Gamepads/Controllers/index" {
  43382. export * from "babylonjs/Gamepads/Controllers/daydreamController";
  43383. export * from "babylonjs/Gamepads/Controllers/gearVRController";
  43384. export * from "babylonjs/Gamepads/Controllers/genericController";
  43385. export * from "babylonjs/Gamepads/Controllers/oculusTouchController";
  43386. export * from "babylonjs/Gamepads/Controllers/poseEnabledController";
  43387. export * from "babylonjs/Gamepads/Controllers/viveController";
  43388. export * from "babylonjs/Gamepads/Controllers/webVRController";
  43389. export * from "babylonjs/Gamepads/Controllers/windowsMotionController";
  43390. }
  43391. declare module "babylonjs/Gamepads/index" {
  43392. export * from "babylonjs/Gamepads/Controllers/index";
  43393. export * from "babylonjs/Gamepads/gamepad";
  43394. export * from "babylonjs/Gamepads/gamepadManager";
  43395. export * from "babylonjs/Gamepads/gamepadSceneComponent";
  43396. export * from "babylonjs/Gamepads/xboxGamepad";
  43397. }
  43398. declare module "babylonjs/Gizmos/axisScaleGizmo" {
  43399. import { Observable } from "babylonjs/Misc/observable";
  43400. import { Nullable } from "babylonjs/types";
  43401. import { Vector3, Color3 } from "babylonjs/Maths/math";
  43402. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  43403. import { Mesh } from "babylonjs/Meshes/mesh";
  43404. import { PointerDragBehavior } from "babylonjs/Behaviors/Meshes/pointerDragBehavior";
  43405. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  43406. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  43407. /**
  43408. * Single axis scale gizmo
  43409. */
  43410. export class AxisScaleGizmo extends Gizmo {
  43411. private _coloredMaterial;
  43412. /**
  43413. * Drag behavior responsible for the gizmos dragging interactions
  43414. */
  43415. dragBehavior: PointerDragBehavior;
  43416. private _pointerObserver;
  43417. /**
  43418. * Scale distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  43419. */
  43420. snapDistance: number;
  43421. /**
  43422. * Event that fires each time the gizmo snaps to a new location.
  43423. * * snapDistance is the the change in distance
  43424. */
  43425. onSnapObservable: Observable<{
  43426. snapDistance: number;
  43427. }>;
  43428. /**
  43429. * If the scaling operation should be done on all axis (default: false)
  43430. */
  43431. uniformScaling: boolean;
  43432. /**
  43433. * Creates an AxisScaleGizmo
  43434. * @param gizmoLayer The utility layer the gizmo will be added to
  43435. * @param dragAxis The axis which the gizmo will be able to scale on
  43436. * @param color The color of the gizmo
  43437. */
  43438. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer);
  43439. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  43440. /**
  43441. * Disposes of the gizmo
  43442. */
  43443. dispose(): void;
  43444. /**
  43445. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  43446. * @param mesh The mesh to replace the default mesh of the gizmo
  43447. * @param useGizmoMaterial If the gizmo's default material should be used (default: false)
  43448. */
  43449. setCustomMesh(mesh: Mesh, useGizmoMaterial?: boolean): void;
  43450. }
  43451. }
  43452. declare module "babylonjs/Gizmos/boundingBoxGizmo" {
  43453. import { Observable } from "babylonjs/Misc/observable";
  43454. import { Nullable } from "babylonjs/types";
  43455. import { Vector3, Color3 } from "babylonjs/Maths/math";
  43456. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  43457. import { Mesh } from "babylonjs/Meshes/mesh";
  43458. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  43459. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  43460. import "babylonjs/Meshes/Builders/boxBuilder";
  43461. /**
  43462. * Bounding box gizmo
  43463. */
  43464. export class BoundingBoxGizmo extends Gizmo {
  43465. private _lineBoundingBox;
  43466. private _rotateSpheresParent;
  43467. private _scaleBoxesParent;
  43468. private _boundingDimensions;
  43469. private _renderObserver;
  43470. private _pointerObserver;
  43471. private _scaleDragSpeed;
  43472. private _tmpQuaternion;
  43473. private _tmpVector;
  43474. private _tmpRotationMatrix;
  43475. /**
  43476. * 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)
  43477. */
  43478. ignoreChildren: boolean;
  43479. /**
  43480. * 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)
  43481. */
  43482. includeChildPredicate: Nullable<(abstractMesh: AbstractMesh) => boolean>;
  43483. /**
  43484. * The size of the rotation spheres attached to the bounding box (Default: 0.1)
  43485. */
  43486. rotationSphereSize: number;
  43487. /**
  43488. * The size of the scale boxes attached to the bounding box (Default: 0.1)
  43489. */
  43490. scaleBoxSize: number;
  43491. /**
  43492. * 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)
  43493. */
  43494. fixedDragMeshScreenSize: boolean;
  43495. /**
  43496. * The distance away from the object which the draggable meshes should appear world sized when fixedDragMeshScreenSize is set to true (default: 10)
  43497. */
  43498. fixedDragMeshScreenSizeDistanceFactor: number;
  43499. /**
  43500. * Fired when a rotation sphere or scale box is dragged
  43501. */
  43502. onDragStartObservable: Observable<{}>;
  43503. /**
  43504. * Fired when a scale box is dragged
  43505. */
  43506. onScaleBoxDragObservable: Observable<{}>;
  43507. /**
  43508. * Fired when a scale box drag is ended
  43509. */
  43510. onScaleBoxDragEndObservable: Observable<{}>;
  43511. /**
  43512. * Fired when a rotation sphere is dragged
  43513. */
  43514. onRotationSphereDragObservable: Observable<{}>;
  43515. /**
  43516. * Fired when a rotation sphere drag is ended
  43517. */
  43518. onRotationSphereDragEndObservable: Observable<{}>;
  43519. /**
  43520. * 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)
  43521. */
  43522. scalePivot: Nullable<Vector3>;
  43523. private _anchorMesh;
  43524. private _existingMeshScale;
  43525. private _dragMesh;
  43526. private pointerDragBehavior;
  43527. private coloredMaterial;
  43528. private hoverColoredMaterial;
  43529. /**
  43530. * Sets the color of the bounding box gizmo
  43531. * @param color the color to set
  43532. */
  43533. setColor(color: Color3): void;
  43534. /**
  43535. * Creates an BoundingBoxGizmo
  43536. * @param gizmoLayer The utility layer the gizmo will be added to
  43537. * @param color The color of the gizmo
  43538. */
  43539. constructor(color?: Color3, gizmoLayer?: UtilityLayerRenderer);
  43540. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  43541. private _selectNode;
  43542. /**
  43543. * Updates the bounding box information for the Gizmo
  43544. */
  43545. updateBoundingBox(): void;
  43546. private _updateRotationSpheres;
  43547. private _updateScaleBoxes;
  43548. /**
  43549. * Enables rotation on the specified axis and disables rotation on the others
  43550. * @param axis The list of axis that should be enabled (eg. "xy" or "xyz")
  43551. */
  43552. setEnabledRotationAxis(axis: string): void;
  43553. /**
  43554. * Enables/disables scaling
  43555. * @param enable if scaling should be enabled
  43556. */
  43557. setEnabledScaling(enable: boolean): void;
  43558. private _updateDummy;
  43559. /**
  43560. * Enables a pointer drag behavior on the bounding box of the gizmo
  43561. */
  43562. enableDragBehavior(): void;
  43563. /**
  43564. * Disposes of the gizmo
  43565. */
  43566. dispose(): void;
  43567. /**
  43568. * 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)
  43569. * @param mesh the mesh to wrap in the bounding box mesh and make not pickable
  43570. * @returns the bounding box mesh with the passed in mesh as a child
  43571. */
  43572. static MakeNotPickableAndWrapInBoundingBox(mesh: Mesh): Mesh;
  43573. /**
  43574. * CustomMeshes are not supported by this gizmo
  43575. * @param mesh The mesh to replace the default mesh of the gizmo
  43576. */
  43577. setCustomMesh(mesh: Mesh): void;
  43578. }
  43579. }
  43580. declare module "babylonjs/Gizmos/planeRotationGizmo" {
  43581. import { Observable } from "babylonjs/Misc/observable";
  43582. import { Nullable } from "babylonjs/types";
  43583. import { Vector3, Color3 } from "babylonjs/Maths/math";
  43584. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  43585. import { PointerDragBehavior } from "babylonjs/Behaviors/Meshes/pointerDragBehavior";
  43586. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  43587. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  43588. import "babylonjs/Meshes/Builders/linesBuilder";
  43589. /**
  43590. * Single plane rotation gizmo
  43591. */
  43592. export class PlaneRotationGizmo extends Gizmo {
  43593. /**
  43594. * Drag behavior responsible for the gizmos dragging interactions
  43595. */
  43596. dragBehavior: PointerDragBehavior;
  43597. private _pointerObserver;
  43598. /**
  43599. * Rotation distance in radians that the gizmo will snap to (Default: 0)
  43600. */
  43601. snapDistance: number;
  43602. /**
  43603. * Event that fires each time the gizmo snaps to a new location.
  43604. * * snapDistance is the the change in distance
  43605. */
  43606. onSnapObservable: Observable<{
  43607. snapDistance: number;
  43608. }>;
  43609. /**
  43610. * Creates a PlaneRotationGizmo
  43611. * @param gizmoLayer The utility layer the gizmo will be added to
  43612. * @param planeNormal The normal of the plane which the gizmo will be able to rotate on
  43613. * @param color The color of the gizmo
  43614. * @param tessellation Amount of tessellation to be used when creating rotation circles
  43615. */
  43616. constructor(planeNormal: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, tessellation?: number);
  43617. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  43618. /**
  43619. * Disposes of the gizmo
  43620. */
  43621. dispose(): void;
  43622. }
  43623. }
  43624. declare module "babylonjs/Gizmos/rotationGizmo" {
  43625. import { Observable } from "babylonjs/Misc/observable";
  43626. import { Nullable } from "babylonjs/types";
  43627. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  43628. import { Mesh } from "babylonjs/Meshes/mesh";
  43629. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  43630. import { PlaneRotationGizmo } from "babylonjs/Gizmos/planeRotationGizmo";
  43631. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  43632. /**
  43633. * Gizmo that enables rotating a mesh along 3 axis
  43634. */
  43635. export class RotationGizmo extends Gizmo {
  43636. /**
  43637. * Internal gizmo used for interactions on the x axis
  43638. */
  43639. xGizmo: PlaneRotationGizmo;
  43640. /**
  43641. * Internal gizmo used for interactions on the y axis
  43642. */
  43643. yGizmo: PlaneRotationGizmo;
  43644. /**
  43645. * Internal gizmo used for interactions on the z axis
  43646. */
  43647. zGizmo: PlaneRotationGizmo;
  43648. /** Fires an event when any of it's sub gizmos are dragged */
  43649. onDragStartObservable: Observable<{}>;
  43650. /** Fires an event when any of it's sub gizmos are released from dragging */
  43651. onDragEndObservable: Observable<{}>;
  43652. attachedMesh: Nullable<AbstractMesh>;
  43653. /**
  43654. * Creates a RotationGizmo
  43655. * @param gizmoLayer The utility layer the gizmo will be added to
  43656. * @param tessellation Amount of tessellation to be used when creating rotation circles
  43657. */
  43658. constructor(gizmoLayer?: UtilityLayerRenderer, tessellation?: number);
  43659. updateGizmoRotationToMatchAttachedMesh: boolean;
  43660. /**
  43661. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  43662. */
  43663. snapDistance: number;
  43664. /**
  43665. * Ratio for the scale of the gizmo (Default: 1)
  43666. */
  43667. scaleRatio: number;
  43668. /**
  43669. * Disposes of the gizmo
  43670. */
  43671. dispose(): void;
  43672. /**
  43673. * CustomMeshes are not supported by this gizmo
  43674. * @param mesh The mesh to replace the default mesh of the gizmo
  43675. */
  43676. setCustomMesh(mesh: Mesh): void;
  43677. }
  43678. }
  43679. declare module "babylonjs/Gizmos/positionGizmo" {
  43680. import { Observable } from "babylonjs/Misc/observable";
  43681. import { Nullable } from "babylonjs/types";
  43682. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  43683. import { Mesh } from "babylonjs/Meshes/mesh";
  43684. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  43685. import { AxisDragGizmo } from "babylonjs/Gizmos/axisDragGizmo";
  43686. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  43687. /**
  43688. * Gizmo that enables dragging a mesh along 3 axis
  43689. */
  43690. export class PositionGizmo extends Gizmo {
  43691. /**
  43692. * Internal gizmo used for interactions on the x axis
  43693. */
  43694. xGizmo: AxisDragGizmo;
  43695. /**
  43696. * Internal gizmo used for interactions on the y axis
  43697. */
  43698. yGizmo: AxisDragGizmo;
  43699. /**
  43700. * Internal gizmo used for interactions on the z axis
  43701. */
  43702. zGizmo: AxisDragGizmo;
  43703. /** Fires an event when any of it's sub gizmos are dragged */
  43704. onDragStartObservable: Observable<{}>;
  43705. /** Fires an event when any of it's sub gizmos are released from dragging */
  43706. onDragEndObservable: Observable<{}>;
  43707. attachedMesh: Nullable<AbstractMesh>;
  43708. /**
  43709. * Creates a PositionGizmo
  43710. * @param gizmoLayer The utility layer the gizmo will be added to
  43711. */
  43712. constructor(gizmoLayer?: UtilityLayerRenderer);
  43713. updateGizmoRotationToMatchAttachedMesh: boolean;
  43714. /**
  43715. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  43716. */
  43717. snapDistance: number;
  43718. /**
  43719. * Ratio for the scale of the gizmo (Default: 1)
  43720. */
  43721. scaleRatio: number;
  43722. /**
  43723. * Disposes of the gizmo
  43724. */
  43725. dispose(): void;
  43726. /**
  43727. * CustomMeshes are not supported by this gizmo
  43728. * @param mesh The mesh to replace the default mesh of the gizmo
  43729. */
  43730. setCustomMesh(mesh: Mesh): void;
  43731. }
  43732. }
  43733. declare module "babylonjs/Meshes/Builders/polyhedronBuilder" {
  43734. import { Scene } from "babylonjs/scene";
  43735. import { Color4, Vector4 } from "babylonjs/Maths/math";
  43736. import { Mesh } from "babylonjs/Meshes/mesh";
  43737. /**
  43738. * Class containing static functions to help procedurally build meshes
  43739. */
  43740. export class PolyhedronBuilder {
  43741. /**
  43742. * Creates a polyhedron mesh
  43743. * * 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
  43744. * * The parameter `size` (positive float, default 1) sets the polygon size
  43745. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  43746. * * 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`
  43747. * * 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
  43748. * * 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)`)
  43749. * * 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
  43750. * * 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
  43751. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  43752. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  43753. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  43754. * @param name defines the name of the mesh
  43755. * @param options defines the options used to create the mesh
  43756. * @param scene defines the hosting scene
  43757. * @returns the polyhedron mesh
  43758. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  43759. */
  43760. static CreatePolyhedron(name: string, options: {
  43761. type?: number;
  43762. size?: number;
  43763. sizeX?: number;
  43764. sizeY?: number;
  43765. sizeZ?: number;
  43766. custom?: any;
  43767. faceUV?: Vector4[];
  43768. faceColors?: Color4[];
  43769. flat?: boolean;
  43770. updatable?: boolean;
  43771. sideOrientation?: number;
  43772. frontUVs?: Vector4;
  43773. backUVs?: Vector4;
  43774. }, scene: Scene): Mesh;
  43775. }
  43776. }
  43777. declare module "babylonjs/Gizmos/scaleGizmo" {
  43778. import { Observable } from "babylonjs/Misc/observable";
  43779. import { Nullable } from "babylonjs/types";
  43780. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  43781. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  43782. import { AxisScaleGizmo } from "babylonjs/Gizmos/axisScaleGizmo";
  43783. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  43784. /**
  43785. * Gizmo that enables scaling a mesh along 3 axis
  43786. */
  43787. export class ScaleGizmo extends Gizmo {
  43788. /**
  43789. * Internal gizmo used for interactions on the x axis
  43790. */
  43791. xGizmo: AxisScaleGizmo;
  43792. /**
  43793. * Internal gizmo used for interactions on the y axis
  43794. */
  43795. yGizmo: AxisScaleGizmo;
  43796. /**
  43797. * Internal gizmo used for interactions on the z axis
  43798. */
  43799. zGizmo: AxisScaleGizmo;
  43800. /**
  43801. * Internal gizmo used to scale all axis equally
  43802. */
  43803. uniformScaleGizmo: AxisScaleGizmo;
  43804. /** Fires an event when any of it's sub gizmos are dragged */
  43805. onDragStartObservable: Observable<{}>;
  43806. /** Fires an event when any of it's sub gizmos are released from dragging */
  43807. onDragEndObservable: Observable<{}>;
  43808. attachedMesh: Nullable<AbstractMesh>;
  43809. /**
  43810. * Creates a ScaleGizmo
  43811. * @param gizmoLayer The utility layer the gizmo will be added to
  43812. */
  43813. constructor(gizmoLayer?: UtilityLayerRenderer);
  43814. updateGizmoRotationToMatchAttachedMesh: boolean;
  43815. /**
  43816. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  43817. */
  43818. snapDistance: number;
  43819. /**
  43820. * Ratio for the scale of the gizmo (Default: 1)
  43821. */
  43822. scaleRatio: number;
  43823. /**
  43824. * Disposes of the gizmo
  43825. */
  43826. dispose(): void;
  43827. }
  43828. }
  43829. declare module "babylonjs/Gizmos/gizmoManager" {
  43830. import { Observable } from "babylonjs/Misc/observable";
  43831. import { Nullable } from "babylonjs/types";
  43832. import { Scene, IDisposable } from "babylonjs/scene";
  43833. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  43834. import { SixDofDragBehavior } from "babylonjs/Behaviors/Meshes/sixDofDragBehavior";
  43835. import { RotationGizmo } from "babylonjs/Gizmos/rotationGizmo";
  43836. import { PositionGizmo } from "babylonjs/Gizmos/positionGizmo";
  43837. import { ScaleGizmo } from "babylonjs/Gizmos/scaleGizmo";
  43838. import { BoundingBoxGizmo } from "babylonjs/Gizmos/boundingBoxGizmo";
  43839. /**
  43840. * Helps setup gizmo's in the scene to rotate/scale/position meshes
  43841. */
  43842. export class GizmoManager implements IDisposable {
  43843. private scene;
  43844. /**
  43845. * Gizmo's created by the gizmo manager, gizmo will be null until gizmo has been enabled for the first time
  43846. */
  43847. gizmos: {
  43848. positionGizmo: Nullable<PositionGizmo>;
  43849. rotationGizmo: Nullable<RotationGizmo>;
  43850. scaleGizmo: Nullable<ScaleGizmo>;
  43851. boundingBoxGizmo: Nullable<BoundingBoxGizmo>;
  43852. };
  43853. /** When true, the gizmo will be detached from the current object when a pointer down occurs with an empty picked mesh */
  43854. clearGizmoOnEmptyPointerEvent: boolean;
  43855. /** Fires an event when the manager is attached to a mesh */
  43856. onAttachedToMeshObservable: Observable<Nullable<AbstractMesh>>;
  43857. private _gizmosEnabled;
  43858. private _pointerObserver;
  43859. private _attachedMesh;
  43860. private _boundingBoxColor;
  43861. private _defaultUtilityLayer;
  43862. private _defaultKeepDepthUtilityLayer;
  43863. /**
  43864. * When bounding box gizmo is enabled, this can be used to track drag/end events
  43865. */
  43866. boundingBoxDragBehavior: SixDofDragBehavior;
  43867. /**
  43868. * Array of meshes which will have the gizmo attached when a pointer selected them. If null, all meshes are attachable. (Default: null)
  43869. */
  43870. attachableMeshes: Nullable<Array<AbstractMesh>>;
  43871. /**
  43872. * If pointer events should perform attaching/detaching a gizmo, if false this can be done manually via attachToMesh. (Default: true)
  43873. */
  43874. usePointerToAttachGizmos: boolean;
  43875. /**
  43876. * Instatiates a gizmo manager
  43877. * @param scene the scene to overlay the gizmos on top of
  43878. */
  43879. constructor(scene: Scene);
  43880. /**
  43881. * Attaches a set of gizmos to the specified mesh
  43882. * @param mesh The mesh the gizmo's should be attached to
  43883. */
  43884. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  43885. /**
  43886. * If the position gizmo is enabled
  43887. */
  43888. positionGizmoEnabled: boolean;
  43889. /**
  43890. * If the rotation gizmo is enabled
  43891. */
  43892. rotationGizmoEnabled: boolean;
  43893. /**
  43894. * If the scale gizmo is enabled
  43895. */
  43896. scaleGizmoEnabled: boolean;
  43897. /**
  43898. * If the boundingBox gizmo is enabled
  43899. */
  43900. boundingBoxGizmoEnabled: boolean;
  43901. /**
  43902. * Disposes of the gizmo manager
  43903. */
  43904. dispose(): void;
  43905. }
  43906. }
  43907. declare module "babylonjs/Gizmos/lightGizmo" {
  43908. import { Nullable } from "babylonjs/types";
  43909. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  43910. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  43911. import { Light } from "babylonjs/Lights/light";
  43912. /**
  43913. * Gizmo that enables viewing a light
  43914. */
  43915. export class LightGizmo extends Gizmo {
  43916. private _box;
  43917. /**
  43918. * Creates a LightGizmo
  43919. * @param gizmoLayer The utility layer the gizmo will be added to
  43920. */
  43921. constructor(gizmoLayer?: UtilityLayerRenderer);
  43922. private _light;
  43923. /**
  43924. * The light that the gizmo is attached to
  43925. */
  43926. light: Nullable<Light>;
  43927. /**
  43928. * @hidden
  43929. * Updates the gizmo to match the attached mesh's position/rotation
  43930. */
  43931. protected _update(): void;
  43932. }
  43933. }
  43934. declare module "babylonjs/Gizmos/index" {
  43935. export * from "babylonjs/Gizmos/axisDragGizmo";
  43936. export * from "babylonjs/Gizmos/axisScaleGizmo";
  43937. export * from "babylonjs/Gizmos/boundingBoxGizmo";
  43938. export * from "babylonjs/Gizmos/gizmo";
  43939. export * from "babylonjs/Gizmos/gizmoManager";
  43940. export * from "babylonjs/Gizmos/planeRotationGizmo";
  43941. export * from "babylonjs/Gizmos/positionGizmo";
  43942. export * from "babylonjs/Gizmos/rotationGizmo";
  43943. export * from "babylonjs/Gizmos/scaleGizmo";
  43944. export * from "babylonjs/Gizmos/lightGizmo";
  43945. }
  43946. declare module "babylonjs/Shaders/ShadersInclude/backgroundFragmentDeclaration" {
  43947. /** @hidden */
  43948. export var backgroundFragmentDeclaration: {
  43949. name: string;
  43950. shader: string;
  43951. };
  43952. }
  43953. declare module "babylonjs/Shaders/ShadersInclude/backgroundUboDeclaration" {
  43954. /** @hidden */
  43955. export var backgroundUboDeclaration: {
  43956. name: string;
  43957. shader: string;
  43958. };
  43959. }
  43960. declare module "babylonjs/Shaders/background.fragment" {
  43961. import "babylonjs/Shaders/ShadersInclude/backgroundFragmentDeclaration";
  43962. import "babylonjs/Shaders/ShadersInclude/backgroundUboDeclaration";
  43963. import "babylonjs/Shaders/ShadersInclude/reflectionFunction";
  43964. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  43965. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  43966. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  43967. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  43968. import "babylonjs/Shaders/ShadersInclude/lightsFragmentFunctions";
  43969. import "babylonjs/Shaders/ShadersInclude/shadowsFragmentFunctions";
  43970. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  43971. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration";
  43972. import "babylonjs/Shaders/ShadersInclude/fogFragmentDeclaration";
  43973. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  43974. import "babylonjs/Shaders/ShadersInclude/lightFragment";
  43975. import "babylonjs/Shaders/ShadersInclude/fogFragment";
  43976. /** @hidden */
  43977. export var backgroundPixelShader: {
  43978. name: string;
  43979. shader: string;
  43980. };
  43981. }
  43982. declare module "babylonjs/Shaders/ShadersInclude/backgroundVertexDeclaration" {
  43983. /** @hidden */
  43984. export var backgroundVertexDeclaration: {
  43985. name: string;
  43986. shader: string;
  43987. };
  43988. }
  43989. declare module "babylonjs/Shaders/background.vertex" {
  43990. import "babylonjs/Shaders/ShadersInclude/backgroundVertexDeclaration";
  43991. import "babylonjs/Shaders/ShadersInclude/backgroundUboDeclaration";
  43992. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  43993. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  43994. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  43995. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration";
  43996. import "babylonjs/Shaders/ShadersInclude/fogVertexDeclaration";
  43997. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  43998. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  43999. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  44000. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  44001. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  44002. import "babylonjs/Shaders/ShadersInclude/fogVertex";
  44003. import "babylonjs/Shaders/ShadersInclude/shadowsVertex";
  44004. /** @hidden */
  44005. export var backgroundVertexShader: {
  44006. name: string;
  44007. shader: string;
  44008. };
  44009. }
  44010. declare module "babylonjs/Materials/Background/backgroundMaterial" {
  44011. import { Nullable, int, float } from "babylonjs/types";
  44012. import { Scene } from "babylonjs/scene";
  44013. import { Matrix, Vector3, Color3 } from "babylonjs/Maths/math";
  44014. import { SubMesh } from "babylonjs/Meshes/subMesh";
  44015. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  44016. import { Mesh } from "babylonjs/Meshes/mesh";
  44017. import { PushMaterial } from "babylonjs/Materials/pushMaterial";
  44018. import { ColorCurves } from "babylonjs/Materials/colorCurves";
  44019. import { ImageProcessingConfiguration } from "babylonjs/Materials/imageProcessingConfiguration";
  44020. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  44021. import { IShadowLight } from "babylonjs/Lights/shadowLight";
  44022. import "babylonjs/Shaders/background.fragment";
  44023. import "babylonjs/Shaders/background.vertex";
  44024. /**
  44025. * Background material used to create an efficient environement around your scene.
  44026. */
  44027. export class BackgroundMaterial extends PushMaterial {
  44028. /**
  44029. * Standard reflectance value at parallel view angle.
  44030. */
  44031. static StandardReflectance0: number;
  44032. /**
  44033. * Standard reflectance value at grazing angle.
  44034. */
  44035. static StandardReflectance90: number;
  44036. protected _primaryColor: Color3;
  44037. /**
  44038. * Key light Color (multiply against the environement texture)
  44039. */
  44040. primaryColor: Color3;
  44041. protected __perceptualColor: Nullable<Color3>;
  44042. /**
  44043. * Experimental Internal Use Only.
  44044. *
  44045. * Key light Color in "perceptual value" meaning the color you would like to see on screen.
  44046. * This acts as a helper to set the primary color to a more "human friendly" value.
  44047. * Conversion to linear space as well as exposure and tone mapping correction will be applied to keep the
  44048. * output color as close as possible from the chosen value.
  44049. * (This does not account for contrast color grading and color curves as they are considered post effect and not directly
  44050. * part of lighting setup.)
  44051. */
  44052. _perceptualColor: Nullable<Color3>;
  44053. protected _primaryColorShadowLevel: float;
  44054. /**
  44055. * Defines the level of the shadows (dark area of the reflection map) in order to help scaling the colors.
  44056. * The color opposite to the primary color is used at the level chosen to define what the black area would look.
  44057. */
  44058. primaryColorShadowLevel: float;
  44059. protected _primaryColorHighlightLevel: float;
  44060. /**
  44061. * Defines the level of the highliights (highlight area of the reflection map) in order to help scaling the colors.
  44062. * The primary color is used at the level chosen to define what the white area would look.
  44063. */
  44064. primaryColorHighlightLevel: float;
  44065. protected _reflectionTexture: Nullable<BaseTexture>;
  44066. /**
  44067. * Reflection Texture used in the material.
  44068. * Should be author in a specific way for the best result (refer to the documentation).
  44069. */
  44070. reflectionTexture: Nullable<BaseTexture>;
  44071. protected _reflectionBlur: float;
  44072. /**
  44073. * Reflection Texture level of blur.
  44074. *
  44075. * Can be use to reuse an existing HDR Texture and target a specific LOD to prevent authoring the
  44076. * texture twice.
  44077. */
  44078. reflectionBlur: float;
  44079. protected _diffuseTexture: Nullable<BaseTexture>;
  44080. /**
  44081. * Diffuse Texture used in the material.
  44082. * Should be author in a specific way for the best result (refer to the documentation).
  44083. */
  44084. diffuseTexture: Nullable<BaseTexture>;
  44085. protected _shadowLights: Nullable<IShadowLight[]>;
  44086. /**
  44087. * Specify the list of lights casting shadow on the material.
  44088. * All scene shadow lights will be included if null.
  44089. */
  44090. shadowLights: Nullable<IShadowLight[]>;
  44091. protected _shadowLevel: float;
  44092. /**
  44093. * Helps adjusting the shadow to a softer level if required.
  44094. * 0 means black shadows and 1 means no shadows.
  44095. */
  44096. shadowLevel: float;
  44097. protected _sceneCenter: Vector3;
  44098. /**
  44099. * In case of opacity Fresnel or reflection falloff, this is use as a scene center.
  44100. * It is usually zero but might be interesting to modify according to your setup.
  44101. */
  44102. sceneCenter: Vector3;
  44103. protected _opacityFresnel: boolean;
  44104. /**
  44105. * This helps specifying that the material is falling off to the sky box at grazing angle.
  44106. * This helps ensuring a nice transition when the camera goes under the ground.
  44107. */
  44108. opacityFresnel: boolean;
  44109. protected _reflectionFresnel: boolean;
  44110. /**
  44111. * This helps specifying that the material is falling off from diffuse to the reflection texture at grazing angle.
  44112. * This helps adding a mirror texture on the ground.
  44113. */
  44114. reflectionFresnel: boolean;
  44115. protected _reflectionFalloffDistance: number;
  44116. /**
  44117. * This helps specifying the falloff radius off the reflection texture from the sceneCenter.
  44118. * This helps adding a nice falloff effect to the reflection if used as a mirror for instance.
  44119. */
  44120. reflectionFalloffDistance: number;
  44121. protected _reflectionAmount: number;
  44122. /**
  44123. * This specifies the weight of the reflection against the background in case of reflection Fresnel.
  44124. */
  44125. reflectionAmount: number;
  44126. protected _reflectionReflectance0: number;
  44127. /**
  44128. * This specifies the weight of the reflection at grazing angle.
  44129. */
  44130. reflectionReflectance0: number;
  44131. protected _reflectionReflectance90: number;
  44132. /**
  44133. * This specifies the weight of the reflection at a perpendicular point of view.
  44134. */
  44135. reflectionReflectance90: number;
  44136. /**
  44137. * Sets the reflection reflectance fresnel values according to the default standard
  44138. * empirically know to work well :-)
  44139. */
  44140. reflectionStandardFresnelWeight: number;
  44141. protected _useRGBColor: boolean;
  44142. /**
  44143. * Helps to directly use the maps channels instead of their level.
  44144. */
  44145. useRGBColor: boolean;
  44146. protected _enableNoise: boolean;
  44147. /**
  44148. * This helps reducing the banding effect that could occur on the background.
  44149. */
  44150. enableNoise: boolean;
  44151. /**
  44152. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  44153. * Best used when trying to implement visual zoom effects like fish-eye or binoculars while not adjusting camera fov.
  44154. * Recommended to be keep at 1.0 except for special cases.
  44155. */
  44156. fovMultiplier: number;
  44157. private _fovMultiplier;
  44158. /**
  44159. * Enable the FOV adjustment feature controlled by fovMultiplier.
  44160. */
  44161. useEquirectangularFOV: boolean;
  44162. private _maxSimultaneousLights;
  44163. /**
  44164. * Number of Simultaneous lights allowed on the material.
  44165. */
  44166. maxSimultaneousLights: int;
  44167. /**
  44168. * Default configuration related to image processing available in the Background Material.
  44169. */
  44170. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  44171. /**
  44172. * Keep track of the image processing observer to allow dispose and replace.
  44173. */
  44174. private _imageProcessingObserver;
  44175. /**
  44176. * Attaches a new image processing configuration to the PBR Material.
  44177. * @param configuration (if null the scene configuration will be use)
  44178. */
  44179. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  44180. /**
  44181. * Gets the image processing configuration used either in this material.
  44182. */
  44183. /**
  44184. * Sets the Default image processing configuration used either in the this material.
  44185. *
  44186. * If sets to null, the scene one is in use.
  44187. */
  44188. imageProcessingConfiguration: Nullable<ImageProcessingConfiguration>;
  44189. /**
  44190. * Gets wether the color curves effect is enabled.
  44191. */
  44192. /**
  44193. * Sets wether the color curves effect is enabled.
  44194. */
  44195. cameraColorCurvesEnabled: boolean;
  44196. /**
  44197. * Gets wether the color grading effect is enabled.
  44198. */
  44199. /**
  44200. * Gets wether the color grading effect is enabled.
  44201. */
  44202. cameraColorGradingEnabled: boolean;
  44203. /**
  44204. * Gets wether tonemapping is enabled or not.
  44205. */
  44206. /**
  44207. * Sets wether tonemapping is enabled or not
  44208. */
  44209. cameraToneMappingEnabled: boolean;
  44210. /**
  44211. * The camera exposure used on this material.
  44212. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  44213. * This corresponds to a photographic exposure.
  44214. */
  44215. /**
  44216. * The camera exposure used on this material.
  44217. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  44218. * This corresponds to a photographic exposure.
  44219. */
  44220. cameraExposure: float;
  44221. /**
  44222. * Gets The camera contrast used on this material.
  44223. */
  44224. /**
  44225. * Sets The camera contrast used on this material.
  44226. */
  44227. cameraContrast: float;
  44228. /**
  44229. * Gets the Color Grading 2D Lookup Texture.
  44230. */
  44231. /**
  44232. * Sets the Color Grading 2D Lookup Texture.
  44233. */
  44234. cameraColorGradingTexture: Nullable<BaseTexture>;
  44235. /**
  44236. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  44237. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  44238. * 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;
  44239. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  44240. */
  44241. /**
  44242. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  44243. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  44244. * 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;
  44245. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  44246. */
  44247. cameraColorCurves: Nullable<ColorCurves>;
  44248. /**
  44249. * Due to a bug in iOS10, video tags (which are using the background material) are in BGR and not RGB.
  44250. * Setting this flag to true (not done automatically!) will convert it back to RGB.
  44251. */
  44252. switchToBGR: boolean;
  44253. private _renderTargets;
  44254. private _reflectionControls;
  44255. private _white;
  44256. private _primaryShadowColor;
  44257. private _primaryHighlightColor;
  44258. /**
  44259. * Instantiates a Background Material in the given scene
  44260. * @param name The friendly name of the material
  44261. * @param scene The scene to add the material to
  44262. */
  44263. constructor(name: string, scene: Scene);
  44264. /**
  44265. * Gets a boolean indicating that current material needs to register RTT
  44266. */
  44267. readonly hasRenderTargetTextures: boolean;
  44268. /**
  44269. * The entire material has been created in order to prevent overdraw.
  44270. * @returns false
  44271. */
  44272. needAlphaTesting(): boolean;
  44273. /**
  44274. * The entire material has been created in order to prevent overdraw.
  44275. * @returns true if blending is enable
  44276. */
  44277. needAlphaBlending(): boolean;
  44278. /**
  44279. * Checks wether the material is ready to be rendered for a given mesh.
  44280. * @param mesh The mesh to render
  44281. * @param subMesh The submesh to check against
  44282. * @param useInstances Specify wether or not the material is used with instances
  44283. * @returns true if all the dependencies are ready (Textures, Effects...)
  44284. */
  44285. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  44286. /**
  44287. * Compute the primary color according to the chosen perceptual color.
  44288. */
  44289. private _computePrimaryColorFromPerceptualColor;
  44290. /**
  44291. * Compute the highlights and shadow colors according to their chosen levels.
  44292. */
  44293. private _computePrimaryColors;
  44294. /**
  44295. * Build the uniform buffer used in the material.
  44296. */
  44297. buildUniformLayout(): void;
  44298. /**
  44299. * Unbind the material.
  44300. */
  44301. unbind(): void;
  44302. /**
  44303. * Bind only the world matrix to the material.
  44304. * @param world The world matrix to bind.
  44305. */
  44306. bindOnlyWorldMatrix(world: Matrix): void;
  44307. /**
  44308. * Bind the material for a dedicated submeh (every used meshes will be considered opaque).
  44309. * @param world The world matrix to bind.
  44310. * @param subMesh The submesh to bind for.
  44311. */
  44312. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  44313. /**
  44314. * Dispose the material.
  44315. * @param forceDisposeEffect Force disposal of the associated effect.
  44316. * @param forceDisposeTextures Force disposal of the associated textures.
  44317. */
  44318. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  44319. /**
  44320. * Clones the material.
  44321. * @param name The cloned name.
  44322. * @returns The cloned material.
  44323. */
  44324. clone(name: string): BackgroundMaterial;
  44325. /**
  44326. * Serializes the current material to its JSON representation.
  44327. * @returns The JSON representation.
  44328. */
  44329. serialize(): any;
  44330. /**
  44331. * Gets the class name of the material
  44332. * @returns "BackgroundMaterial"
  44333. */
  44334. getClassName(): string;
  44335. /**
  44336. * Parse a JSON input to create back a background material.
  44337. * @param source The JSON data to parse
  44338. * @param scene The scene to create the parsed material in
  44339. * @param rootUrl The root url of the assets the material depends upon
  44340. * @returns the instantiated BackgroundMaterial.
  44341. */
  44342. static Parse(source: any, scene: Scene, rootUrl: string): BackgroundMaterial;
  44343. }
  44344. }
  44345. declare module "babylonjs/Helpers/environmentHelper" {
  44346. import { Observable } from "babylonjs/Misc/observable";
  44347. import { Nullable } from "babylonjs/types";
  44348. import { Scene } from "babylonjs/scene";
  44349. import { Vector3, Color3 } from "babylonjs/Maths/math";
  44350. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  44351. import { Mesh } from "babylonjs/Meshes/mesh";
  44352. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  44353. import { MirrorTexture } from "babylonjs/Materials/Textures/mirrorTexture";
  44354. import { BackgroundMaterial } from "babylonjs/Materials/Background/backgroundMaterial";
  44355. import "babylonjs/Meshes/Builders/planeBuilder";
  44356. import "babylonjs/Meshes/Builders/boxBuilder";
  44357. /**
  44358. * Represents the different options available during the creation of
  44359. * a Environment helper.
  44360. *
  44361. * This can control the default ground, skybox and image processing setup of your scene.
  44362. */
  44363. export interface IEnvironmentHelperOptions {
  44364. /**
  44365. * Specifies wether or not to create a ground.
  44366. * True by default.
  44367. */
  44368. createGround: boolean;
  44369. /**
  44370. * Specifies the ground size.
  44371. * 15 by default.
  44372. */
  44373. groundSize: number;
  44374. /**
  44375. * The texture used on the ground for the main color.
  44376. * Comes from the BabylonJS CDN by default.
  44377. *
  44378. * Remarks: Can be either a texture or a url.
  44379. */
  44380. groundTexture: string | BaseTexture;
  44381. /**
  44382. * The color mixed in the ground texture by default.
  44383. * BabylonJS clearColor by default.
  44384. */
  44385. groundColor: Color3;
  44386. /**
  44387. * Specifies the ground opacity.
  44388. * 1 by default.
  44389. */
  44390. groundOpacity: number;
  44391. /**
  44392. * Enables the ground to receive shadows.
  44393. * True by default.
  44394. */
  44395. enableGroundShadow: boolean;
  44396. /**
  44397. * Helps preventing the shadow to be fully black on the ground.
  44398. * 0.5 by default.
  44399. */
  44400. groundShadowLevel: number;
  44401. /**
  44402. * Creates a mirror texture attach to the ground.
  44403. * false by default.
  44404. */
  44405. enableGroundMirror: boolean;
  44406. /**
  44407. * Specifies the ground mirror size ratio.
  44408. * 0.3 by default as the default kernel is 64.
  44409. */
  44410. groundMirrorSizeRatio: number;
  44411. /**
  44412. * Specifies the ground mirror blur kernel size.
  44413. * 64 by default.
  44414. */
  44415. groundMirrorBlurKernel: number;
  44416. /**
  44417. * Specifies the ground mirror visibility amount.
  44418. * 1 by default
  44419. */
  44420. groundMirrorAmount: number;
  44421. /**
  44422. * Specifies the ground mirror reflectance weight.
  44423. * This uses the standard weight of the background material to setup the fresnel effect
  44424. * of the mirror.
  44425. * 1 by default.
  44426. */
  44427. groundMirrorFresnelWeight: number;
  44428. /**
  44429. * Specifies the ground mirror Falloff distance.
  44430. * This can helps reducing the size of the reflection.
  44431. * 0 by Default.
  44432. */
  44433. groundMirrorFallOffDistance: number;
  44434. /**
  44435. * Specifies the ground mirror texture type.
  44436. * Unsigned Int by Default.
  44437. */
  44438. groundMirrorTextureType: number;
  44439. /**
  44440. * Specifies a bias applied to the ground vertical position to prevent z-fighting with
  44441. * the shown objects.
  44442. */
  44443. groundYBias: number;
  44444. /**
  44445. * Specifies wether or not to create a skybox.
  44446. * True by default.
  44447. */
  44448. createSkybox: boolean;
  44449. /**
  44450. * Specifies the skybox size.
  44451. * 20 by default.
  44452. */
  44453. skyboxSize: number;
  44454. /**
  44455. * The texture used on the skybox for the main color.
  44456. * Comes from the BabylonJS CDN by default.
  44457. *
  44458. * Remarks: Can be either a texture or a url.
  44459. */
  44460. skyboxTexture: string | BaseTexture;
  44461. /**
  44462. * The color mixed in the skybox texture by default.
  44463. * BabylonJS clearColor by default.
  44464. */
  44465. skyboxColor: Color3;
  44466. /**
  44467. * The background rotation around the Y axis of the scene.
  44468. * This helps aligning the key lights of your scene with the background.
  44469. * 0 by default.
  44470. */
  44471. backgroundYRotation: number;
  44472. /**
  44473. * Compute automatically the size of the elements to best fit with the scene.
  44474. */
  44475. sizeAuto: boolean;
  44476. /**
  44477. * Default position of the rootMesh if autoSize is not true.
  44478. */
  44479. rootPosition: Vector3;
  44480. /**
  44481. * Sets up the image processing in the scene.
  44482. * true by default.
  44483. */
  44484. setupImageProcessing: boolean;
  44485. /**
  44486. * The texture used as your environment texture in the scene.
  44487. * Comes from the BabylonJS CDN by default and in use if setupImageProcessing is true.
  44488. *
  44489. * Remarks: Can be either a texture or a url.
  44490. */
  44491. environmentTexture: string | BaseTexture;
  44492. /**
  44493. * The value of the exposure to apply to the scene.
  44494. * 0.6 by default if setupImageProcessing is true.
  44495. */
  44496. cameraExposure: number;
  44497. /**
  44498. * The value of the contrast to apply to the scene.
  44499. * 1.6 by default if setupImageProcessing is true.
  44500. */
  44501. cameraContrast: number;
  44502. /**
  44503. * Specifies wether or not tonemapping should be enabled in the scene.
  44504. * true by default if setupImageProcessing is true.
  44505. */
  44506. toneMappingEnabled: boolean;
  44507. }
  44508. /**
  44509. * The Environment helper class can be used to add a fully featuread none expensive background to your scene.
  44510. * It includes by default a skybox and a ground relying on the BackgroundMaterial.
  44511. * It also helps with the default setup of your imageProcessing configuration.
  44512. */
  44513. export class EnvironmentHelper {
  44514. /**
  44515. * Default ground texture URL.
  44516. */
  44517. private static _groundTextureCDNUrl;
  44518. /**
  44519. * Default skybox texture URL.
  44520. */
  44521. private static _skyboxTextureCDNUrl;
  44522. /**
  44523. * Default environment texture URL.
  44524. */
  44525. private static _environmentTextureCDNUrl;
  44526. /**
  44527. * Creates the default options for the helper.
  44528. */
  44529. private static _getDefaultOptions;
  44530. private _rootMesh;
  44531. /**
  44532. * Gets the root mesh created by the helper.
  44533. */
  44534. readonly rootMesh: Mesh;
  44535. private _skybox;
  44536. /**
  44537. * Gets the skybox created by the helper.
  44538. */
  44539. readonly skybox: Nullable<Mesh>;
  44540. private _skyboxTexture;
  44541. /**
  44542. * Gets the skybox texture created by the helper.
  44543. */
  44544. readonly skyboxTexture: Nullable<BaseTexture>;
  44545. private _skyboxMaterial;
  44546. /**
  44547. * Gets the skybox material created by the helper.
  44548. */
  44549. readonly skyboxMaterial: Nullable<BackgroundMaterial>;
  44550. private _ground;
  44551. /**
  44552. * Gets the ground mesh created by the helper.
  44553. */
  44554. readonly ground: Nullable<Mesh>;
  44555. private _groundTexture;
  44556. /**
  44557. * Gets the ground texture created by the helper.
  44558. */
  44559. readonly groundTexture: Nullable<BaseTexture>;
  44560. private _groundMirror;
  44561. /**
  44562. * Gets the ground mirror created by the helper.
  44563. */
  44564. readonly groundMirror: Nullable<MirrorTexture>;
  44565. /**
  44566. * Gets the ground mirror render list to helps pushing the meshes
  44567. * you wish in the ground reflection.
  44568. */
  44569. readonly groundMirrorRenderList: Nullable<AbstractMesh[]>;
  44570. private _groundMaterial;
  44571. /**
  44572. * Gets the ground material created by the helper.
  44573. */
  44574. readonly groundMaterial: Nullable<BackgroundMaterial>;
  44575. /**
  44576. * Stores the creation options.
  44577. */
  44578. private readonly _scene;
  44579. private _options;
  44580. /**
  44581. * This observable will be notified with any error during the creation of the environment,
  44582. * mainly texture creation errors.
  44583. */
  44584. onErrorObservable: Observable<{
  44585. message?: string;
  44586. exception?: any;
  44587. }>;
  44588. /**
  44589. * constructor
  44590. * @param options Defines the options we want to customize the helper
  44591. * @param scene The scene to add the material to
  44592. */
  44593. constructor(options: Partial<IEnvironmentHelperOptions>, scene: Scene);
  44594. /**
  44595. * Updates the background according to the new options
  44596. * @param options
  44597. */
  44598. updateOptions(options: Partial<IEnvironmentHelperOptions>): void;
  44599. /**
  44600. * Sets the primary color of all the available elements.
  44601. * @param color the main color to affect to the ground and the background
  44602. */
  44603. setMainColor(color: Color3): void;
  44604. /**
  44605. * Setup the image processing according to the specified options.
  44606. */
  44607. private _setupImageProcessing;
  44608. /**
  44609. * Setup the environment texture according to the specified options.
  44610. */
  44611. private _setupEnvironmentTexture;
  44612. /**
  44613. * Setup the background according to the specified options.
  44614. */
  44615. private _setupBackground;
  44616. /**
  44617. * Get the scene sizes according to the setup.
  44618. */
  44619. private _getSceneSize;
  44620. /**
  44621. * Setup the ground according to the specified options.
  44622. */
  44623. private _setupGround;
  44624. /**
  44625. * Setup the ground material according to the specified options.
  44626. */
  44627. private _setupGroundMaterial;
  44628. /**
  44629. * Setup the ground diffuse texture according to the specified options.
  44630. */
  44631. private _setupGroundDiffuseTexture;
  44632. /**
  44633. * Setup the ground mirror texture according to the specified options.
  44634. */
  44635. private _setupGroundMirrorTexture;
  44636. /**
  44637. * Setup the ground to receive the mirror texture.
  44638. */
  44639. private _setupMirrorInGroundMaterial;
  44640. /**
  44641. * Setup the skybox according to the specified options.
  44642. */
  44643. private _setupSkybox;
  44644. /**
  44645. * Setup the skybox material according to the specified options.
  44646. */
  44647. private _setupSkyboxMaterial;
  44648. /**
  44649. * Setup the skybox reflection texture according to the specified options.
  44650. */
  44651. private _setupSkyboxReflectionTexture;
  44652. private _errorHandler;
  44653. /**
  44654. * Dispose all the elements created by the Helper.
  44655. */
  44656. dispose(): void;
  44657. }
  44658. }
  44659. declare module "babylonjs/Helpers/photoDome" {
  44660. import { Observable } from "babylonjs/Misc/observable";
  44661. import { Nullable } from "babylonjs/types";
  44662. import { Scene } from "babylonjs/scene";
  44663. import { TransformNode } from "babylonjs/Meshes/transformNode";
  44664. import { Mesh } from "babylonjs/Meshes/mesh";
  44665. import { Texture } from "babylonjs/Materials/Textures/texture";
  44666. import { BackgroundMaterial } from "babylonjs/Materials/Background/backgroundMaterial";
  44667. import "babylonjs/Meshes/Builders/sphereBuilder";
  44668. /**
  44669. * Display a 360 degree photo on an approximately spherical surface, useful for VR applications or skyboxes.
  44670. * As a subclass of TransformNode, this allow parenting to the camera with different locations in the scene.
  44671. * This class achieves its effect with a Texture and a correctly configured BackgroundMaterial on an inverted sphere.
  44672. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  44673. */
  44674. export class PhotoDome extends TransformNode {
  44675. private _useDirectMapping;
  44676. /**
  44677. * The texture being displayed on the sphere
  44678. */
  44679. protected _photoTexture: Texture;
  44680. /**
  44681. * Gets or sets the texture being displayed on the sphere
  44682. */
  44683. photoTexture: Texture;
  44684. /**
  44685. * Observable raised when an error occured while loading the 360 image
  44686. */
  44687. onLoadErrorObservable: Observable<string>;
  44688. /**
  44689. * The skybox material
  44690. */
  44691. protected _material: BackgroundMaterial;
  44692. /**
  44693. * The surface used for the skybox
  44694. */
  44695. protected _mesh: Mesh;
  44696. /**
  44697. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  44698. * Also see the options.resolution property.
  44699. */
  44700. fovMultiplier: number;
  44701. /**
  44702. * Create an instance of this class and pass through the parameters to the relevant classes, Texture, StandardMaterial, and Mesh.
  44703. * @param name Element's name, child elements will append suffixes for their own names.
  44704. * @param urlsOfPhoto defines the url of the photo to display
  44705. * @param options defines an object containing optional or exposed sub element properties
  44706. * @param onError defines a callback called when an error occured while loading the texture
  44707. */
  44708. constructor(name: string, urlOfPhoto: string, options: {
  44709. resolution?: number;
  44710. size?: number;
  44711. useDirectMapping?: boolean;
  44712. faceForward?: boolean;
  44713. }, scene: Scene, onError?: Nullable<(message?: string, exception?: any) => void>);
  44714. /**
  44715. * Releases resources associated with this node.
  44716. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  44717. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  44718. */
  44719. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  44720. }
  44721. }
  44722. declare module "babylonjs/Misc/textureTools" {
  44723. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  44724. import { Texture } from "babylonjs/Materials/Textures/texture";
  44725. import { Scene } from "babylonjs/scene";
  44726. /**
  44727. * Class used to host texture specific utilities
  44728. */
  44729. export class TextureTools {
  44730. /**
  44731. * Uses the GPU to create a copy texture rescaled at a given size
  44732. * @param texture Texture to copy from
  44733. * @param width defines the desired width
  44734. * @param height defines the desired height
  44735. * @param useBilinearMode defines if bilinear mode has to be used
  44736. * @return the generated texture
  44737. */
  44738. static CreateResizedCopy(texture: Texture, width: number, height: number, useBilinearMode?: boolean): Texture;
  44739. /**
  44740. * Gets a default environment BRDF for MS-BRDF Height Correlated BRDF
  44741. * @param scene defines the hosting scene
  44742. * @returns the environment BRDF texture
  44743. */
  44744. static GetEnvironmentBRDFTexture(scene: Scene): BaseTexture;
  44745. private static _environmentBRDFBase64Texture;
  44746. }
  44747. }
  44748. declare module "babylonjs/Materials/PBR/pbrClearCoatConfiguration" {
  44749. import { Nullable } from "babylonjs/types";
  44750. import { IAnimatable } from "babylonjs/Misc/tools";
  44751. import { Color3 } from "babylonjs/Maths/math";
  44752. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  44753. import { EffectFallbacks } from "babylonjs/Materials/effect";
  44754. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  44755. import { Engine } from "babylonjs/Engines/engine";
  44756. import { Scene } from "babylonjs/scene";
  44757. /**
  44758. * @hidden
  44759. */
  44760. export interface IMaterialClearCoatDefines {
  44761. CLEARCOAT: boolean;
  44762. CLEARCOAT_DEFAULTIOR: boolean;
  44763. CLEARCOAT_TEXTURE: boolean;
  44764. CLEARCOAT_TEXTUREDIRECTUV: number;
  44765. CLEARCOAT_BUMP: boolean;
  44766. CLEARCOAT_BUMPDIRECTUV: number;
  44767. CLEARCOAT_TINT: boolean;
  44768. CLEARCOAT_TINT_TEXTURE: boolean;
  44769. CLEARCOAT_TINT_TEXTUREDIRECTUV: number;
  44770. /** @hidden */
  44771. _areTexturesDirty: boolean;
  44772. }
  44773. /**
  44774. * Define the code related to the clear coat parameters of the pbr material.
  44775. */
  44776. export class PBRClearCoatConfiguration {
  44777. /**
  44778. * This defaults to 1.5 corresponding to a 0.04 f0 or a 4% reflectance at normal incidence
  44779. * The default fits with a polyurethane material.
  44780. */
  44781. private static readonly _DefaultIndiceOfRefraction;
  44782. private _isEnabled;
  44783. /**
  44784. * Defines if the clear coat is enabled in the material.
  44785. */
  44786. isEnabled: boolean;
  44787. /**
  44788. * Defines the clear coat layer strength (between 0 and 1) it defaults to 1.
  44789. */
  44790. intensity: number;
  44791. /**
  44792. * Defines the clear coat layer roughness.
  44793. */
  44794. roughness: number;
  44795. private _indiceOfRefraction;
  44796. /**
  44797. * Defines the indice of refraction of the clear coat.
  44798. * This defaults to 1.5 corresponding to a 0.04 f0 or a 4% reflectance at normal incidence
  44799. * The default fits with a polyurethane material.
  44800. * Changing the default value is more performance intensive.
  44801. */
  44802. indiceOfRefraction: number;
  44803. private _texture;
  44804. /**
  44805. * Stores the clear coat values in a texture.
  44806. */
  44807. texture: Nullable<BaseTexture>;
  44808. private _bumpTexture;
  44809. /**
  44810. * Define the clear coat specific bump texture.
  44811. */
  44812. bumpTexture: Nullable<BaseTexture>;
  44813. private _isTintEnabled;
  44814. /**
  44815. * Defines if the clear coat tint is enabled in the material.
  44816. */
  44817. isTintEnabled: boolean;
  44818. /**
  44819. * Defines if the clear coat tint is enabled in the material.
  44820. * This is only use if tint is enabled
  44821. */
  44822. tintColor: Color3;
  44823. /**
  44824. * Defines if the distance at which the tint color should be found in the
  44825. * clear coat media.
  44826. * This is only use if tint is enabled
  44827. */
  44828. tintColorAtDistance: number;
  44829. /**
  44830. * Defines the clear coat layer thickness.
  44831. * This is only use if tint is enabled
  44832. */
  44833. tintThickness: number;
  44834. private _tintTexture;
  44835. /**
  44836. * Stores the clear tint values in a texture.
  44837. * rgb is tint
  44838. * a is a thickness factor
  44839. */
  44840. tintTexture: Nullable<BaseTexture>;
  44841. /** @hidden */
  44842. private _internalMarkAllSubMeshesAsTexturesDirty;
  44843. /** @hidden */
  44844. _markAllSubMeshesAsTexturesDirty(): void;
  44845. /**
  44846. * Instantiate a new istance of clear coat configuration.
  44847. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  44848. */
  44849. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  44850. /**
  44851. * Specifies that the submesh is ready to be used.
  44852. * @param defines the list of "defines" to update.
  44853. * @param scene defines the scene the material belongs to.
  44854. * @param engine defines the engine the material belongs to.
  44855. * @param disableBumpMap defines wether the material disables bump or not.
  44856. * @returns - boolean indicating that the submesh is ready or not.
  44857. */
  44858. isReadyForSubMesh(defines: IMaterialClearCoatDefines, scene: Scene, engine: Engine, disableBumpMap: boolean): boolean;
  44859. /**
  44860. * Checks to see if a texture is used in the material.
  44861. * @param defines the list of "defines" to update.
  44862. * @param scene defines the scene to the material belongs to.
  44863. */
  44864. prepareDefines(defines: IMaterialClearCoatDefines, scene: Scene): void;
  44865. /**
  44866. * Binds the material data.
  44867. * @param uniformBuffer defines the Uniform buffer to fill in.
  44868. * @param scene defines the scene the material belongs to.
  44869. * @param engine defines the engine the material belongs to.
  44870. * @param disableBumpMap defines wether the material disables bump or not.
  44871. * @param isFrozen defines wether the material is frozen or not.
  44872. * @param invertNormalMapX If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  44873. * @param invertNormalMapY If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  44874. */
  44875. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, engine: Engine, disableBumpMap: boolean, isFrozen: boolean, invertNormalMapX: boolean, invertNormalMapY: boolean): void;
  44876. /**
  44877. * Checks to see if a texture is used in the material.
  44878. * @param texture - Base texture to use.
  44879. * @returns - Boolean specifying if a texture is used in the material.
  44880. */
  44881. hasTexture(texture: BaseTexture): boolean;
  44882. /**
  44883. * Returns an array of the actively used textures.
  44884. * @param activeTextures Array of BaseTextures
  44885. */
  44886. getActiveTextures(activeTextures: BaseTexture[]): void;
  44887. /**
  44888. * Returns the animatable textures.
  44889. * @param animatables Array of animatable textures.
  44890. */
  44891. getAnimatables(animatables: IAnimatable[]): void;
  44892. /**
  44893. * Disposes the resources of the material.
  44894. * @param forceDisposeTextures - Forces the disposal of all textures.
  44895. */
  44896. dispose(forceDisposeTextures?: boolean): void;
  44897. /**
  44898. * Get the current class name of the texture useful for serialization or dynamic coding.
  44899. * @returns "PBRClearCoatConfiguration"
  44900. */
  44901. getClassName(): string;
  44902. /**
  44903. * Add fallbacks to the effect fallbacks list.
  44904. * @param defines defines the Base texture to use.
  44905. * @param fallbacks defines the current fallback list.
  44906. * @param currentRank defines the current fallback rank.
  44907. * @returns the new fallback rank.
  44908. */
  44909. static AddFallbacks(defines: IMaterialClearCoatDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  44910. /**
  44911. * Add the required uniforms to the current list.
  44912. * @param uniforms defines the current uniform list.
  44913. */
  44914. static AddUniforms(uniforms: string[]): void;
  44915. /**
  44916. * Add the required samplers to the current list.
  44917. * @param samplers defines the current sampler list.
  44918. */
  44919. static AddSamplers(samplers: string[]): void;
  44920. /**
  44921. * Add the required uniforms to the current buffer.
  44922. * @param uniformBuffer defines the current uniform buffer.
  44923. */
  44924. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  44925. /**
  44926. * Makes a duplicate of the current configuration into another one.
  44927. * @param clearCoatConfiguration define the config where to copy the info
  44928. */
  44929. copyTo(clearCoatConfiguration: PBRClearCoatConfiguration): void;
  44930. /**
  44931. * Serializes this clear coat configuration.
  44932. * @returns - An object with the serialized config.
  44933. */
  44934. serialize(): any;
  44935. /**
  44936. * Parses a Clear Coat Configuration from a serialized object.
  44937. * @param source - Serialized object.
  44938. */
  44939. parse(source: any): void;
  44940. }
  44941. }
  44942. declare module "babylonjs/Materials/PBR/pbrAnisotropicConfiguration" {
  44943. import { EffectFallbacks } from "babylonjs/Materials/effect";
  44944. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  44945. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  44946. import { Vector2 } from "babylonjs/Maths/math";
  44947. import { Scene } from "babylonjs/scene";
  44948. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  44949. import { IAnimatable } from "babylonjs/Misc/tools";
  44950. import { Nullable } from "babylonjs/types";
  44951. /**
  44952. * @hidden
  44953. */
  44954. export interface IMaterialAnisotropicDefines {
  44955. ANISOTROPIC: boolean;
  44956. ANISOTROPIC_TEXTURE: boolean;
  44957. ANISOTROPIC_TEXTUREDIRECTUV: number;
  44958. MAINUV1: boolean;
  44959. _areTexturesDirty: boolean;
  44960. _needUVs: boolean;
  44961. }
  44962. /**
  44963. * Define the code related to the anisotropic parameters of the pbr material.
  44964. */
  44965. export class PBRAnisotropicConfiguration {
  44966. private _isEnabled;
  44967. /**
  44968. * Defines if the anisotropy is enabled in the material.
  44969. */
  44970. isEnabled: boolean;
  44971. /**
  44972. * Defines the anisotropy strength (between 0 and 1) it defaults to 1.
  44973. */
  44974. intensity: number;
  44975. /**
  44976. * Defines if the effect is along the tangents, bitangents or in between.
  44977. * By default, the effect is "strectching" the highlights along the tangents.
  44978. */
  44979. direction: Vector2;
  44980. private _texture;
  44981. /**
  44982. * Stores the anisotropy values in a texture.
  44983. * rg is direction (like normal from -1 to 1)
  44984. * b is a intensity
  44985. */
  44986. texture: Nullable<BaseTexture>;
  44987. /** @hidden */
  44988. private _internalMarkAllSubMeshesAsTexturesDirty;
  44989. /** @hidden */
  44990. _markAllSubMeshesAsTexturesDirty(): void;
  44991. /**
  44992. * Instantiate a new istance of anisotropy configuration.
  44993. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  44994. */
  44995. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  44996. /**
  44997. * Specifies that the submesh is ready to be used.
  44998. * @param defines the list of "defines" to update.
  44999. * @param scene defines the scene the material belongs to.
  45000. * @returns - boolean indicating that the submesh is ready or not.
  45001. */
  45002. isReadyForSubMesh(defines: IMaterialAnisotropicDefines, scene: Scene): boolean;
  45003. /**
  45004. * Checks to see if a texture is used in the material.
  45005. * @param defines the list of "defines" to update.
  45006. * @param mesh the mesh we are preparing the defines for.
  45007. * @param scene defines the scene the material belongs to.
  45008. */
  45009. prepareDefines(defines: IMaterialAnisotropicDefines, mesh: AbstractMesh, scene: Scene): void;
  45010. /**
  45011. * Binds the material data.
  45012. * @param uniformBuffer defines the Uniform buffer to fill in.
  45013. * @param scene defines the scene the material belongs to.
  45014. * @param isFrozen defines wether the material is frozen or not.
  45015. */
  45016. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  45017. /**
  45018. * Checks to see if a texture is used in the material.
  45019. * @param texture - Base texture to use.
  45020. * @returns - Boolean specifying if a texture is used in the material.
  45021. */
  45022. hasTexture(texture: BaseTexture): boolean;
  45023. /**
  45024. * Returns an array of the actively used textures.
  45025. * @param activeTextures Array of BaseTextures
  45026. */
  45027. getActiveTextures(activeTextures: BaseTexture[]): void;
  45028. /**
  45029. * Returns the animatable textures.
  45030. * @param animatables Array of animatable textures.
  45031. */
  45032. getAnimatables(animatables: IAnimatable[]): void;
  45033. /**
  45034. * Disposes the resources of the material.
  45035. * @param forceDisposeTextures - Forces the disposal of all textures.
  45036. */
  45037. dispose(forceDisposeTextures?: boolean): void;
  45038. /**
  45039. * Get the current class name of the texture useful for serialization or dynamic coding.
  45040. * @returns "PBRAnisotropicConfiguration"
  45041. */
  45042. getClassName(): string;
  45043. /**
  45044. * Add fallbacks to the effect fallbacks list.
  45045. * @param defines defines the Base texture to use.
  45046. * @param fallbacks defines the current fallback list.
  45047. * @param currentRank defines the current fallback rank.
  45048. * @returns the new fallback rank.
  45049. */
  45050. static AddFallbacks(defines: IMaterialAnisotropicDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  45051. /**
  45052. * Add the required uniforms to the current list.
  45053. * @param uniforms defines the current uniform list.
  45054. */
  45055. static AddUniforms(uniforms: string[]): void;
  45056. /**
  45057. * Add the required uniforms to the current buffer.
  45058. * @param uniformBuffer defines the current uniform buffer.
  45059. */
  45060. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  45061. /**
  45062. * Add the required samplers to the current list.
  45063. * @param samplers defines the current sampler list.
  45064. */
  45065. static AddSamplers(samplers: string[]): void;
  45066. /**
  45067. * Makes a duplicate of the current configuration into another one.
  45068. * @param anisotropicConfiguration define the config where to copy the info
  45069. */
  45070. copyTo(anisotropicConfiguration: PBRAnisotropicConfiguration): void;
  45071. /**
  45072. * Serializes this anisotropy configuration.
  45073. * @returns - An object with the serialized config.
  45074. */
  45075. serialize(): any;
  45076. /**
  45077. * Parses a anisotropy Configuration from a serialized object.
  45078. * @param source - Serialized object.
  45079. */
  45080. parse(source: any): void;
  45081. }
  45082. }
  45083. declare module "babylonjs/Materials/PBR/pbrBRDFConfiguration" {
  45084. /**
  45085. * @hidden
  45086. */
  45087. export interface IMaterialBRDFDefines {
  45088. BRDF_V_HEIGHT_CORRELATED: boolean;
  45089. MS_BRDF_ENERGY_CONSERVATION: boolean;
  45090. /** @hidden */
  45091. _areMiscDirty: boolean;
  45092. }
  45093. /**
  45094. * Define the code related to the BRDF parameters of the pbr material.
  45095. */
  45096. export class PBRBRDFConfiguration {
  45097. private _useEnergyConservation;
  45098. /**
  45099. * Defines if the material uses energy conservation.
  45100. */
  45101. useEnergyConservation: boolean;
  45102. private _useSmithVisibilityHeightCorrelated;
  45103. /**
  45104. * LEGACY Mode set to false
  45105. * Defines if the material uses height smith correlated visibility term.
  45106. * If you intent to not use our default BRDF, you need to load a separate BRDF Texture for the PBR
  45107. * You can either load https://assets.babylonjs.com/environments/uncorrelatedBRDF.png
  45108. * or https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds to have more precision
  45109. * Not relying on height correlated will also disable energy conservation.
  45110. */
  45111. useSmithVisibilityHeightCorrelated: boolean;
  45112. /** @hidden */
  45113. private _internalMarkAllSubMeshesAsMiscDirty;
  45114. /** @hidden */
  45115. _markAllSubMeshesAsMiscDirty(): void;
  45116. /**
  45117. * Instantiate a new istance of clear coat configuration.
  45118. * @param markAllSubMeshesAsMiscDirty Callback to flag the material to dirty
  45119. */
  45120. constructor(markAllSubMeshesAsMiscDirty: () => void);
  45121. /**
  45122. * Checks to see if a texture is used in the material.
  45123. * @param defines the list of "defines" to update.
  45124. */
  45125. prepareDefines(defines: IMaterialBRDFDefines): void;
  45126. /**
  45127. * Get the current class name of the texture useful for serialization or dynamic coding.
  45128. * @returns "PBRClearCoatConfiguration"
  45129. */
  45130. getClassName(): string;
  45131. /**
  45132. * Makes a duplicate of the current configuration into another one.
  45133. * @param brdfConfiguration define the config where to copy the info
  45134. */
  45135. copyTo(brdfConfiguration: PBRBRDFConfiguration): void;
  45136. /**
  45137. * Serializes this BRDF configuration.
  45138. * @returns - An object with the serialized config.
  45139. */
  45140. serialize(): any;
  45141. /**
  45142. * Parses a BRDF Configuration from a serialized object.
  45143. * @param source - Serialized object.
  45144. */
  45145. parse(source: any): void;
  45146. }
  45147. }
  45148. declare module "babylonjs/Materials/PBR/pbrSheenConfiguration" {
  45149. import { EffectFallbacks } from "babylonjs/Materials/effect";
  45150. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  45151. import { Color3 } from "babylonjs/Maths/math";
  45152. import { Scene } from "babylonjs/scene";
  45153. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  45154. import { IAnimatable } from "babylonjs/Misc/tools";
  45155. import { Nullable } from "babylonjs/types";
  45156. /**
  45157. * @hidden
  45158. */
  45159. export interface IMaterialSheenDefines {
  45160. SHEEN: boolean;
  45161. SHEEN_TEXTURE: boolean;
  45162. SHEEN_TEXTUREDIRECTUV: number;
  45163. SHEEN_LINKWITHALBEDO: boolean;
  45164. /** @hidden */
  45165. _areTexturesDirty: boolean;
  45166. }
  45167. /**
  45168. * Define the code related to the Sheen parameters of the pbr material.
  45169. */
  45170. export class PBRSheenConfiguration {
  45171. private _isEnabled;
  45172. /**
  45173. * Defines if the material uses sheen.
  45174. */
  45175. isEnabled: boolean;
  45176. private _linkSheenWithAlbedo;
  45177. /**
  45178. * Defines if the sheen is linked to the sheen color.
  45179. */
  45180. linkSheenWithAlbedo: boolean;
  45181. /**
  45182. * Defines the sheen intensity.
  45183. */
  45184. intensity: number;
  45185. /**
  45186. * Defines the sheen color.
  45187. */
  45188. color: Color3;
  45189. private _texture;
  45190. /**
  45191. * Stores the sheen tint values in a texture.
  45192. * rgb is tint
  45193. * a is a intensity
  45194. */
  45195. texture: Nullable<BaseTexture>;
  45196. /** @hidden */
  45197. private _internalMarkAllSubMeshesAsTexturesDirty;
  45198. /** @hidden */
  45199. _markAllSubMeshesAsTexturesDirty(): void;
  45200. /**
  45201. * Instantiate a new istance of clear coat configuration.
  45202. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  45203. */
  45204. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  45205. /**
  45206. * Specifies that the submesh is ready to be used.
  45207. * @param defines the list of "defines" to update.
  45208. * @param scene defines the scene the material belongs to.
  45209. * @returns - boolean indicating that the submesh is ready or not.
  45210. */
  45211. isReadyForSubMesh(defines: IMaterialSheenDefines, scene: Scene): boolean;
  45212. /**
  45213. * Checks to see if a texture is used in the material.
  45214. * @param defines the list of "defines" to update.
  45215. * @param scene defines the scene the material belongs to.
  45216. */
  45217. prepareDefines(defines: IMaterialSheenDefines, scene: Scene): void;
  45218. /**
  45219. * Binds the material data.
  45220. * @param uniformBuffer defines the Uniform buffer to fill in.
  45221. * @param scene defines the scene the material belongs to.
  45222. * @param isFrozen defines wether the material is frozen or not.
  45223. */
  45224. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  45225. /**
  45226. * Checks to see if a texture is used in the material.
  45227. * @param texture - Base texture to use.
  45228. * @returns - Boolean specifying if a texture is used in the material.
  45229. */
  45230. hasTexture(texture: BaseTexture): boolean;
  45231. /**
  45232. * Returns an array of the actively used textures.
  45233. * @param activeTextures Array of BaseTextures
  45234. */
  45235. getActiveTextures(activeTextures: BaseTexture[]): void;
  45236. /**
  45237. * Returns the animatable textures.
  45238. * @param animatables Array of animatable textures.
  45239. */
  45240. getAnimatables(animatables: IAnimatable[]): void;
  45241. /**
  45242. * Disposes the resources of the material.
  45243. * @param forceDisposeTextures - Forces the disposal of all textures.
  45244. */
  45245. dispose(forceDisposeTextures?: boolean): void;
  45246. /**
  45247. * Get the current class name of the texture useful for serialization or dynamic coding.
  45248. * @returns "PBRSheenConfiguration"
  45249. */
  45250. getClassName(): string;
  45251. /**
  45252. * Add fallbacks to the effect fallbacks list.
  45253. * @param defines defines the Base texture to use.
  45254. * @param fallbacks defines the current fallback list.
  45255. * @param currentRank defines the current fallback rank.
  45256. * @returns the new fallback rank.
  45257. */
  45258. static AddFallbacks(defines: IMaterialSheenDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  45259. /**
  45260. * Add the required uniforms to the current list.
  45261. * @param uniforms defines the current uniform list.
  45262. */
  45263. static AddUniforms(uniforms: string[]): void;
  45264. /**
  45265. * Add the required uniforms to the current buffer.
  45266. * @param uniformBuffer defines the current uniform buffer.
  45267. */
  45268. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  45269. /**
  45270. * Add the required samplers to the current list.
  45271. * @param samplers defines the current sampler list.
  45272. */
  45273. static AddSamplers(samplers: string[]): void;
  45274. /**
  45275. * Makes a duplicate of the current configuration into another one.
  45276. * @param sheenConfiguration define the config where to copy the info
  45277. */
  45278. copyTo(sheenConfiguration: PBRSheenConfiguration): void;
  45279. /**
  45280. * Serializes this BRDF configuration.
  45281. * @returns - An object with the serialized config.
  45282. */
  45283. serialize(): any;
  45284. /**
  45285. * Parses a Sheen Configuration from a serialized object.
  45286. * @param source - Serialized object.
  45287. */
  45288. parse(source: any): void;
  45289. }
  45290. }
  45291. declare module "babylonjs/Shaders/ShadersInclude/pbrFragmentDeclaration" {
  45292. /** @hidden */
  45293. export var pbrFragmentDeclaration: {
  45294. name: string;
  45295. shader: string;
  45296. };
  45297. }
  45298. declare module "babylonjs/Shaders/ShadersInclude/pbrUboDeclaration" {
  45299. /** @hidden */
  45300. export var pbrUboDeclaration: {
  45301. name: string;
  45302. shader: string;
  45303. };
  45304. }
  45305. declare module "babylonjs/Shaders/ShadersInclude/pbrFragmentExtraDeclaration" {
  45306. /** @hidden */
  45307. export var pbrFragmentExtraDeclaration: {
  45308. name: string;
  45309. shader: string;
  45310. };
  45311. }
  45312. declare module "babylonjs/Shaders/ShadersInclude/pbrFragmentSamplersDeclaration" {
  45313. /** @hidden */
  45314. export var pbrFragmentSamplersDeclaration: {
  45315. name: string;
  45316. shader: string;
  45317. };
  45318. }
  45319. declare module "babylonjs/Shaders/ShadersInclude/pbrHelperFunctions" {
  45320. /** @hidden */
  45321. export var pbrHelperFunctions: {
  45322. name: string;
  45323. shader: string;
  45324. };
  45325. }
  45326. declare module "babylonjs/Shaders/ShadersInclude/harmonicsFunctions" {
  45327. /** @hidden */
  45328. export var harmonicsFunctions: {
  45329. name: string;
  45330. shader: string;
  45331. };
  45332. }
  45333. declare module "babylonjs/Shaders/ShadersInclude/pbrDirectLightingSetupFunctions" {
  45334. /** @hidden */
  45335. export var pbrDirectLightingSetupFunctions: {
  45336. name: string;
  45337. shader: string;
  45338. };
  45339. }
  45340. declare module "babylonjs/Shaders/ShadersInclude/pbrDirectLightingFalloffFunctions" {
  45341. /** @hidden */
  45342. export var pbrDirectLightingFalloffFunctions: {
  45343. name: string;
  45344. shader: string;
  45345. };
  45346. }
  45347. declare module "babylonjs/Shaders/ShadersInclude/pbrBRDFFunctions" {
  45348. /** @hidden */
  45349. export var pbrBRDFFunctions: {
  45350. name: string;
  45351. shader: string;
  45352. };
  45353. }
  45354. declare module "babylonjs/Shaders/ShadersInclude/pbrDirectLightingFunctions" {
  45355. /** @hidden */
  45356. export var pbrDirectLightingFunctions: {
  45357. name: string;
  45358. shader: string;
  45359. };
  45360. }
  45361. declare module "babylonjs/Shaders/ShadersInclude/pbrIBLFunctions" {
  45362. /** @hidden */
  45363. export var pbrIBLFunctions: {
  45364. name: string;
  45365. shader: string;
  45366. };
  45367. }
  45368. declare module "babylonjs/Shaders/ShadersInclude/pbrDebug" {
  45369. /** @hidden */
  45370. export var pbrDebug: {
  45371. name: string;
  45372. shader: string;
  45373. };
  45374. }
  45375. declare module "babylonjs/Shaders/pbr.fragment" {
  45376. import "babylonjs/Shaders/ShadersInclude/pbrFragmentDeclaration";
  45377. import "babylonjs/Shaders/ShadersInclude/pbrUboDeclaration";
  45378. import "babylonjs/Shaders/ShadersInclude/pbrFragmentExtraDeclaration";
  45379. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  45380. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  45381. import "babylonjs/Shaders/ShadersInclude/pbrFragmentSamplersDeclaration";
  45382. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  45383. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration";
  45384. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  45385. import "babylonjs/Shaders/ShadersInclude/fogFragmentDeclaration";
  45386. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  45387. import "babylonjs/Shaders/ShadersInclude/pbrHelperFunctions";
  45388. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  45389. import "babylonjs/Shaders/ShadersInclude/shadowsFragmentFunctions";
  45390. import "babylonjs/Shaders/ShadersInclude/harmonicsFunctions";
  45391. import "babylonjs/Shaders/ShadersInclude/pbrDirectLightingSetupFunctions";
  45392. import "babylonjs/Shaders/ShadersInclude/pbrDirectLightingFalloffFunctions";
  45393. import "babylonjs/Shaders/ShadersInclude/pbrBRDFFunctions";
  45394. import "babylonjs/Shaders/ShadersInclude/pbrDirectLightingFunctions";
  45395. import "babylonjs/Shaders/ShadersInclude/pbrIBLFunctions";
  45396. import "babylonjs/Shaders/ShadersInclude/bumpFragmentFunctions";
  45397. import "babylonjs/Shaders/ShadersInclude/reflectionFunction";
  45398. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  45399. import "babylonjs/Shaders/ShadersInclude/bumpFragment";
  45400. import "babylonjs/Shaders/ShadersInclude/depthPrePass";
  45401. import "babylonjs/Shaders/ShadersInclude/lightFragment";
  45402. import "babylonjs/Shaders/ShadersInclude/logDepthFragment";
  45403. import "babylonjs/Shaders/ShadersInclude/fogFragment";
  45404. import "babylonjs/Shaders/ShadersInclude/pbrDebug";
  45405. /** @hidden */
  45406. export var pbrPixelShader: {
  45407. name: string;
  45408. shader: string;
  45409. };
  45410. }
  45411. declare module "babylonjs/Shaders/ShadersInclude/pbrVertexDeclaration" {
  45412. /** @hidden */
  45413. export var pbrVertexDeclaration: {
  45414. name: string;
  45415. shader: string;
  45416. };
  45417. }
  45418. declare module "babylonjs/Shaders/pbr.vertex" {
  45419. import "babylonjs/Shaders/ShadersInclude/pbrVertexDeclaration";
  45420. import "babylonjs/Shaders/ShadersInclude/pbrUboDeclaration";
  45421. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  45422. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  45423. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  45424. import "babylonjs/Shaders/ShadersInclude/harmonicsFunctions";
  45425. import "babylonjs/Shaders/ShadersInclude/bumpVertexDeclaration";
  45426. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration";
  45427. import "babylonjs/Shaders/ShadersInclude/fogVertexDeclaration";
  45428. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  45429. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  45430. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  45431. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  45432. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  45433. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  45434. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  45435. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  45436. import "babylonjs/Shaders/ShadersInclude/bumpVertex";
  45437. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  45438. import "babylonjs/Shaders/ShadersInclude/fogVertex";
  45439. import "babylonjs/Shaders/ShadersInclude/shadowsVertex";
  45440. import "babylonjs/Shaders/ShadersInclude/logDepthVertex";
  45441. /** @hidden */
  45442. export var pbrVertexShader: {
  45443. name: string;
  45444. shader: string;
  45445. };
  45446. }
  45447. declare module "babylonjs/Materials/PBR/pbrBaseMaterial" {
  45448. import { IAnimatable } from "babylonjs/Misc/tools";
  45449. import { Nullable } from "babylonjs/types";
  45450. import { Scene } from "babylonjs/scene";
  45451. import { Matrix, Color3 } from "babylonjs/Maths/math";
  45452. import { SubMesh } from "babylonjs/Meshes/subMesh";
  45453. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  45454. import { Mesh } from "babylonjs/Meshes/mesh";
  45455. import { PBRClearCoatConfiguration } from "babylonjs/Materials/PBR/pbrClearCoatConfiguration";
  45456. import { PBRAnisotropicConfiguration } from "babylonjs/Materials/PBR/pbrAnisotropicConfiguration";
  45457. import { PBRBRDFConfiguration } from "babylonjs/Materials/PBR/pbrBRDFConfiguration";
  45458. import { PBRSheenConfiguration } from "babylonjs/Materials/PBR/pbrSheenConfiguration";
  45459. import { ImageProcessingConfiguration } from "babylonjs/Materials/imageProcessingConfiguration";
  45460. import { Material } from "babylonjs/Materials/material";
  45461. import { PushMaterial } from "babylonjs/Materials/pushMaterial";
  45462. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  45463. import "babylonjs/Shaders/pbr.fragment";
  45464. import "babylonjs/Shaders/pbr.vertex";
  45465. /**
  45466. * The Physically based material base class of BJS.
  45467. *
  45468. * This offers the main features of a standard PBR material.
  45469. * For more information, please refer to the documentation :
  45470. * http://doc.babylonjs.com/extensions/Physically_Based_Rendering
  45471. */
  45472. export abstract class PBRBaseMaterial extends PushMaterial {
  45473. /**
  45474. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  45475. */
  45476. static readonly PBRMATERIAL_OPAQUE: number;
  45477. /**
  45478. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  45479. */
  45480. static readonly PBRMATERIAL_ALPHATEST: number;
  45481. /**
  45482. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  45483. */
  45484. static readonly PBRMATERIAL_ALPHABLEND: number;
  45485. /**
  45486. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  45487. * They are also discarded below the alpha cutoff threshold to improve performances.
  45488. */
  45489. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  45490. /**
  45491. * Defines the default value of how much AO map is occluding the analytical lights
  45492. * (point spot...).
  45493. */
  45494. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  45495. /**
  45496. * PBRMaterialLightFalloff Physical: light is falling off following the inverse squared distance law.
  45497. */
  45498. static readonly LIGHTFALLOFF_PHYSICAL: number;
  45499. /**
  45500. * PBRMaterialLightFalloff gltf: light is falling off as described in the gltf moving to PBR document
  45501. * to enhance interoperability with other engines.
  45502. */
  45503. static readonly LIGHTFALLOFF_GLTF: number;
  45504. /**
  45505. * PBRMaterialLightFalloff Standard: light is falling off like in the standard material
  45506. * to enhance interoperability with other materials.
  45507. */
  45508. static readonly LIGHTFALLOFF_STANDARD: number;
  45509. /**
  45510. * Intensity of the direct lights e.g. the four lights available in your scene.
  45511. * This impacts both the direct diffuse and specular highlights.
  45512. */
  45513. protected _directIntensity: number;
  45514. /**
  45515. * Intensity of the emissive part of the material.
  45516. * This helps controlling the emissive effect without modifying the emissive color.
  45517. */
  45518. protected _emissiveIntensity: number;
  45519. /**
  45520. * Intensity of the environment e.g. how much the environment will light the object
  45521. * either through harmonics for rough material or through the refelction for shiny ones.
  45522. */
  45523. protected _environmentIntensity: number;
  45524. /**
  45525. * This is a special control allowing the reduction of the specular highlights coming from the
  45526. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  45527. */
  45528. protected _specularIntensity: number;
  45529. /**
  45530. * This stores the direct, emissive, environment, and specular light intensities into a Vector4.
  45531. */
  45532. private _lightingInfos;
  45533. /**
  45534. * Debug Control allowing disabling the bump map on this material.
  45535. */
  45536. protected _disableBumpMap: boolean;
  45537. /**
  45538. * AKA Diffuse Texture in standard nomenclature.
  45539. */
  45540. protected _albedoTexture: BaseTexture;
  45541. /**
  45542. * AKA Occlusion Texture in other nomenclature.
  45543. */
  45544. protected _ambientTexture: BaseTexture;
  45545. /**
  45546. * AKA Occlusion Texture Intensity in other nomenclature.
  45547. */
  45548. protected _ambientTextureStrength: number;
  45549. /**
  45550. * Defines how much the AO map is occluding the analytical lights (point spot...).
  45551. * 1 means it completely occludes it
  45552. * 0 mean it has no impact
  45553. */
  45554. protected _ambientTextureImpactOnAnalyticalLights: number;
  45555. /**
  45556. * Stores the alpha values in a texture.
  45557. */
  45558. protected _opacityTexture: BaseTexture;
  45559. /**
  45560. * Stores the reflection values in a texture.
  45561. */
  45562. protected _reflectionTexture: BaseTexture;
  45563. /**
  45564. * Stores the refraction values in a texture.
  45565. */
  45566. protected _refractionTexture: BaseTexture;
  45567. /**
  45568. * Stores the emissive values in a texture.
  45569. */
  45570. protected _emissiveTexture: BaseTexture;
  45571. /**
  45572. * AKA Specular texture in other nomenclature.
  45573. */
  45574. protected _reflectivityTexture: BaseTexture;
  45575. /**
  45576. * Used to switch from specular/glossiness to metallic/roughness workflow.
  45577. */
  45578. protected _metallicTexture: BaseTexture;
  45579. /**
  45580. * Specifies the metallic scalar of the metallic/roughness workflow.
  45581. * Can also be used to scale the metalness values of the metallic texture.
  45582. */
  45583. protected _metallic: Nullable<number>;
  45584. /**
  45585. * Specifies the roughness scalar of the metallic/roughness workflow.
  45586. * Can also be used to scale the roughness values of the metallic texture.
  45587. */
  45588. protected _roughness: Nullable<number>;
  45589. /**
  45590. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  45591. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  45592. */
  45593. protected _microSurfaceTexture: BaseTexture;
  45594. /**
  45595. * Stores surface normal data used to displace a mesh in a texture.
  45596. */
  45597. protected _bumpTexture: BaseTexture;
  45598. /**
  45599. * Stores the pre-calculated light information of a mesh in a texture.
  45600. */
  45601. protected _lightmapTexture: BaseTexture;
  45602. /**
  45603. * The color of a material in ambient lighting.
  45604. */
  45605. protected _ambientColor: Color3;
  45606. /**
  45607. * AKA Diffuse Color in other nomenclature.
  45608. */
  45609. protected _albedoColor: Color3;
  45610. /**
  45611. * AKA Specular Color in other nomenclature.
  45612. */
  45613. protected _reflectivityColor: Color3;
  45614. /**
  45615. * The color applied when light is reflected from a material.
  45616. */
  45617. protected _reflectionColor: Color3;
  45618. /**
  45619. * The color applied when light is emitted from a material.
  45620. */
  45621. protected _emissiveColor: Color3;
  45622. /**
  45623. * AKA Glossiness in other nomenclature.
  45624. */
  45625. protected _microSurface: number;
  45626. /**
  45627. * source material index of refraction (IOR)' / 'destination material IOR.
  45628. */
  45629. protected _indexOfRefraction: number;
  45630. /**
  45631. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  45632. */
  45633. protected _invertRefractionY: boolean;
  45634. /**
  45635. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  45636. * Materials half opaque for instance using refraction could benefit from this control.
  45637. */
  45638. protected _linkRefractionWithTransparency: boolean;
  45639. /**
  45640. * Specifies that the material will use the light map as a show map.
  45641. */
  45642. protected _useLightmapAsShadowmap: boolean;
  45643. /**
  45644. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  45645. * makes the reflect vector face the model (under horizon).
  45646. */
  45647. protected _useHorizonOcclusion: boolean;
  45648. /**
  45649. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  45650. * too much the area relying on ambient texture to define their ambient occlusion.
  45651. */
  45652. protected _useRadianceOcclusion: boolean;
  45653. /**
  45654. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  45655. */
  45656. protected _useAlphaFromAlbedoTexture: boolean;
  45657. /**
  45658. * Specifies that the material will keeps the specular highlights over a transparent surface (only the most limunous ones).
  45659. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  45660. */
  45661. protected _useSpecularOverAlpha: boolean;
  45662. /**
  45663. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  45664. */
  45665. protected _useMicroSurfaceFromReflectivityMapAlpha: boolean;
  45666. /**
  45667. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  45668. */
  45669. protected _useRoughnessFromMetallicTextureAlpha: boolean;
  45670. /**
  45671. * Specifies if the metallic texture contains the roughness information in its green channel.
  45672. */
  45673. protected _useRoughnessFromMetallicTextureGreen: boolean;
  45674. /**
  45675. * Specifies if the metallic texture contains the metallness information in its blue channel.
  45676. */
  45677. protected _useMetallnessFromMetallicTextureBlue: boolean;
  45678. /**
  45679. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  45680. */
  45681. protected _useAmbientOcclusionFromMetallicTextureRed: boolean;
  45682. /**
  45683. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  45684. */
  45685. protected _useAmbientInGrayScale: boolean;
  45686. /**
  45687. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  45688. * The material will try to infer what glossiness each pixel should be.
  45689. */
  45690. protected _useAutoMicroSurfaceFromReflectivityMap: boolean;
  45691. /**
  45692. * Defines the falloff type used in this material.
  45693. * It by default is Physical.
  45694. */
  45695. protected _lightFalloff: number;
  45696. /**
  45697. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  45698. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  45699. */
  45700. protected _useRadianceOverAlpha: boolean;
  45701. /**
  45702. * Allows using an object space normal map (instead of tangent space).
  45703. */
  45704. protected _useObjectSpaceNormalMap: boolean;
  45705. /**
  45706. * Allows using the bump map in parallax mode.
  45707. */
  45708. protected _useParallax: boolean;
  45709. /**
  45710. * Allows using the bump map in parallax occlusion mode.
  45711. */
  45712. protected _useParallaxOcclusion: boolean;
  45713. /**
  45714. * Controls the scale bias of the parallax mode.
  45715. */
  45716. protected _parallaxScaleBias: number;
  45717. /**
  45718. * If sets to true, disables all the lights affecting the material.
  45719. */
  45720. protected _disableLighting: boolean;
  45721. /**
  45722. * Number of Simultaneous lights allowed on the material.
  45723. */
  45724. protected _maxSimultaneousLights: number;
  45725. /**
  45726. * If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  45727. */
  45728. protected _invertNormalMapX: boolean;
  45729. /**
  45730. * If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  45731. */
  45732. protected _invertNormalMapY: boolean;
  45733. /**
  45734. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  45735. */
  45736. protected _twoSidedLighting: boolean;
  45737. /**
  45738. * Defines the alpha limits in alpha test mode.
  45739. */
  45740. protected _alphaCutOff: number;
  45741. /**
  45742. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  45743. */
  45744. protected _forceAlphaTest: boolean;
  45745. /**
  45746. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  45747. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  45748. */
  45749. protected _useAlphaFresnel: boolean;
  45750. /**
  45751. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  45752. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  45753. */
  45754. protected _useLinearAlphaFresnel: boolean;
  45755. /**
  45756. * The transparency mode of the material.
  45757. */
  45758. protected _transparencyMode: Nullable<number>;
  45759. /**
  45760. * Specifies the environment BRDF texture used to comput the scale and offset roughness values
  45761. * from cos thetav and roughness:
  45762. * http://blog.selfshadow.com/publications/s2013-shading-course/karis/s2013_pbs_epic_notes_v2.pdf
  45763. */
  45764. protected _environmentBRDFTexture: Nullable<BaseTexture>;
  45765. /**
  45766. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  45767. */
  45768. protected _forceIrradianceInFragment: boolean;
  45769. /**
  45770. * Force normal to face away from face.
  45771. */
  45772. protected _forceNormalForward: boolean;
  45773. /**
  45774. * Enables specular anti aliasing in the PBR shader.
  45775. * It will both interacts on the Geometry for analytical and IBL lighting.
  45776. * It also prefilter the roughness map based on the bump values.
  45777. */
  45778. protected _enableSpecularAntiAliasing: boolean;
  45779. /**
  45780. * Default configuration related to image processing available in the PBR Material.
  45781. */
  45782. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  45783. /**
  45784. * Keep track of the image processing observer to allow dispose and replace.
  45785. */
  45786. private _imageProcessingObserver;
  45787. /**
  45788. * Attaches a new image processing configuration to the PBR Material.
  45789. * @param configuration
  45790. */
  45791. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  45792. /**
  45793. * Stores the available render targets.
  45794. */
  45795. private _renderTargets;
  45796. /**
  45797. * Sets the global ambient color for the material used in lighting calculations.
  45798. */
  45799. private _globalAmbientColor;
  45800. /**
  45801. * Enables the use of logarithmic depth buffers, which is good for wide depth buffers.
  45802. */
  45803. private _useLogarithmicDepth;
  45804. /**
  45805. * If set to true, no lighting calculations will be applied.
  45806. */
  45807. private _unlit;
  45808. private _debugMode;
  45809. /**
  45810. * @hidden
  45811. * This is reserved for the inspector.
  45812. * Defines the material debug mode.
  45813. * It helps seeing only some components of the material while troubleshooting.
  45814. */
  45815. debugMode: number;
  45816. /**
  45817. * @hidden
  45818. * This is reserved for the inspector.
  45819. * Specify from where on screen the debug mode should start.
  45820. * The value goes from -1 (full screen) to 1 (not visible)
  45821. * It helps with side by side comparison against the final render
  45822. * This defaults to -1
  45823. */
  45824. private debugLimit;
  45825. /**
  45826. * @hidden
  45827. * This is reserved for the inspector.
  45828. * As the default viewing range might not be enough (if the ambient is really small for instance)
  45829. * You can use the factor to better multiply the final value.
  45830. */
  45831. private debugFactor;
  45832. /**
  45833. * Defines the clear coat layer parameters for the material.
  45834. */
  45835. readonly clearCoat: PBRClearCoatConfiguration;
  45836. /**
  45837. * Defines the anisotropic parameters for the material.
  45838. */
  45839. readonly anisotropy: PBRAnisotropicConfiguration;
  45840. /**
  45841. * Defines the BRDF parameters for the material.
  45842. */
  45843. readonly brdf: PBRBRDFConfiguration;
  45844. /**
  45845. * Defines the Sheen parameters for the material.
  45846. */
  45847. readonly sheen: PBRSheenConfiguration;
  45848. /**
  45849. * Instantiates a new PBRMaterial instance.
  45850. *
  45851. * @param name The material name
  45852. * @param scene The scene the material will be use in.
  45853. */
  45854. constructor(name: string, scene: Scene);
  45855. /**
  45856. * Gets a boolean indicating that current material needs to register RTT
  45857. */
  45858. readonly hasRenderTargetTextures: boolean;
  45859. /**
  45860. * Gets the name of the material class.
  45861. */
  45862. getClassName(): string;
  45863. /**
  45864. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  45865. */
  45866. /**
  45867. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  45868. */
  45869. useLogarithmicDepth: boolean;
  45870. /**
  45871. * Gets the current transparency mode.
  45872. */
  45873. /**
  45874. * Sets the transparency mode of the material.
  45875. *
  45876. * | Value | Type | Description |
  45877. * | ----- | ----------------------------------- | ----------- |
  45878. * | 0 | OPAQUE | |
  45879. * | 1 | ALPHATEST | |
  45880. * | 2 | ALPHABLEND | |
  45881. * | 3 | ALPHATESTANDBLEND | |
  45882. *
  45883. */
  45884. transparencyMode: Nullable<number>;
  45885. /**
  45886. * Returns true if alpha blending should be disabled.
  45887. */
  45888. private readonly _disableAlphaBlending;
  45889. /**
  45890. * Specifies whether or not this material should be rendered in alpha blend mode.
  45891. */
  45892. needAlphaBlending(): boolean;
  45893. /**
  45894. * Specifies if the mesh will require alpha blending.
  45895. * @param mesh - BJS mesh.
  45896. */
  45897. needAlphaBlendingForMesh(mesh: AbstractMesh): boolean;
  45898. /**
  45899. * Specifies whether or not this material should be rendered in alpha test mode.
  45900. */
  45901. needAlphaTesting(): boolean;
  45902. /**
  45903. * Specifies whether or not the alpha value of the albedo texture should be used for alpha blending.
  45904. */
  45905. protected _shouldUseAlphaFromAlbedoTexture(): boolean;
  45906. /**
  45907. * Gets the texture used for the alpha test.
  45908. */
  45909. getAlphaTestTexture(): BaseTexture;
  45910. /**
  45911. * Specifies that the submesh is ready to be used.
  45912. * @param mesh - BJS mesh.
  45913. * @param subMesh - A submesh of the BJS mesh. Used to check if it is ready.
  45914. * @param useInstances - Specifies that instances should be used.
  45915. * @returns - boolean indicating that the submesh is ready or not.
  45916. */
  45917. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  45918. /**
  45919. * Specifies if the material uses metallic roughness workflow.
  45920. * @returns boolean specifiying if the material uses metallic roughness workflow.
  45921. */
  45922. isMetallicWorkflow(): boolean;
  45923. private _prepareEffect;
  45924. private _prepareDefines;
  45925. /**
  45926. * Force shader compilation
  45927. */
  45928. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<{
  45929. clipPlane: boolean;
  45930. }>): void;
  45931. /**
  45932. * Initializes the uniform buffer layout for the shader.
  45933. */
  45934. buildUniformLayout(): void;
  45935. /**
  45936. * Unbinds the textures.
  45937. */
  45938. unbind(): void;
  45939. /**
  45940. * Binds the submesh data.
  45941. * @param world - The world matrix.
  45942. * @param mesh - The BJS mesh.
  45943. * @param subMesh - A submesh of the BJS mesh.
  45944. */
  45945. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  45946. /**
  45947. * Returns the animatable textures.
  45948. * @returns - Array of animatable textures.
  45949. */
  45950. getAnimatables(): IAnimatable[];
  45951. /**
  45952. * Returns the texture used for reflections.
  45953. * @returns - Reflection texture if present. Otherwise, returns the environment texture.
  45954. */
  45955. private _getReflectionTexture;
  45956. /**
  45957. * Returns the texture used for refraction or null if none is used.
  45958. * @returns - Refection texture if present. If no refraction texture and refraction
  45959. * is linked with transparency, returns environment texture. Otherwise, returns null.
  45960. */
  45961. private _getRefractionTexture;
  45962. /**
  45963. * Returns an array of the actively used textures.
  45964. * @returns - Array of BaseTextures
  45965. */
  45966. getActiveTextures(): BaseTexture[];
  45967. /**
  45968. * Checks to see if a texture is used in the material.
  45969. * @param texture - Base texture to use.
  45970. * @returns - Boolean specifying if a texture is used in the material.
  45971. */
  45972. hasTexture(texture: BaseTexture): boolean;
  45973. /**
  45974. * Disposes the resources of the material.
  45975. * @param forceDisposeEffect - Forces the disposal of effects.
  45976. * @param forceDisposeTextures - Forces the disposal of all textures.
  45977. */
  45978. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  45979. }
  45980. }
  45981. declare module "babylonjs/Materials/PBR/pbrMaterial" {
  45982. import { Nullable } from "babylonjs/types";
  45983. import { Scene } from "babylonjs/scene";
  45984. import { Color3 } from "babylonjs/Maths/math";
  45985. import { ImageProcessingConfiguration } from "babylonjs/Materials/imageProcessingConfiguration";
  45986. import { ColorCurves } from "babylonjs/Materials/colorCurves";
  45987. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  45988. import { PBRBaseMaterial } from "babylonjs/Materials/PBR/pbrBaseMaterial";
  45989. /**
  45990. * The Physically based material of BJS.
  45991. *
  45992. * This offers the main features of a standard PBR material.
  45993. * For more information, please refer to the documentation :
  45994. * http://doc.babylonjs.com/extensions/Physically_Based_Rendering
  45995. */
  45996. export class PBRMaterial extends PBRBaseMaterial {
  45997. /**
  45998. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  45999. */
  46000. static readonly PBRMATERIAL_OPAQUE: number;
  46001. /**
  46002. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  46003. */
  46004. static readonly PBRMATERIAL_ALPHATEST: number;
  46005. /**
  46006. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  46007. */
  46008. static readonly PBRMATERIAL_ALPHABLEND: number;
  46009. /**
  46010. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  46011. * They are also discarded below the alpha cutoff threshold to improve performances.
  46012. */
  46013. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  46014. /**
  46015. * Defines the default value of how much AO map is occluding the analytical lights
  46016. * (point spot...).
  46017. */
  46018. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  46019. /**
  46020. * Intensity of the direct lights e.g. the four lights available in your scene.
  46021. * This impacts both the direct diffuse and specular highlights.
  46022. */
  46023. directIntensity: number;
  46024. /**
  46025. * Intensity of the emissive part of the material.
  46026. * This helps controlling the emissive effect without modifying the emissive color.
  46027. */
  46028. emissiveIntensity: number;
  46029. /**
  46030. * Intensity of the environment e.g. how much the environment will light the object
  46031. * either through harmonics for rough material or through the refelction for shiny ones.
  46032. */
  46033. environmentIntensity: number;
  46034. /**
  46035. * This is a special control allowing the reduction of the specular highlights coming from the
  46036. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  46037. */
  46038. specularIntensity: number;
  46039. /**
  46040. * Debug Control allowing disabling the bump map on this material.
  46041. */
  46042. disableBumpMap: boolean;
  46043. /**
  46044. * AKA Diffuse Texture in standard nomenclature.
  46045. */
  46046. albedoTexture: BaseTexture;
  46047. /**
  46048. * AKA Occlusion Texture in other nomenclature.
  46049. */
  46050. ambientTexture: BaseTexture;
  46051. /**
  46052. * AKA Occlusion Texture Intensity in other nomenclature.
  46053. */
  46054. ambientTextureStrength: number;
  46055. /**
  46056. * Defines how much the AO map is occluding the analytical lights (point spot...).
  46057. * 1 means it completely occludes it
  46058. * 0 mean it has no impact
  46059. */
  46060. ambientTextureImpactOnAnalyticalLights: number;
  46061. /**
  46062. * Stores the alpha values in a texture.
  46063. */
  46064. opacityTexture: BaseTexture;
  46065. /**
  46066. * Stores the reflection values in a texture.
  46067. */
  46068. reflectionTexture: Nullable<BaseTexture>;
  46069. /**
  46070. * Stores the emissive values in a texture.
  46071. */
  46072. emissiveTexture: BaseTexture;
  46073. /**
  46074. * AKA Specular texture in other nomenclature.
  46075. */
  46076. reflectivityTexture: BaseTexture;
  46077. /**
  46078. * Used to switch from specular/glossiness to metallic/roughness workflow.
  46079. */
  46080. metallicTexture: BaseTexture;
  46081. /**
  46082. * Specifies the metallic scalar of the metallic/roughness workflow.
  46083. * Can also be used to scale the metalness values of the metallic texture.
  46084. */
  46085. metallic: Nullable<number>;
  46086. /**
  46087. * Specifies the roughness scalar of the metallic/roughness workflow.
  46088. * Can also be used to scale the roughness values of the metallic texture.
  46089. */
  46090. roughness: Nullable<number>;
  46091. /**
  46092. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  46093. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  46094. */
  46095. microSurfaceTexture: BaseTexture;
  46096. /**
  46097. * Stores surface normal data used to displace a mesh in a texture.
  46098. */
  46099. bumpTexture: BaseTexture;
  46100. /**
  46101. * Stores the pre-calculated light information of a mesh in a texture.
  46102. */
  46103. lightmapTexture: BaseTexture;
  46104. /**
  46105. * Stores the refracted light information in a texture.
  46106. */
  46107. refractionTexture: BaseTexture;
  46108. /**
  46109. * The color of a material in ambient lighting.
  46110. */
  46111. ambientColor: Color3;
  46112. /**
  46113. * AKA Diffuse Color in other nomenclature.
  46114. */
  46115. albedoColor: Color3;
  46116. /**
  46117. * AKA Specular Color in other nomenclature.
  46118. */
  46119. reflectivityColor: Color3;
  46120. /**
  46121. * The color reflected from the material.
  46122. */
  46123. reflectionColor: Color3;
  46124. /**
  46125. * The color emitted from the material.
  46126. */
  46127. emissiveColor: Color3;
  46128. /**
  46129. * AKA Glossiness in other nomenclature.
  46130. */
  46131. microSurface: number;
  46132. /**
  46133. * source material index of refraction (IOR)' / 'destination material IOR.
  46134. */
  46135. indexOfRefraction: number;
  46136. /**
  46137. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  46138. */
  46139. invertRefractionY: boolean;
  46140. /**
  46141. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  46142. * Materials half opaque for instance using refraction could benefit from this control.
  46143. */
  46144. linkRefractionWithTransparency: boolean;
  46145. /**
  46146. * If true, the light map contains occlusion information instead of lighting info.
  46147. */
  46148. useLightmapAsShadowmap: boolean;
  46149. /**
  46150. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  46151. */
  46152. useAlphaFromAlbedoTexture: boolean;
  46153. /**
  46154. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  46155. */
  46156. forceAlphaTest: boolean;
  46157. /**
  46158. * Defines the alpha limits in alpha test mode.
  46159. */
  46160. alphaCutOff: number;
  46161. /**
  46162. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  46163. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  46164. */
  46165. useSpecularOverAlpha: boolean;
  46166. /**
  46167. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  46168. */
  46169. useMicroSurfaceFromReflectivityMapAlpha: boolean;
  46170. /**
  46171. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  46172. */
  46173. useRoughnessFromMetallicTextureAlpha: boolean;
  46174. /**
  46175. * Specifies if the metallic texture contains the roughness information in its green channel.
  46176. */
  46177. useRoughnessFromMetallicTextureGreen: boolean;
  46178. /**
  46179. * Specifies if the metallic texture contains the metallness information in its blue channel.
  46180. */
  46181. useMetallnessFromMetallicTextureBlue: boolean;
  46182. /**
  46183. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  46184. */
  46185. useAmbientOcclusionFromMetallicTextureRed: boolean;
  46186. /**
  46187. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  46188. */
  46189. useAmbientInGrayScale: boolean;
  46190. /**
  46191. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  46192. * The material will try to infer what glossiness each pixel should be.
  46193. */
  46194. useAutoMicroSurfaceFromReflectivityMap: boolean;
  46195. /**
  46196. * BJS is using an harcoded light falloff based on a manually sets up range.
  46197. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  46198. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  46199. */
  46200. /**
  46201. * BJS is using an harcoded light falloff based on a manually sets up range.
  46202. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  46203. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  46204. */
  46205. usePhysicalLightFalloff: boolean;
  46206. /**
  46207. * In order to support the falloff compatibility with gltf, a special mode has been added
  46208. * to reproduce the gltf light falloff.
  46209. */
  46210. /**
  46211. * In order to support the falloff compatibility with gltf, a special mode has been added
  46212. * to reproduce the gltf light falloff.
  46213. */
  46214. useGLTFLightFalloff: boolean;
  46215. /**
  46216. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  46217. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  46218. */
  46219. useRadianceOverAlpha: boolean;
  46220. /**
  46221. * Allows using an object space normal map (instead of tangent space).
  46222. */
  46223. useObjectSpaceNormalMap: boolean;
  46224. /**
  46225. * Allows using the bump map in parallax mode.
  46226. */
  46227. useParallax: boolean;
  46228. /**
  46229. * Allows using the bump map in parallax occlusion mode.
  46230. */
  46231. useParallaxOcclusion: boolean;
  46232. /**
  46233. * Controls the scale bias of the parallax mode.
  46234. */
  46235. parallaxScaleBias: number;
  46236. /**
  46237. * If sets to true, disables all the lights affecting the material.
  46238. */
  46239. disableLighting: boolean;
  46240. /**
  46241. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  46242. */
  46243. forceIrradianceInFragment: boolean;
  46244. /**
  46245. * Number of Simultaneous lights allowed on the material.
  46246. */
  46247. maxSimultaneousLights: number;
  46248. /**
  46249. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  46250. */
  46251. invertNormalMapX: boolean;
  46252. /**
  46253. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  46254. */
  46255. invertNormalMapY: boolean;
  46256. /**
  46257. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  46258. */
  46259. twoSidedLighting: boolean;
  46260. /**
  46261. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  46262. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  46263. */
  46264. useAlphaFresnel: boolean;
  46265. /**
  46266. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  46267. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  46268. */
  46269. useLinearAlphaFresnel: boolean;
  46270. /**
  46271. * Let user defines the brdf lookup texture used for IBL.
  46272. * A default 8bit version is embedded but you could point at :
  46273. * * Default texture: https://assets.babylonjs.com/environments/correlatedMSBRDF.png
  46274. * * Default 16bit pixel depth texture: https://assets.babylonjs.com/environments/correlatedMSBRDF.dds
  46275. * * LEGACY Default None correlated https://assets.babylonjs.com/environments/uncorrelatedBRDF.png
  46276. * * LEGACY Default None correlated 16bit pixel depth https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds
  46277. */
  46278. environmentBRDFTexture: Nullable<BaseTexture>;
  46279. /**
  46280. * Force normal to face away from face.
  46281. */
  46282. forceNormalForward: boolean;
  46283. /**
  46284. * Enables specular anti aliasing in the PBR shader.
  46285. * It will both interacts on the Geometry for analytical and IBL lighting.
  46286. * It also prefilter the roughness map based on the bump values.
  46287. */
  46288. enableSpecularAntiAliasing: boolean;
  46289. /**
  46290. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  46291. * makes the reflect vector face the model (under horizon).
  46292. */
  46293. useHorizonOcclusion: boolean;
  46294. /**
  46295. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  46296. * too much the area relying on ambient texture to define their ambient occlusion.
  46297. */
  46298. useRadianceOcclusion: boolean;
  46299. /**
  46300. * If set to true, no lighting calculations will be applied.
  46301. */
  46302. unlit: boolean;
  46303. /**
  46304. * Gets the image processing configuration used either in this material.
  46305. */
  46306. /**
  46307. * Sets the Default image processing configuration used either in the this material.
  46308. *
  46309. * If sets to null, the scene one is in use.
  46310. */
  46311. imageProcessingConfiguration: ImageProcessingConfiguration;
  46312. /**
  46313. * Gets wether the color curves effect is enabled.
  46314. */
  46315. /**
  46316. * Sets wether the color curves effect is enabled.
  46317. */
  46318. cameraColorCurvesEnabled: boolean;
  46319. /**
  46320. * Gets wether the color grading effect is enabled.
  46321. */
  46322. /**
  46323. * Gets wether the color grading effect is enabled.
  46324. */
  46325. cameraColorGradingEnabled: boolean;
  46326. /**
  46327. * Gets wether tonemapping is enabled or not.
  46328. */
  46329. /**
  46330. * Sets wether tonemapping is enabled or not
  46331. */
  46332. cameraToneMappingEnabled: boolean;
  46333. /**
  46334. * The camera exposure used on this material.
  46335. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  46336. * This corresponds to a photographic exposure.
  46337. */
  46338. /**
  46339. * The camera exposure used on this material.
  46340. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  46341. * This corresponds to a photographic exposure.
  46342. */
  46343. cameraExposure: number;
  46344. /**
  46345. * Gets The camera contrast used on this material.
  46346. */
  46347. /**
  46348. * Sets The camera contrast used on this material.
  46349. */
  46350. cameraContrast: number;
  46351. /**
  46352. * Gets the Color Grading 2D Lookup Texture.
  46353. */
  46354. /**
  46355. * Sets the Color Grading 2D Lookup Texture.
  46356. */
  46357. cameraColorGradingTexture: Nullable<BaseTexture>;
  46358. /**
  46359. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  46360. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  46361. * 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;
  46362. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  46363. */
  46364. /**
  46365. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  46366. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  46367. * 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;
  46368. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  46369. */
  46370. cameraColorCurves: Nullable<ColorCurves>;
  46371. /**
  46372. * Instantiates a new PBRMaterial instance.
  46373. *
  46374. * @param name The material name
  46375. * @param scene The scene the material will be use in.
  46376. */
  46377. constructor(name: string, scene: Scene);
  46378. /**
  46379. * Returns the name of this material class.
  46380. */
  46381. getClassName(): string;
  46382. /**
  46383. * Makes a duplicate of the current material.
  46384. * @param name - name to use for the new material.
  46385. */
  46386. clone(name: string): PBRMaterial;
  46387. /**
  46388. * Serializes this PBR Material.
  46389. * @returns - An object with the serialized material.
  46390. */
  46391. serialize(): any;
  46392. /**
  46393. * Parses a PBR Material from a serialized object.
  46394. * @param source - Serialized object.
  46395. * @param scene - BJS scene instance.
  46396. * @param rootUrl - url for the scene object
  46397. * @returns - PBRMaterial
  46398. */
  46399. static Parse(source: any, scene: Scene, rootUrl: string): PBRMaterial;
  46400. }
  46401. }
  46402. declare module "babylonjs/Misc/dds" {
  46403. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  46404. import { Engine } from "babylonjs/Engines/engine";
  46405. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  46406. import { Nullable } from "babylonjs/types";
  46407. import { Scene } from "babylonjs/scene";
  46408. /**
  46409. * Direct draw surface info
  46410. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dx-graphics-dds-pguide
  46411. */
  46412. export interface DDSInfo {
  46413. /**
  46414. * Width of the texture
  46415. */
  46416. width: number;
  46417. /**
  46418. * Width of the texture
  46419. */
  46420. height: number;
  46421. /**
  46422. * Number of Mipmaps for the texture
  46423. * @see https://en.wikipedia.org/wiki/Mipmap
  46424. */
  46425. mipmapCount: number;
  46426. /**
  46427. * If the textures format is a known fourCC format
  46428. * @see https://www.fourcc.org/
  46429. */
  46430. isFourCC: boolean;
  46431. /**
  46432. * If the texture is an RGB format eg. DXGI_FORMAT_B8G8R8X8_UNORM format
  46433. */
  46434. isRGB: boolean;
  46435. /**
  46436. * If the texture is a lumincance format
  46437. */
  46438. isLuminance: boolean;
  46439. /**
  46440. * If this is a cube texture
  46441. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dds-file-layout-for-cubic-environment-maps
  46442. */
  46443. isCube: boolean;
  46444. /**
  46445. * If the texture is a compressed format eg. FOURCC_DXT1
  46446. */
  46447. isCompressed: boolean;
  46448. /**
  46449. * The dxgiFormat of the texture
  46450. * @see https://docs.microsoft.com/en-us/windows/desktop/api/dxgiformat/ne-dxgiformat-dxgi_format
  46451. */
  46452. dxgiFormat: number;
  46453. /**
  46454. * Texture type eg. Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT
  46455. */
  46456. textureType: number;
  46457. /**
  46458. * Sphericle polynomial created for the dds texture
  46459. */
  46460. sphericalPolynomial?: SphericalPolynomial;
  46461. }
  46462. /**
  46463. * Class used to provide DDS decompression tools
  46464. */
  46465. export class DDSTools {
  46466. /**
  46467. * Gets or sets a boolean indicating that LOD info is stored in alpha channel (false by default)
  46468. */
  46469. static StoreLODInAlphaChannel: boolean;
  46470. /**
  46471. * Gets DDS information from an array buffer
  46472. * @param arrayBuffer defines the array buffer to read data from
  46473. * @returns the DDS information
  46474. */
  46475. static GetDDSInfo(arrayBuffer: any): DDSInfo;
  46476. private static _FloatView;
  46477. private static _Int32View;
  46478. private static _ToHalfFloat;
  46479. private static _FromHalfFloat;
  46480. private static _GetHalfFloatAsFloatRGBAArrayBuffer;
  46481. private static _GetHalfFloatRGBAArrayBuffer;
  46482. private static _GetFloatRGBAArrayBuffer;
  46483. private static _GetFloatAsUIntRGBAArrayBuffer;
  46484. private static _GetHalfFloatAsUIntRGBAArrayBuffer;
  46485. private static _GetRGBAArrayBuffer;
  46486. private static _ExtractLongWordOrder;
  46487. private static _GetRGBArrayBuffer;
  46488. private static _GetLuminanceArrayBuffer;
  46489. /**
  46490. * Uploads DDS Levels to a Babylon Texture
  46491. * @hidden
  46492. */
  46493. static UploadDDSLevels(engine: Engine, texture: InternalTexture, arrayBuffer: any, info: DDSInfo, loadMipmaps: boolean, faces: number, lodIndex?: number, currentFace?: number): void;
  46494. }
  46495. module "babylonjs/Engines/engine" {
  46496. interface Engine {
  46497. /**
  46498. * Create a cube texture from prefiltered data (ie. the mipmaps contain ready to use data for PBR reflection)
  46499. * @param rootUrl defines the url where the file to load is located
  46500. * @param scene defines the current scene
  46501. * @param lodScale defines scale to apply to the mip map selection
  46502. * @param lodOffset defines offset to apply to the mip map selection
  46503. * @param onLoad defines an optional callback raised when the texture is loaded
  46504. * @param onError defines an optional callback raised if there is an issue to load the texture
  46505. * @param format defines the format of the data
  46506. * @param forcedExtension defines the extension to use to pick the right loader
  46507. * @param createPolynomials defines wheter or not to create polynomails harmonics for the texture
  46508. * @returns the cube texture as an InternalTexture
  46509. */
  46510. 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;
  46511. }
  46512. }
  46513. }
  46514. declare module "babylonjs/Materials/Textures/Loaders/ddsTextureLoader" {
  46515. import { Nullable } from "babylonjs/types";
  46516. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  46517. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  46518. /**
  46519. * Implementation of the DDS Texture Loader.
  46520. * @hidden
  46521. */
  46522. export class _DDSTextureLoader implements IInternalTextureLoader {
  46523. /**
  46524. * Defines wether the loader supports cascade loading the different faces.
  46525. */
  46526. readonly supportCascades: boolean;
  46527. /**
  46528. * This returns if the loader support the current file information.
  46529. * @param extension defines the file extension of the file being loaded
  46530. * @param textureFormatInUse defines the current compressed format in use iun the engine
  46531. * @param fallback defines the fallback internal texture if any
  46532. * @param isBase64 defines whether the texture is encoded as a base64
  46533. * @param isBuffer defines whether the texture data are stored as a buffer
  46534. * @returns true if the loader can load the specified file
  46535. */
  46536. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  46537. /**
  46538. * Transform the url before loading if required.
  46539. * @param rootUrl the url of the texture
  46540. * @param textureFormatInUse defines the current compressed format in use iun the engine
  46541. * @returns the transformed texture
  46542. */
  46543. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  46544. /**
  46545. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  46546. * @param rootUrl the url of the texture
  46547. * @param textureFormatInUse defines the current compressed format in use iun the engine
  46548. * @returns the fallback texture
  46549. */
  46550. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  46551. /**
  46552. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  46553. * @param data contains the texture data
  46554. * @param texture defines the BabylonJS internal texture
  46555. * @param createPolynomials will be true if polynomials have been requested
  46556. * @param onLoad defines the callback to trigger once the texture is ready
  46557. * @param onError defines the callback to trigger in case of error
  46558. */
  46559. loadCubeData(imgs: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  46560. /**
  46561. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  46562. * @param data contains the texture data
  46563. * @param texture defines the BabylonJS internal texture
  46564. * @param callback defines the method to call once ready to upload
  46565. */
  46566. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  46567. }
  46568. }
  46569. declare module "babylonjs/Shaders/rgbdEncode.fragment" {
  46570. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  46571. /** @hidden */
  46572. export var rgbdEncodePixelShader: {
  46573. name: string;
  46574. shader: string;
  46575. };
  46576. }
  46577. declare module "babylonjs/Shaders/rgbdDecode.fragment" {
  46578. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  46579. /** @hidden */
  46580. export var rgbdDecodePixelShader: {
  46581. name: string;
  46582. shader: string;
  46583. };
  46584. }
  46585. declare module "babylonjs/Misc/environmentTextureTools" {
  46586. import { Nullable } from "babylonjs/types";
  46587. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  46588. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  46589. import { CubeTexture } from "babylonjs/Materials/Textures/cubeTexture";
  46590. import "babylonjs/Shaders/rgbdEncode.fragment";
  46591. import "babylonjs/Shaders/rgbdDecode.fragment";
  46592. /**
  46593. * Raw texture data and descriptor sufficient for WebGL texture upload
  46594. */
  46595. export interface EnvironmentTextureInfo {
  46596. /**
  46597. * Version of the environment map
  46598. */
  46599. version: number;
  46600. /**
  46601. * Width of image
  46602. */
  46603. width: number;
  46604. /**
  46605. * Irradiance information stored in the file.
  46606. */
  46607. irradiance: any;
  46608. /**
  46609. * Specular information stored in the file.
  46610. */
  46611. specular: any;
  46612. }
  46613. /**
  46614. * Sets of helpers addressing the serialization and deserialization of environment texture
  46615. * stored in a BabylonJS env file.
  46616. * Those files are usually stored as .env files.
  46617. */
  46618. export class EnvironmentTextureTools {
  46619. /**
  46620. * Magic number identifying the env file.
  46621. */
  46622. private static _MagicBytes;
  46623. /**
  46624. * Gets the environment info from an env file.
  46625. * @param data The array buffer containing the .env bytes.
  46626. * @returns the environment file info (the json header) if successfully parsed.
  46627. */
  46628. static GetEnvInfo(data: ArrayBuffer): Nullable<EnvironmentTextureInfo>;
  46629. /**
  46630. * Creates an environment texture from a loaded cube texture.
  46631. * @param texture defines the cube texture to convert in env file
  46632. * @return a promise containing the environment data if succesfull.
  46633. */
  46634. static CreateEnvTextureAsync(texture: CubeTexture): Promise<ArrayBuffer>;
  46635. /**
  46636. * Creates a JSON representation of the spherical data.
  46637. * @param texture defines the texture containing the polynomials
  46638. * @return the JSON representation of the spherical info
  46639. */
  46640. private static _CreateEnvTextureIrradiance;
  46641. /**
  46642. * Uploads the texture info contained in the env file to the GPU.
  46643. * @param texture defines the internal texture to upload to
  46644. * @param arrayBuffer defines the buffer cotaining the data to load
  46645. * @param info defines the texture info retrieved through the GetEnvInfo method
  46646. * @returns a promise
  46647. */
  46648. static UploadEnvLevelsAsync(texture: InternalTexture, arrayBuffer: any, info: EnvironmentTextureInfo): Promise<void>;
  46649. /**
  46650. * Uploads the levels of image data to the GPU.
  46651. * @param texture defines the internal texture to upload to
  46652. * @param imageData defines the array buffer views of image data [mipmap][face]
  46653. * @returns a promise
  46654. */
  46655. static UploadLevelsAsync(texture: InternalTexture, imageData: ArrayBufferView[][]): Promise<void>;
  46656. /**
  46657. * Uploads spherical polynomials information to the texture.
  46658. * @param texture defines the texture we are trying to upload the information to
  46659. * @param info defines the environment texture info retrieved through the GetEnvInfo method
  46660. */
  46661. static UploadEnvSpherical(texture: InternalTexture, info: EnvironmentTextureInfo): void;
  46662. /** @hidden */
  46663. static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  46664. }
  46665. }
  46666. declare module "babylonjs/Materials/Textures/Loaders/envTextureLoader" {
  46667. import { Nullable } from "babylonjs/types";
  46668. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  46669. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  46670. /**
  46671. * Implementation of the ENV Texture Loader.
  46672. * @hidden
  46673. */
  46674. export class _ENVTextureLoader implements IInternalTextureLoader {
  46675. /**
  46676. * Defines wether the loader supports cascade loading the different faces.
  46677. */
  46678. readonly supportCascades: boolean;
  46679. /**
  46680. * This returns if the loader support the current file information.
  46681. * @param extension defines the file extension of the file being loaded
  46682. * @param textureFormatInUse defines the current compressed format in use iun the engine
  46683. * @param fallback defines the fallback internal texture if any
  46684. * @param isBase64 defines whether the texture is encoded as a base64
  46685. * @param isBuffer defines whether the texture data are stored as a buffer
  46686. * @returns true if the loader can load the specified file
  46687. */
  46688. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  46689. /**
  46690. * Transform the url before loading if required.
  46691. * @param rootUrl the url of the texture
  46692. * @param textureFormatInUse defines the current compressed format in use iun the engine
  46693. * @returns the transformed texture
  46694. */
  46695. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  46696. /**
  46697. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  46698. * @param rootUrl the url of the texture
  46699. * @param textureFormatInUse defines the current compressed format in use iun the engine
  46700. * @returns the fallback texture
  46701. */
  46702. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  46703. /**
  46704. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  46705. * @param data contains the texture data
  46706. * @param texture defines the BabylonJS internal texture
  46707. * @param createPolynomials will be true if polynomials have been requested
  46708. * @param onLoad defines the callback to trigger once the texture is ready
  46709. * @param onError defines the callback to trigger in case of error
  46710. */
  46711. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  46712. /**
  46713. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  46714. * @param data contains the texture data
  46715. * @param texture defines the BabylonJS internal texture
  46716. * @param callback defines the method to call once ready to upload
  46717. */
  46718. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  46719. }
  46720. }
  46721. declare module "babylonjs/Misc/khronosTextureContainer" {
  46722. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  46723. /**
  46724. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  46725. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  46726. */
  46727. export class KhronosTextureContainer {
  46728. /** contents of the KTX container file */
  46729. arrayBuffer: any;
  46730. private static HEADER_LEN;
  46731. private static COMPRESSED_2D;
  46732. private static COMPRESSED_3D;
  46733. private static TEX_2D;
  46734. private static TEX_3D;
  46735. /**
  46736. * Gets the openGL type
  46737. */
  46738. glType: number;
  46739. /**
  46740. * Gets the openGL type size
  46741. */
  46742. glTypeSize: number;
  46743. /**
  46744. * Gets the openGL format
  46745. */
  46746. glFormat: number;
  46747. /**
  46748. * Gets the openGL internal format
  46749. */
  46750. glInternalFormat: number;
  46751. /**
  46752. * Gets the base internal format
  46753. */
  46754. glBaseInternalFormat: number;
  46755. /**
  46756. * Gets image width in pixel
  46757. */
  46758. pixelWidth: number;
  46759. /**
  46760. * Gets image height in pixel
  46761. */
  46762. pixelHeight: number;
  46763. /**
  46764. * Gets image depth in pixels
  46765. */
  46766. pixelDepth: number;
  46767. /**
  46768. * Gets the number of array elements
  46769. */
  46770. numberOfArrayElements: number;
  46771. /**
  46772. * Gets the number of faces
  46773. */
  46774. numberOfFaces: number;
  46775. /**
  46776. * Gets the number of mipmap levels
  46777. */
  46778. numberOfMipmapLevels: number;
  46779. /**
  46780. * Gets the bytes of key value data
  46781. */
  46782. bytesOfKeyValueData: number;
  46783. /**
  46784. * Gets the load type
  46785. */
  46786. loadType: number;
  46787. /**
  46788. * If the container has been made invalid (eg. constructor failed to correctly load array buffer)
  46789. */
  46790. isInvalid: boolean;
  46791. /**
  46792. * Creates a new KhronosTextureContainer
  46793. * @param arrayBuffer contents of the KTX container file
  46794. * @param facesExpected should be either 1 or 6, based whether a cube texture or or
  46795. * @param threeDExpected provision for indicating that data should be a 3D texture, not implemented
  46796. * @param textureArrayExpected provision for indicating that data should be a texture array, not implemented
  46797. */
  46798. constructor(
  46799. /** contents of the KTX container file */
  46800. arrayBuffer: any, facesExpected: number, threeDExpected?: boolean, textureArrayExpected?: boolean);
  46801. /**
  46802. * Uploads KTX content to a Babylon Texture.
  46803. * It is assumed that the texture has already been created & is currently bound
  46804. * @hidden
  46805. */
  46806. uploadLevels(texture: InternalTexture, loadMipmaps: boolean): void;
  46807. private _upload2DCompressedLevels;
  46808. }
  46809. }
  46810. declare module "babylonjs/Materials/Textures/Loaders/ktxTextureLoader" {
  46811. import { Nullable } from "babylonjs/types";
  46812. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  46813. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  46814. /**
  46815. * Implementation of the KTX Texture Loader.
  46816. * @hidden
  46817. */
  46818. export class _KTXTextureLoader implements IInternalTextureLoader {
  46819. /**
  46820. * Defines wether the loader supports cascade loading the different faces.
  46821. */
  46822. readonly supportCascades: boolean;
  46823. /**
  46824. * This returns if the loader support the current file information.
  46825. * @param extension defines the file extension of the file being loaded
  46826. * @param textureFormatInUse defines the current compressed format in use iun the engine
  46827. * @param fallback defines the fallback internal texture if any
  46828. * @param isBase64 defines whether the texture is encoded as a base64
  46829. * @param isBuffer defines whether the texture data are stored as a buffer
  46830. * @returns true if the loader can load the specified file
  46831. */
  46832. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  46833. /**
  46834. * Transform the url before loading if required.
  46835. * @param rootUrl the url of the texture
  46836. * @param textureFormatInUse defines the current compressed format in use iun the engine
  46837. * @returns the transformed texture
  46838. */
  46839. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  46840. /**
  46841. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  46842. * @param rootUrl the url of the texture
  46843. * @param textureFormatInUse defines the current compressed format in use iun the engine
  46844. * @returns the fallback texture
  46845. */
  46846. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  46847. /**
  46848. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  46849. * @param data contains the texture data
  46850. * @param texture defines the BabylonJS internal texture
  46851. * @param createPolynomials will be true if polynomials have been requested
  46852. * @param onLoad defines the callback to trigger once the texture is ready
  46853. * @param onError defines the callback to trigger in case of error
  46854. */
  46855. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  46856. /**
  46857. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  46858. * @param data contains the texture data
  46859. * @param texture defines the BabylonJS internal texture
  46860. * @param callback defines the method to call once ready to upload
  46861. */
  46862. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void, loadFailed: boolean) => void): void;
  46863. }
  46864. }
  46865. declare module "babylonjs/Helpers/sceneHelpers" {
  46866. import { Nullable } from "babylonjs/types";
  46867. import { Mesh } from "babylonjs/Meshes/mesh";
  46868. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  46869. import { IEnvironmentHelperOptions, EnvironmentHelper } from "babylonjs/Helpers/environmentHelper";
  46870. import { WebXRExperienceHelper } from "babylonjs/Cameras/XR/webXRExperienceHelper";
  46871. import { VRExperienceHelperOptions, VRExperienceHelper } from "babylonjs/Cameras/VR/vrExperienceHelper";
  46872. import "babylonjs/Materials/Textures/Loaders/ddsTextureLoader";
  46873. import "babylonjs/Materials/Textures/Loaders/envTextureLoader";
  46874. import "babylonjs/Materials/Textures/Loaders/ktxTextureLoader";
  46875. import "babylonjs/Meshes/Builders/boxBuilder";
  46876. /** @hidden */
  46877. export var _forceSceneHelpersToBundle: boolean;
  46878. module "babylonjs/scene" {
  46879. interface Scene {
  46880. /**
  46881. * Creates a default light for the scene.
  46882. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-light
  46883. * @param replace has the default false, when true replaces the existing lights in the scene with a hemispheric light
  46884. */
  46885. createDefaultLight(replace?: boolean): void;
  46886. /**
  46887. * Creates a default camera for the scene.
  46888. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-camera
  46889. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  46890. * @param replace has default false, when true replaces the active camera in the scene
  46891. * @param attachCameraControls has default false, when true attaches camera controls to the canvas.
  46892. */
  46893. createDefaultCamera(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  46894. /**
  46895. * Creates a default camera and a default light.
  46896. * @see http://doc.babylonjs.com/how_to/Fast_Build#create-default-camera-or-light
  46897. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  46898. * @param replace has the default false, when true replaces the active camera/light in the scene
  46899. * @param attachCameraControls has the default false, when true attaches camera controls to the canvas.
  46900. */
  46901. createDefaultCameraOrLight(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  46902. /**
  46903. * Creates a new sky box
  46904. * @see http://doc.babylonjs.com/how_to/Fast_Build#create-default-skybox
  46905. * @param environmentTexture defines the texture to use as environment texture
  46906. * @param pbr has default false which requires the StandardMaterial to be used, when true PBRMaterial must be used
  46907. * @param scale defines the overall scale of the skybox
  46908. * @param blur is only available when pbr is true, default is 0, no blur, maximum value is 1
  46909. * @param setGlobalEnvTexture has default true indicating that scene.environmentTexture must match the current skybox texture
  46910. * @returns a new mesh holding the sky box
  46911. */
  46912. createDefaultSkybox(environmentTexture?: BaseTexture, pbr?: boolean, scale?: number, blur?: number, setGlobalEnvTexture?: boolean): Nullable<Mesh>;
  46913. /**
  46914. * Creates a new environment
  46915. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-environment
  46916. * @param options defines the options you can use to configure the environment
  46917. * @returns the new EnvironmentHelper
  46918. */
  46919. createDefaultEnvironment(options?: Partial<IEnvironmentHelperOptions>): Nullable<EnvironmentHelper>;
  46920. /**
  46921. * Creates a new VREXperienceHelper
  46922. * @see http://doc.babylonjs.com/how_to/webvr_helper
  46923. * @param webVROptions defines the options used to create the new VREXperienceHelper
  46924. * @returns a new VREXperienceHelper
  46925. */
  46926. createDefaultVRExperience(webVROptions?: VRExperienceHelperOptions): VRExperienceHelper;
  46927. /**
  46928. * Creates a new XREXperienceHelper
  46929. * @see http://doc.babylonjs.com/how_to/webxr
  46930. * @returns a promise for a new XREXperienceHelper
  46931. */
  46932. createDefaultXRExperienceAsync(): Promise<WebXRExperienceHelper>;
  46933. }
  46934. }
  46935. }
  46936. declare module "babylonjs/Helpers/videoDome" {
  46937. import { Scene } from "babylonjs/scene";
  46938. import { TransformNode } from "babylonjs/Meshes/transformNode";
  46939. import { Mesh } from "babylonjs/Meshes/mesh";
  46940. import { VideoTexture } from "babylonjs/Materials/Textures/videoTexture";
  46941. import { BackgroundMaterial } from "babylonjs/Materials/Background/backgroundMaterial";
  46942. import "babylonjs/Meshes/Builders/sphereBuilder";
  46943. /**
  46944. * Display a 360 degree video on an approximately spherical surface, useful for VR applications or skyboxes.
  46945. * As a subclass of TransformNode, this allow parenting to the camera or multiple videos with different locations in the scene.
  46946. * This class achieves its effect with a VideoTexture and a correctly configured BackgroundMaterial on an inverted sphere.
  46947. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  46948. */
  46949. export class VideoDome extends TransformNode {
  46950. /**
  46951. * Define the video source as a Monoscopic panoramic 360 video.
  46952. */
  46953. static readonly MODE_MONOSCOPIC: number;
  46954. /**
  46955. * Define the video source as a Stereoscopic TopBottom/OverUnder panoramic 360 video.
  46956. */
  46957. static readonly MODE_TOPBOTTOM: number;
  46958. /**
  46959. * Define the video source as a Stereoscopic Side by Side panoramic 360 video.
  46960. */
  46961. static readonly MODE_SIDEBYSIDE: number;
  46962. private _useDirectMapping;
  46963. /**
  46964. * The video texture being displayed on the sphere
  46965. */
  46966. protected _videoTexture: VideoTexture;
  46967. /**
  46968. * Gets the video texture being displayed on the sphere
  46969. */
  46970. readonly videoTexture: VideoTexture;
  46971. /**
  46972. * The skybox material
  46973. */
  46974. protected _material: BackgroundMaterial;
  46975. /**
  46976. * The surface used for the skybox
  46977. */
  46978. protected _mesh: Mesh;
  46979. /**
  46980. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  46981. * Also see the options.resolution property.
  46982. */
  46983. fovMultiplier: number;
  46984. private _videoMode;
  46985. /**
  46986. * Gets or set the current video mode for the video. It can be:
  46987. * * VideoDome.MODE_MONOSCOPIC : Define the video source as a Monoscopic panoramic 360 video.
  46988. * * VideoDome.MODE_TOPBOTTOM : Define the video source as a Stereoscopic TopBottom/OverUnder panoramic 360 video.
  46989. * * VideoDome.MODE_SIDEBYSIDE : Define the video source as a Stereoscopic Side by Side panoramic 360 video.
  46990. */
  46991. videoMode: number;
  46992. /**
  46993. * Oberserver used in Stereoscopic VR Mode.
  46994. */
  46995. private _onBeforeCameraRenderObserver;
  46996. /**
  46997. * Create an instance of this class and pass through the parameters to the relevant classes, VideoTexture, StandardMaterial, and Mesh.
  46998. * @param name Element's name, child elements will append suffixes for their own names.
  46999. * @param urlsOrVideo defines the url(s) or the video element to use
  47000. * @param options An object containing optional or exposed sub element properties
  47001. */
  47002. constructor(name: string, urlsOrVideo: string | string[] | HTMLVideoElement, options: {
  47003. resolution?: number;
  47004. clickToPlay?: boolean;
  47005. autoPlay?: boolean;
  47006. loop?: boolean;
  47007. size?: number;
  47008. poster?: string;
  47009. faceForward?: boolean;
  47010. useDirectMapping?: boolean;
  47011. }, scene: Scene);
  47012. private _changeVideoMode;
  47013. /**
  47014. * Releases resources associated with this node.
  47015. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  47016. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  47017. */
  47018. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  47019. }
  47020. }
  47021. declare module "babylonjs/Helpers/index" {
  47022. export * from "babylonjs/Helpers/environmentHelper";
  47023. export * from "babylonjs/Helpers/photoDome";
  47024. export * from "babylonjs/Helpers/sceneHelpers";
  47025. export * from "babylonjs/Helpers/videoDome";
  47026. }
  47027. declare module "babylonjs/Instrumentation/engineInstrumentation" {
  47028. import { PerfCounter } from "babylonjs/Misc/tools";
  47029. import { IDisposable } from "babylonjs/scene";
  47030. import { Engine } from "babylonjs/Engines/engine";
  47031. /**
  47032. * This class can be used to get instrumentation data from a Babylon engine
  47033. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  47034. */
  47035. export class EngineInstrumentation implements IDisposable {
  47036. /**
  47037. * Define the instrumented engine.
  47038. */
  47039. engine: Engine;
  47040. private _captureGPUFrameTime;
  47041. private _gpuFrameTimeToken;
  47042. private _gpuFrameTime;
  47043. private _captureShaderCompilationTime;
  47044. private _shaderCompilationTime;
  47045. private _onBeginFrameObserver;
  47046. private _onEndFrameObserver;
  47047. private _onBeforeShaderCompilationObserver;
  47048. private _onAfterShaderCompilationObserver;
  47049. /**
  47050. * Gets the perf counter used for GPU frame time
  47051. */
  47052. readonly gpuFrameTimeCounter: PerfCounter;
  47053. /**
  47054. * Gets the GPU frame time capture status
  47055. */
  47056. /**
  47057. * Enable or disable the GPU frame time capture
  47058. */
  47059. captureGPUFrameTime: boolean;
  47060. /**
  47061. * Gets the perf counter used for shader compilation time
  47062. */
  47063. readonly shaderCompilationTimeCounter: PerfCounter;
  47064. /**
  47065. * Gets the shader compilation time capture status
  47066. */
  47067. /**
  47068. * Enable or disable the shader compilation time capture
  47069. */
  47070. captureShaderCompilationTime: boolean;
  47071. /**
  47072. * Instantiates a new engine instrumentation.
  47073. * This class can be used to get instrumentation data from a Babylon engine
  47074. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  47075. * @param engine Defines the engine to instrument
  47076. */
  47077. constructor(
  47078. /**
  47079. * Define the instrumented engine.
  47080. */
  47081. engine: Engine);
  47082. /**
  47083. * Dispose and release associated resources.
  47084. */
  47085. dispose(): void;
  47086. }
  47087. }
  47088. declare module "babylonjs/Instrumentation/sceneInstrumentation" {
  47089. import { PerfCounter } from "babylonjs/Misc/tools";
  47090. import { Scene, IDisposable } from "babylonjs/scene";
  47091. /**
  47092. * This class can be used to get instrumentation data from a Babylon engine
  47093. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  47094. */
  47095. export class SceneInstrumentation implements IDisposable {
  47096. /**
  47097. * Defines the scene to instrument
  47098. */
  47099. scene: Scene;
  47100. private _captureActiveMeshesEvaluationTime;
  47101. private _activeMeshesEvaluationTime;
  47102. private _captureRenderTargetsRenderTime;
  47103. private _renderTargetsRenderTime;
  47104. private _captureFrameTime;
  47105. private _frameTime;
  47106. private _captureRenderTime;
  47107. private _renderTime;
  47108. private _captureInterFrameTime;
  47109. private _interFrameTime;
  47110. private _captureParticlesRenderTime;
  47111. private _particlesRenderTime;
  47112. private _captureSpritesRenderTime;
  47113. private _spritesRenderTime;
  47114. private _capturePhysicsTime;
  47115. private _physicsTime;
  47116. private _captureAnimationsTime;
  47117. private _animationsTime;
  47118. private _captureCameraRenderTime;
  47119. private _cameraRenderTime;
  47120. private _onBeforeActiveMeshesEvaluationObserver;
  47121. private _onAfterActiveMeshesEvaluationObserver;
  47122. private _onBeforeRenderTargetsRenderObserver;
  47123. private _onAfterRenderTargetsRenderObserver;
  47124. private _onAfterRenderObserver;
  47125. private _onBeforeDrawPhaseObserver;
  47126. private _onAfterDrawPhaseObserver;
  47127. private _onBeforeAnimationsObserver;
  47128. private _onBeforeParticlesRenderingObserver;
  47129. private _onAfterParticlesRenderingObserver;
  47130. private _onBeforeSpritesRenderingObserver;
  47131. private _onAfterSpritesRenderingObserver;
  47132. private _onBeforePhysicsObserver;
  47133. private _onAfterPhysicsObserver;
  47134. private _onAfterAnimationsObserver;
  47135. private _onBeforeCameraRenderObserver;
  47136. private _onAfterCameraRenderObserver;
  47137. /**
  47138. * Gets the perf counter used for active meshes evaluation time
  47139. */
  47140. readonly activeMeshesEvaluationTimeCounter: PerfCounter;
  47141. /**
  47142. * Gets the active meshes evaluation time capture status
  47143. */
  47144. /**
  47145. * Enable or disable the active meshes evaluation time capture
  47146. */
  47147. captureActiveMeshesEvaluationTime: boolean;
  47148. /**
  47149. * Gets the perf counter used for render targets render time
  47150. */
  47151. readonly renderTargetsRenderTimeCounter: PerfCounter;
  47152. /**
  47153. * Gets the render targets render time capture status
  47154. */
  47155. /**
  47156. * Enable or disable the render targets render time capture
  47157. */
  47158. captureRenderTargetsRenderTime: boolean;
  47159. /**
  47160. * Gets the perf counter used for particles render time
  47161. */
  47162. readonly particlesRenderTimeCounter: PerfCounter;
  47163. /**
  47164. * Gets the particles render time capture status
  47165. */
  47166. /**
  47167. * Enable or disable the particles render time capture
  47168. */
  47169. captureParticlesRenderTime: boolean;
  47170. /**
  47171. * Gets the perf counter used for sprites render time
  47172. */
  47173. readonly spritesRenderTimeCounter: PerfCounter;
  47174. /**
  47175. * Gets the sprites render time capture status
  47176. */
  47177. /**
  47178. * Enable or disable the sprites render time capture
  47179. */
  47180. captureSpritesRenderTime: boolean;
  47181. /**
  47182. * Gets the perf counter used for physics time
  47183. */
  47184. readonly physicsTimeCounter: PerfCounter;
  47185. /**
  47186. * Gets the physics time capture status
  47187. */
  47188. /**
  47189. * Enable or disable the physics time capture
  47190. */
  47191. capturePhysicsTime: boolean;
  47192. /**
  47193. * Gets the perf counter used for animations time
  47194. */
  47195. readonly animationsTimeCounter: PerfCounter;
  47196. /**
  47197. * Gets the animations time capture status
  47198. */
  47199. /**
  47200. * Enable or disable the animations time capture
  47201. */
  47202. captureAnimationsTime: boolean;
  47203. /**
  47204. * Gets the perf counter used for frame time capture
  47205. */
  47206. readonly frameTimeCounter: PerfCounter;
  47207. /**
  47208. * Gets the frame time capture status
  47209. */
  47210. /**
  47211. * Enable or disable the frame time capture
  47212. */
  47213. captureFrameTime: boolean;
  47214. /**
  47215. * Gets the perf counter used for inter-frames time capture
  47216. */
  47217. readonly interFrameTimeCounter: PerfCounter;
  47218. /**
  47219. * Gets the inter-frames time capture status
  47220. */
  47221. /**
  47222. * Enable or disable the inter-frames time capture
  47223. */
  47224. captureInterFrameTime: boolean;
  47225. /**
  47226. * Gets the perf counter used for render time capture
  47227. */
  47228. readonly renderTimeCounter: PerfCounter;
  47229. /**
  47230. * Gets the render time capture status
  47231. */
  47232. /**
  47233. * Enable or disable the render time capture
  47234. */
  47235. captureRenderTime: boolean;
  47236. /**
  47237. * Gets the perf counter used for camera render time capture
  47238. */
  47239. readonly cameraRenderTimeCounter: PerfCounter;
  47240. /**
  47241. * Gets the camera render time capture status
  47242. */
  47243. /**
  47244. * Enable or disable the camera render time capture
  47245. */
  47246. captureCameraRenderTime: boolean;
  47247. /**
  47248. * Gets the perf counter used for draw calls
  47249. */
  47250. readonly drawCallsCounter: PerfCounter;
  47251. /**
  47252. * Gets the perf counter used for texture collisions
  47253. */
  47254. readonly textureCollisionsCounter: PerfCounter;
  47255. /**
  47256. * Instantiates a new scene instrumentation.
  47257. * This class can be used to get instrumentation data from a Babylon engine
  47258. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  47259. * @param scene Defines the scene to instrument
  47260. */
  47261. constructor(
  47262. /**
  47263. * Defines the scene to instrument
  47264. */
  47265. scene: Scene);
  47266. /**
  47267. * Dispose and release associated resources.
  47268. */
  47269. dispose(): void;
  47270. }
  47271. }
  47272. declare module "babylonjs/Instrumentation/index" {
  47273. export * from "babylonjs/Instrumentation/engineInstrumentation";
  47274. export * from "babylonjs/Instrumentation/sceneInstrumentation";
  47275. export * from "babylonjs/Instrumentation/timeToken";
  47276. }
  47277. declare module "babylonjs/Shaders/glowMapGeneration.fragment" {
  47278. /** @hidden */
  47279. export var glowMapGenerationPixelShader: {
  47280. name: string;
  47281. shader: string;
  47282. };
  47283. }
  47284. declare module "babylonjs/Shaders/glowMapGeneration.vertex" {
  47285. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  47286. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  47287. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  47288. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  47289. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  47290. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  47291. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  47292. /** @hidden */
  47293. export var glowMapGenerationVertexShader: {
  47294. name: string;
  47295. shader: string;
  47296. };
  47297. }
  47298. declare module "babylonjs/Layers/effectLayer" {
  47299. import { Observable } from "babylonjs/Misc/observable";
  47300. import { Nullable } from "babylonjs/types";
  47301. import { Camera } from "babylonjs/Cameras/camera";
  47302. import { Scene } from "babylonjs/scene";
  47303. import { Color4, ISize } from "babylonjs/Maths/math";
  47304. import { Engine } from "babylonjs/Engines/engine";
  47305. import { SubMesh } from "babylonjs/Meshes/subMesh";
  47306. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  47307. import { Mesh } from "babylonjs/Meshes/mesh";
  47308. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  47309. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  47310. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  47311. import { Effect } from "babylonjs/Materials/effect";
  47312. import { Material } from "babylonjs/Materials/material";
  47313. import "babylonjs/Shaders/glowMapGeneration.fragment";
  47314. import "babylonjs/Shaders/glowMapGeneration.vertex";
  47315. /**
  47316. * Effect layer options. This helps customizing the behaviour
  47317. * of the effect layer.
  47318. */
  47319. export interface IEffectLayerOptions {
  47320. /**
  47321. * Multiplication factor apply to the canvas size to compute the render target size
  47322. * used to generated the objects (the smaller the faster).
  47323. */
  47324. mainTextureRatio: number;
  47325. /**
  47326. * Enforces a fixed size texture to ensure effect stability across devices.
  47327. */
  47328. mainTextureFixedSize?: number;
  47329. /**
  47330. * Alpha blending mode used to apply the blur. Default depends of the implementation.
  47331. */
  47332. alphaBlendingMode: number;
  47333. /**
  47334. * The camera attached to the layer.
  47335. */
  47336. camera: Nullable<Camera>;
  47337. /**
  47338. * The rendering group to draw the layer in.
  47339. */
  47340. renderingGroupId: number;
  47341. }
  47342. /**
  47343. * The effect layer Helps adding post process effect blended with the main pass.
  47344. *
  47345. * This can be for instance use to generate glow or higlight effects on the scene.
  47346. *
  47347. * The effect layer class can not be used directly and is intented to inherited from to be
  47348. * customized per effects.
  47349. */
  47350. export abstract class EffectLayer {
  47351. private _vertexBuffers;
  47352. private _indexBuffer;
  47353. private _cachedDefines;
  47354. private _effectLayerMapGenerationEffect;
  47355. private _effectLayerOptions;
  47356. private _mergeEffect;
  47357. protected _scene: Scene;
  47358. protected _engine: Engine;
  47359. protected _maxSize: number;
  47360. protected _mainTextureDesiredSize: ISize;
  47361. protected _mainTexture: RenderTargetTexture;
  47362. protected _shouldRender: boolean;
  47363. protected _postProcesses: PostProcess[];
  47364. protected _textures: BaseTexture[];
  47365. protected _emissiveTextureAndColor: {
  47366. texture: Nullable<BaseTexture>;
  47367. color: Color4;
  47368. };
  47369. /**
  47370. * The name of the layer
  47371. */
  47372. name: string;
  47373. /**
  47374. * The clear color of the texture used to generate the glow map.
  47375. */
  47376. neutralColor: Color4;
  47377. /**
  47378. * Specifies wether the highlight layer is enabled or not.
  47379. */
  47380. isEnabled: boolean;
  47381. /**
  47382. * Gets the camera attached to the layer.
  47383. */
  47384. readonly camera: Nullable<Camera>;
  47385. /**
  47386. * Gets the rendering group id the layer should render in.
  47387. */
  47388. readonly renderingGroupId: number;
  47389. /**
  47390. * An event triggered when the effect layer has been disposed.
  47391. */
  47392. onDisposeObservable: Observable<EffectLayer>;
  47393. /**
  47394. * An event triggered when the effect layer is about rendering the main texture with the glowy parts.
  47395. */
  47396. onBeforeRenderMainTextureObservable: Observable<EffectLayer>;
  47397. /**
  47398. * An event triggered when the generated texture is being merged in the scene.
  47399. */
  47400. onBeforeComposeObservable: Observable<EffectLayer>;
  47401. /**
  47402. * An event triggered when the generated texture has been merged in the scene.
  47403. */
  47404. onAfterComposeObservable: Observable<EffectLayer>;
  47405. /**
  47406. * An event triggered when the efffect layer changes its size.
  47407. */
  47408. onSizeChangedObservable: Observable<EffectLayer>;
  47409. /** @hidden */
  47410. static _SceneComponentInitialization: (scene: Scene) => void;
  47411. /**
  47412. * Instantiates a new effect Layer and references it in the scene.
  47413. * @param name The name of the layer
  47414. * @param scene The scene to use the layer in
  47415. */
  47416. constructor(
  47417. /** The Friendly of the effect in the scene */
  47418. name: string, scene: Scene);
  47419. /**
  47420. * Get the effect name of the layer.
  47421. * @return The effect name
  47422. */
  47423. abstract getEffectName(): string;
  47424. /**
  47425. * Checks for the readiness of the element composing the layer.
  47426. * @param subMesh the mesh to check for
  47427. * @param useInstances specify wether or not to use instances to render the mesh
  47428. * @return true if ready otherwise, false
  47429. */
  47430. abstract isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  47431. /**
  47432. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  47433. * @returns true if the effect requires stencil during the main canvas render pass.
  47434. */
  47435. abstract needStencil(): boolean;
  47436. /**
  47437. * Create the merge effect. This is the shader use to blit the information back
  47438. * to the main canvas at the end of the scene rendering.
  47439. * @returns The effect containing the shader used to merge the effect on the main canvas
  47440. */
  47441. protected abstract _createMergeEffect(): Effect;
  47442. /**
  47443. * Creates the render target textures and post processes used in the effect layer.
  47444. */
  47445. protected abstract _createTextureAndPostProcesses(): void;
  47446. /**
  47447. * Implementation specific of rendering the generating effect on the main canvas.
  47448. * @param effect The effect used to render through
  47449. */
  47450. protected abstract _internalRender(effect: Effect): void;
  47451. /**
  47452. * Sets the required values for both the emissive texture and and the main color.
  47453. */
  47454. protected abstract _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  47455. /**
  47456. * Free any resources and references associated to a mesh.
  47457. * Internal use
  47458. * @param mesh The mesh to free.
  47459. */
  47460. abstract _disposeMesh(mesh: Mesh): void;
  47461. /**
  47462. * Serializes this layer (Glow or Highlight for example)
  47463. * @returns a serialized layer object
  47464. */
  47465. abstract serialize?(): any;
  47466. /**
  47467. * Initializes the effect layer with the required options.
  47468. * @param options Sets of none mandatory options to use with the layer (see IEffectLayerOptions for more information)
  47469. */
  47470. protected _init(options: Partial<IEffectLayerOptions>): void;
  47471. /**
  47472. * Generates the index buffer of the full screen quad blending to the main canvas.
  47473. */
  47474. private _generateIndexBuffer;
  47475. /**
  47476. * Generates the vertex buffer of the full screen quad blending to the main canvas.
  47477. */
  47478. private _genrateVertexBuffer;
  47479. /**
  47480. * Sets the main texture desired size which is the closest power of two
  47481. * of the engine canvas size.
  47482. */
  47483. private _setMainTextureSize;
  47484. /**
  47485. * Creates the main texture for the effect layer.
  47486. */
  47487. protected _createMainTexture(): void;
  47488. /**
  47489. * Adds specific effects defines.
  47490. * @param defines The defines to add specifics to.
  47491. */
  47492. protected _addCustomEffectDefines(defines: string[]): void;
  47493. /**
  47494. * Checks for the readiness of the element composing the layer.
  47495. * @param subMesh the mesh to check for
  47496. * @param useInstances specify wether or not to use instances to render the mesh
  47497. * @param emissiveTexture the associated emissive texture used to generate the glow
  47498. * @return true if ready otherwise, false
  47499. */
  47500. protected _isReady(subMesh: SubMesh, useInstances: boolean, emissiveTexture: Nullable<BaseTexture>): boolean;
  47501. /**
  47502. * Renders the glowing part of the scene by blending the blurred glowing meshes on top of the rendered scene.
  47503. */
  47504. render(): void;
  47505. /**
  47506. * Determine if a given mesh will be used in the current effect.
  47507. * @param mesh mesh to test
  47508. * @returns true if the mesh will be used
  47509. */
  47510. hasMesh(mesh: AbstractMesh): boolean;
  47511. /**
  47512. * Returns true if the layer contains information to display, otherwise false.
  47513. * @returns true if the glow layer should be rendered
  47514. */
  47515. shouldRender(): boolean;
  47516. /**
  47517. * Returns true if the mesh should render, otherwise false.
  47518. * @param mesh The mesh to render
  47519. * @returns true if it should render otherwise false
  47520. */
  47521. protected _shouldRenderMesh(mesh: AbstractMesh): boolean;
  47522. /**
  47523. * Returns true if the mesh can be rendered, otherwise false.
  47524. * @param mesh The mesh to render
  47525. * @param material The material used on the mesh
  47526. * @returns true if it can be rendered otherwise false
  47527. */
  47528. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  47529. /**
  47530. * Returns true if the mesh should render, otherwise false.
  47531. * @param mesh The mesh to render
  47532. * @returns true if it should render otherwise false
  47533. */
  47534. protected _shouldRenderEmissiveTextureForMesh(): boolean;
  47535. /**
  47536. * Renders the submesh passed in parameter to the generation map.
  47537. */
  47538. protected _renderSubMesh(subMesh: SubMesh): void;
  47539. /**
  47540. * Rebuild the required buffers.
  47541. * @hidden Internal use only.
  47542. */
  47543. _rebuild(): void;
  47544. /**
  47545. * Dispose only the render target textures and post process.
  47546. */
  47547. private _disposeTextureAndPostProcesses;
  47548. /**
  47549. * Dispose the highlight layer and free resources.
  47550. */
  47551. dispose(): void;
  47552. /**
  47553. * Gets the class name of the effect layer
  47554. * @returns the string with the class name of the effect layer
  47555. */
  47556. getClassName(): string;
  47557. /**
  47558. * Creates an effect layer from parsed effect layer data
  47559. * @param parsedEffectLayer defines effect layer data
  47560. * @param scene defines the current scene
  47561. * @param rootUrl defines the root URL containing the effect layer information
  47562. * @returns a parsed effect Layer
  47563. */
  47564. static Parse(parsedEffectLayer: any, scene: Scene, rootUrl: string): EffectLayer;
  47565. }
  47566. }
  47567. declare module "babylonjs/Layers/effectLayerSceneComponent" {
  47568. import { Scene } from "babylonjs/scene";
  47569. import { ISceneSerializableComponent } from "babylonjs/sceneComponent";
  47570. import { EffectLayer } from "babylonjs/Layers/effectLayer";
  47571. import { AbstractScene } from "babylonjs/abstractScene";
  47572. module "babylonjs/abstractScene" {
  47573. interface AbstractScene {
  47574. /**
  47575. * The list of effect layers (highlights/glow) added to the scene
  47576. * @see http://doc.babylonjs.com/how_to/highlight_layer
  47577. * @see http://doc.babylonjs.com/how_to/glow_layer
  47578. */
  47579. effectLayers: Array<EffectLayer>;
  47580. /**
  47581. * Removes the given effect layer from this scene.
  47582. * @param toRemove defines the effect layer to remove
  47583. * @returns the index of the removed effect layer
  47584. */
  47585. removeEffectLayer(toRemove: EffectLayer): number;
  47586. /**
  47587. * Adds the given effect layer to this scene
  47588. * @param newEffectLayer defines the effect layer to add
  47589. */
  47590. addEffectLayer(newEffectLayer: EffectLayer): void;
  47591. }
  47592. }
  47593. /**
  47594. * Defines the layer scene component responsible to manage any effect layers
  47595. * in a given scene.
  47596. */
  47597. export class EffectLayerSceneComponent implements ISceneSerializableComponent {
  47598. /**
  47599. * The component name helpfull to identify the component in the list of scene components.
  47600. */
  47601. readonly name: string;
  47602. /**
  47603. * The scene the component belongs to.
  47604. */
  47605. scene: Scene;
  47606. private _engine;
  47607. private _renderEffects;
  47608. private _needStencil;
  47609. private _previousStencilState;
  47610. /**
  47611. * Creates a new instance of the component for the given scene
  47612. * @param scene Defines the scene to register the component in
  47613. */
  47614. constructor(scene: Scene);
  47615. /**
  47616. * Registers the component in a given scene
  47617. */
  47618. register(): void;
  47619. /**
  47620. * Rebuilds the elements related to this component in case of
  47621. * context lost for instance.
  47622. */
  47623. rebuild(): void;
  47624. /**
  47625. * Serializes the component data to the specified json object
  47626. * @param serializationObject The object to serialize to
  47627. */
  47628. serialize(serializationObject: any): void;
  47629. /**
  47630. * Adds all the element from the container to the scene
  47631. * @param container the container holding the elements
  47632. */
  47633. addFromContainer(container: AbstractScene): void;
  47634. /**
  47635. * Removes all the elements in the container from the scene
  47636. * @param container contains the elements to remove
  47637. */
  47638. removeFromContainer(container: AbstractScene): void;
  47639. /**
  47640. * Disposes the component and the associated ressources.
  47641. */
  47642. dispose(): void;
  47643. private _isReadyForMesh;
  47644. private _renderMainTexture;
  47645. private _setStencil;
  47646. private _setStencilBack;
  47647. private _draw;
  47648. private _drawCamera;
  47649. private _drawRenderingGroup;
  47650. }
  47651. }
  47652. declare module "babylonjs/Shaders/glowMapMerge.fragment" {
  47653. /** @hidden */
  47654. export var glowMapMergePixelShader: {
  47655. name: string;
  47656. shader: string;
  47657. };
  47658. }
  47659. declare module "babylonjs/Shaders/glowMapMerge.vertex" {
  47660. /** @hidden */
  47661. export var glowMapMergeVertexShader: {
  47662. name: string;
  47663. shader: string;
  47664. };
  47665. }
  47666. declare module "babylonjs/Layers/glowLayer" {
  47667. import { Nullable } from "babylonjs/types";
  47668. import { Camera } from "babylonjs/Cameras/camera";
  47669. import { Scene } from "babylonjs/scene";
  47670. import { Color4 } from "babylonjs/Maths/math";
  47671. import { SubMesh } from "babylonjs/Meshes/subMesh";
  47672. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  47673. import { Mesh } from "babylonjs/Meshes/mesh";
  47674. import { Texture } from "babylonjs/Materials/Textures/texture";
  47675. import { Effect } from "babylonjs/Materials/effect";
  47676. import { Material } from "babylonjs/Materials/material";
  47677. import { EffectLayer } from "babylonjs/Layers/effectLayer";
  47678. import "babylonjs/Shaders/glowMapMerge.fragment";
  47679. import "babylonjs/Shaders/glowMapMerge.vertex";
  47680. import "babylonjs/Layers/effectLayerSceneComponent";
  47681. module "babylonjs/abstractScene" {
  47682. interface AbstractScene {
  47683. /**
  47684. * Return a the first highlight layer of the scene with a given name.
  47685. * @param name The name of the highlight layer to look for.
  47686. * @return The highlight layer if found otherwise null.
  47687. */
  47688. getGlowLayerByName(name: string): Nullable<GlowLayer>;
  47689. }
  47690. }
  47691. /**
  47692. * Glow layer options. This helps customizing the behaviour
  47693. * of the glow layer.
  47694. */
  47695. export interface IGlowLayerOptions {
  47696. /**
  47697. * Multiplication factor apply to the canvas size to compute the render target size
  47698. * used to generated the glowing objects (the smaller the faster).
  47699. */
  47700. mainTextureRatio: number;
  47701. /**
  47702. * Enforces a fixed size texture to ensure resize independant blur.
  47703. */
  47704. mainTextureFixedSize?: number;
  47705. /**
  47706. * How big is the kernel of the blur texture.
  47707. */
  47708. blurKernelSize: number;
  47709. /**
  47710. * The camera attached to the layer.
  47711. */
  47712. camera: Nullable<Camera>;
  47713. /**
  47714. * Enable MSAA by chosing the number of samples.
  47715. */
  47716. mainTextureSamples?: number;
  47717. /**
  47718. * The rendering group to draw the layer in.
  47719. */
  47720. renderingGroupId: number;
  47721. }
  47722. /**
  47723. * The glow layer Helps adding a glow effect around the emissive parts of a mesh.
  47724. *
  47725. * Once instantiated in a scene, simply use the pushMesh or removeMesh method to add or remove
  47726. * glowy meshes to your scene.
  47727. *
  47728. * Documentation: https://doc.babylonjs.com/how_to/glow_layer
  47729. */
  47730. export class GlowLayer extends EffectLayer {
  47731. /**
  47732. * Effect Name of the layer.
  47733. */
  47734. static readonly EffectName: string;
  47735. /**
  47736. * The default blur kernel size used for the glow.
  47737. */
  47738. static DefaultBlurKernelSize: number;
  47739. /**
  47740. * The default texture size ratio used for the glow.
  47741. */
  47742. static DefaultTextureRatio: number;
  47743. /**
  47744. * Sets the kernel size of the blur.
  47745. */
  47746. /**
  47747. * Gets the kernel size of the blur.
  47748. */
  47749. blurKernelSize: number;
  47750. /**
  47751. * Sets the glow intensity.
  47752. */
  47753. /**
  47754. * Gets the glow intensity.
  47755. */
  47756. intensity: number;
  47757. private _options;
  47758. private _intensity;
  47759. private _horizontalBlurPostprocess1;
  47760. private _verticalBlurPostprocess1;
  47761. private _horizontalBlurPostprocess2;
  47762. private _verticalBlurPostprocess2;
  47763. private _blurTexture1;
  47764. private _blurTexture2;
  47765. private _postProcesses1;
  47766. private _postProcesses2;
  47767. private _includedOnlyMeshes;
  47768. private _excludedMeshes;
  47769. /**
  47770. * Callback used to let the user override the color selection on a per mesh basis
  47771. */
  47772. customEmissiveColorSelector: (mesh: Mesh, subMesh: SubMesh, material: Material, result: Color4) => void;
  47773. /**
  47774. * Callback used to let the user override the texture selection on a per mesh basis
  47775. */
  47776. customEmissiveTextureSelector: (mesh: Mesh, subMesh: SubMesh, material: Material) => Texture;
  47777. /**
  47778. * Instantiates a new glow Layer and references it to the scene.
  47779. * @param name The name of the layer
  47780. * @param scene The scene to use the layer in
  47781. * @param options Sets of none mandatory options to use with the layer (see IGlowLayerOptions for more information)
  47782. */
  47783. constructor(name: string, scene: Scene, options?: Partial<IGlowLayerOptions>);
  47784. /**
  47785. * Get the effect name of the layer.
  47786. * @return The effect name
  47787. */
  47788. getEffectName(): string;
  47789. /**
  47790. * Create the merge effect. This is the shader use to blit the information back
  47791. * to the main canvas at the end of the scene rendering.
  47792. */
  47793. protected _createMergeEffect(): Effect;
  47794. /**
  47795. * Creates the render target textures and post processes used in the glow layer.
  47796. */
  47797. protected _createTextureAndPostProcesses(): void;
  47798. /**
  47799. * Checks for the readiness of the element composing the layer.
  47800. * @param subMesh the mesh to check for
  47801. * @param useInstances specify wether or not to use instances to render the mesh
  47802. * @param emissiveTexture the associated emissive texture used to generate the glow
  47803. * @return true if ready otherwise, false
  47804. */
  47805. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  47806. /**
  47807. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  47808. */
  47809. needStencil(): boolean;
  47810. /**
  47811. * Returns true if the mesh can be rendered, otherwise false.
  47812. * @param mesh The mesh to render
  47813. * @param material The material used on the mesh
  47814. * @returns true if it can be rendered otherwise false
  47815. */
  47816. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  47817. /**
  47818. * Implementation specific of rendering the generating effect on the main canvas.
  47819. * @param effect The effect used to render through
  47820. */
  47821. protected _internalRender(effect: Effect): void;
  47822. /**
  47823. * Sets the required values for both the emissive texture and and the main color.
  47824. */
  47825. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  47826. /**
  47827. * Returns true if the mesh should render, otherwise false.
  47828. * @param mesh The mesh to render
  47829. * @returns true if it should render otherwise false
  47830. */
  47831. protected _shouldRenderMesh(mesh: Mesh): boolean;
  47832. /**
  47833. * Adds specific effects defines.
  47834. * @param defines The defines to add specifics to.
  47835. */
  47836. protected _addCustomEffectDefines(defines: string[]): void;
  47837. /**
  47838. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the glow layer.
  47839. * @param mesh The mesh to exclude from the glow layer
  47840. */
  47841. addExcludedMesh(mesh: Mesh): void;
  47842. /**
  47843. * Remove a mesh from the exclusion list to let it impact or being impacted by the glow layer.
  47844. * @param mesh The mesh to remove
  47845. */
  47846. removeExcludedMesh(mesh: Mesh): void;
  47847. /**
  47848. * Add a mesh in the inclusion list to impact or being impacted by the glow layer.
  47849. * @param mesh The mesh to include in the glow layer
  47850. */
  47851. addIncludedOnlyMesh(mesh: Mesh): void;
  47852. /**
  47853. * Remove a mesh from the Inclusion list to prevent it to impact or being impacted by the glow layer.
  47854. * @param mesh The mesh to remove
  47855. */
  47856. removeIncludedOnlyMesh(mesh: Mesh): void;
  47857. /**
  47858. * Determine if a given mesh will be used in the glow layer
  47859. * @param mesh The mesh to test
  47860. * @returns true if the mesh will be highlighted by the current glow layer
  47861. */
  47862. hasMesh(mesh: AbstractMesh): boolean;
  47863. /**
  47864. * Free any resources and references associated to a mesh.
  47865. * Internal use
  47866. * @param mesh The mesh to free.
  47867. * @hidden
  47868. */
  47869. _disposeMesh(mesh: Mesh): void;
  47870. /**
  47871. * Gets the class name of the effect layer
  47872. * @returns the string with the class name of the effect layer
  47873. */
  47874. getClassName(): string;
  47875. /**
  47876. * Serializes this glow layer
  47877. * @returns a serialized glow layer object
  47878. */
  47879. serialize(): any;
  47880. /**
  47881. * Creates a Glow Layer from parsed glow layer data
  47882. * @param parsedGlowLayer defines glow layer data
  47883. * @param scene defines the current scene
  47884. * @param rootUrl defines the root URL containing the glow layer information
  47885. * @returns a parsed Glow Layer
  47886. */
  47887. static Parse(parsedGlowLayer: any, scene: Scene, rootUrl: string): GlowLayer;
  47888. }
  47889. }
  47890. declare module "babylonjs/Shaders/glowBlurPostProcess.fragment" {
  47891. /** @hidden */
  47892. export var glowBlurPostProcessPixelShader: {
  47893. name: string;
  47894. shader: string;
  47895. };
  47896. }
  47897. declare module "babylonjs/Layers/highlightLayer" {
  47898. import { Observable } from "babylonjs/Misc/observable";
  47899. import { Nullable } from "babylonjs/types";
  47900. import { Camera } from "babylonjs/Cameras/camera";
  47901. import { Scene } from "babylonjs/scene";
  47902. import { Color3, Color4 } from "babylonjs/Maths/math";
  47903. import { SubMesh } from "babylonjs/Meshes/subMesh";
  47904. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  47905. import { Mesh } from "babylonjs/Meshes/mesh";
  47906. import { Effect } from "babylonjs/Materials/effect";
  47907. import { Material } from "babylonjs/Materials/material";
  47908. import { EffectLayer } from "babylonjs/Layers/effectLayer";
  47909. import "babylonjs/Shaders/glowMapMerge.fragment";
  47910. import "babylonjs/Shaders/glowMapMerge.vertex";
  47911. import "babylonjs/Shaders/glowBlurPostProcess.fragment";
  47912. module "babylonjs/abstractScene" {
  47913. interface AbstractScene {
  47914. /**
  47915. * Return a the first highlight layer of the scene with a given name.
  47916. * @param name The name of the highlight layer to look for.
  47917. * @return The highlight layer if found otherwise null.
  47918. */
  47919. getHighlightLayerByName(name: string): Nullable<HighlightLayer>;
  47920. }
  47921. }
  47922. /**
  47923. * Highlight layer options. This helps customizing the behaviour
  47924. * of the highlight layer.
  47925. */
  47926. export interface IHighlightLayerOptions {
  47927. /**
  47928. * Multiplication factor apply to the canvas size to compute the render target size
  47929. * used to generated the glowing objects (the smaller the faster).
  47930. */
  47931. mainTextureRatio: number;
  47932. /**
  47933. * Enforces a fixed size texture to ensure resize independant blur.
  47934. */
  47935. mainTextureFixedSize?: number;
  47936. /**
  47937. * Multiplication factor apply to the main texture size in the first step of the blur to reduce the size
  47938. * of the picture to blur (the smaller the faster).
  47939. */
  47940. blurTextureSizeRatio: number;
  47941. /**
  47942. * How big in texel of the blur texture is the vertical blur.
  47943. */
  47944. blurVerticalSize: number;
  47945. /**
  47946. * How big in texel of the blur texture is the horizontal blur.
  47947. */
  47948. blurHorizontalSize: number;
  47949. /**
  47950. * Alpha blending mode used to apply the blur. Default is combine.
  47951. */
  47952. alphaBlendingMode: number;
  47953. /**
  47954. * The camera attached to the layer.
  47955. */
  47956. camera: Nullable<Camera>;
  47957. /**
  47958. * Should we display highlight as a solid stroke?
  47959. */
  47960. isStroke?: boolean;
  47961. /**
  47962. * The rendering group to draw the layer in.
  47963. */
  47964. renderingGroupId: number;
  47965. }
  47966. /**
  47967. * The highlight layer Helps adding a glow effect around a mesh.
  47968. *
  47969. * Once instantiated in a scene, simply use the pushMesh or removeMesh method to add or remove
  47970. * glowy meshes to your scene.
  47971. *
  47972. * !!! THIS REQUIRES AN ACTIVE STENCIL BUFFER ON THE CANVAS !!!
  47973. */
  47974. export class HighlightLayer extends EffectLayer {
  47975. name: string;
  47976. /**
  47977. * Effect Name of the highlight layer.
  47978. */
  47979. static readonly EffectName: string;
  47980. /**
  47981. * The neutral color used during the preparation of the glow effect.
  47982. * This is black by default as the blend operation is a blend operation.
  47983. */
  47984. static NeutralColor: Color4;
  47985. /**
  47986. * Stencil value used for glowing meshes.
  47987. */
  47988. static GlowingMeshStencilReference: number;
  47989. /**
  47990. * Stencil value used for the other meshes in the scene.
  47991. */
  47992. static NormalMeshStencilReference: number;
  47993. /**
  47994. * Specifies whether or not the inner glow is ACTIVE in the layer.
  47995. */
  47996. innerGlow: boolean;
  47997. /**
  47998. * Specifies whether or not the outer glow is ACTIVE in the layer.
  47999. */
  48000. outerGlow: boolean;
  48001. /**
  48002. * Specifies the horizontal size of the blur.
  48003. */
  48004. /**
  48005. * Gets the horizontal size of the blur.
  48006. */
  48007. blurHorizontalSize: number;
  48008. /**
  48009. * Specifies the vertical size of the blur.
  48010. */
  48011. /**
  48012. * Gets the vertical size of the blur.
  48013. */
  48014. blurVerticalSize: number;
  48015. /**
  48016. * An event triggered when the highlight layer is being blurred.
  48017. */
  48018. onBeforeBlurObservable: Observable<HighlightLayer>;
  48019. /**
  48020. * An event triggered when the highlight layer has been blurred.
  48021. */
  48022. onAfterBlurObservable: Observable<HighlightLayer>;
  48023. private _instanceGlowingMeshStencilReference;
  48024. private _options;
  48025. private _downSamplePostprocess;
  48026. private _horizontalBlurPostprocess;
  48027. private _verticalBlurPostprocess;
  48028. private _blurTexture;
  48029. private _meshes;
  48030. private _excludedMeshes;
  48031. /**
  48032. * Instantiates a new highlight Layer and references it to the scene..
  48033. * @param name The name of the layer
  48034. * @param scene The scene to use the layer in
  48035. * @param options Sets of none mandatory options to use with the layer (see IHighlightLayerOptions for more information)
  48036. */
  48037. constructor(name: string, scene: Scene, options?: Partial<IHighlightLayerOptions>);
  48038. /**
  48039. * Get the effect name of the layer.
  48040. * @return The effect name
  48041. */
  48042. getEffectName(): string;
  48043. /**
  48044. * Create the merge effect. This is the shader use to blit the information back
  48045. * to the main canvas at the end of the scene rendering.
  48046. */
  48047. protected _createMergeEffect(): Effect;
  48048. /**
  48049. * Creates the render target textures and post processes used in the highlight layer.
  48050. */
  48051. protected _createTextureAndPostProcesses(): void;
  48052. /**
  48053. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  48054. */
  48055. needStencil(): boolean;
  48056. /**
  48057. * Checks for the readiness of the element composing the layer.
  48058. * @param subMesh the mesh to check for
  48059. * @param useInstances specify wether or not to use instances to render the mesh
  48060. * @param emissiveTexture the associated emissive texture used to generate the glow
  48061. * @return true if ready otherwise, false
  48062. */
  48063. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  48064. /**
  48065. * Implementation specific of rendering the generating effect on the main canvas.
  48066. * @param effect The effect used to render through
  48067. */
  48068. protected _internalRender(effect: Effect): void;
  48069. /**
  48070. * Returns true if the layer contains information to display, otherwise false.
  48071. */
  48072. shouldRender(): boolean;
  48073. /**
  48074. * Returns true if the mesh should render, otherwise false.
  48075. * @param mesh The mesh to render
  48076. * @returns true if it should render otherwise false
  48077. */
  48078. protected _shouldRenderMesh(mesh: Mesh): boolean;
  48079. /**
  48080. * Sets the required values for both the emissive texture and and the main color.
  48081. */
  48082. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  48083. /**
  48084. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the highlight layer.
  48085. * @param mesh The mesh to exclude from the highlight layer
  48086. */
  48087. addExcludedMesh(mesh: Mesh): void;
  48088. /**
  48089. * Remove a mesh from the exclusion list to let it impact or being impacted by the highlight layer.
  48090. * @param mesh The mesh to highlight
  48091. */
  48092. removeExcludedMesh(mesh: Mesh): void;
  48093. /**
  48094. * Determine if a given mesh will be highlighted by the current HighlightLayer
  48095. * @param mesh mesh to test
  48096. * @returns true if the mesh will be highlighted by the current HighlightLayer
  48097. */
  48098. hasMesh(mesh: AbstractMesh): boolean;
  48099. /**
  48100. * Add a mesh in the highlight layer in order to make it glow with the chosen color.
  48101. * @param mesh The mesh to highlight
  48102. * @param color The color of the highlight
  48103. * @param glowEmissiveOnly Extract the glow from the emissive texture
  48104. */
  48105. addMesh(mesh: Mesh, color: Color3, glowEmissiveOnly?: boolean): void;
  48106. /**
  48107. * Remove a mesh from the highlight layer in order to make it stop glowing.
  48108. * @param mesh The mesh to highlight
  48109. */
  48110. removeMesh(mesh: Mesh): void;
  48111. /**
  48112. * Force the stencil to the normal expected value for none glowing parts
  48113. */
  48114. private _defaultStencilReference;
  48115. /**
  48116. * Free any resources and references associated to a mesh.
  48117. * Internal use
  48118. * @param mesh The mesh to free.
  48119. * @hidden
  48120. */
  48121. _disposeMesh(mesh: Mesh): void;
  48122. /**
  48123. * Dispose the highlight layer and free resources.
  48124. */
  48125. dispose(): void;
  48126. /**
  48127. * Gets the class name of the effect layer
  48128. * @returns the string with the class name of the effect layer
  48129. */
  48130. getClassName(): string;
  48131. /**
  48132. * Serializes this Highlight layer
  48133. * @returns a serialized Highlight layer object
  48134. */
  48135. serialize(): any;
  48136. /**
  48137. * Creates a Highlight layer from parsed Highlight layer data
  48138. * @param parsedHightlightLayer defines the Highlight layer data
  48139. * @param scene defines the current scene
  48140. * @param rootUrl defines the root URL containing the Highlight layer information
  48141. * @returns a parsed Highlight layer
  48142. */
  48143. static Parse(parsedHightlightLayer: any, scene: Scene, rootUrl: string): HighlightLayer;
  48144. }
  48145. }
  48146. declare module "babylonjs/Layers/index" {
  48147. export * from "babylonjs/Layers/effectLayer";
  48148. export * from "babylonjs/Layers/effectLayerSceneComponent";
  48149. export * from "babylonjs/Layers/glowLayer";
  48150. export * from "babylonjs/Layers/highlightLayer";
  48151. export * from "babylonjs/Layers/layer";
  48152. export * from "babylonjs/Layers/layerSceneComponent";
  48153. }
  48154. declare module "babylonjs/Shaders/lensFlare.fragment" {
  48155. /** @hidden */
  48156. export var lensFlarePixelShader: {
  48157. name: string;
  48158. shader: string;
  48159. };
  48160. }
  48161. declare module "babylonjs/Shaders/lensFlare.vertex" {
  48162. /** @hidden */
  48163. export var lensFlareVertexShader: {
  48164. name: string;
  48165. shader: string;
  48166. };
  48167. }
  48168. declare module "babylonjs/LensFlares/lensFlareSystem" {
  48169. import { Scene } from "babylonjs/scene";
  48170. import { Vector3, Viewport } from "babylonjs/Maths/math";
  48171. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  48172. import { LensFlare } from "babylonjs/LensFlares/lensFlare";
  48173. import "babylonjs/Shaders/lensFlare.fragment";
  48174. import "babylonjs/Shaders/lensFlare.vertex";
  48175. /**
  48176. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  48177. * It is usually composed of several `lensFlare`.
  48178. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  48179. */
  48180. export class LensFlareSystem {
  48181. /**
  48182. * Define the name of the lens flare system
  48183. */
  48184. name: string;
  48185. /**
  48186. * List of lens flares used in this system.
  48187. */
  48188. lensFlares: LensFlare[];
  48189. /**
  48190. * Define a limit from the border the lens flare can be visible.
  48191. */
  48192. borderLimit: number;
  48193. /**
  48194. * Define a viewport border we do not want to see the lens flare in.
  48195. */
  48196. viewportBorder: number;
  48197. /**
  48198. * Define a predicate which could limit the list of meshes able to occlude the effect.
  48199. */
  48200. meshesSelectionPredicate: (mesh: AbstractMesh) => boolean;
  48201. /**
  48202. * Restricts the rendering of the effect to only the camera rendering this layer mask.
  48203. */
  48204. layerMask: number;
  48205. /**
  48206. * Define the id of the lens flare system in the scene.
  48207. * (equal to name by default)
  48208. */
  48209. id: string;
  48210. private _scene;
  48211. private _emitter;
  48212. private _vertexBuffers;
  48213. private _indexBuffer;
  48214. private _effect;
  48215. private _positionX;
  48216. private _positionY;
  48217. private _isEnabled;
  48218. /** @hidden */
  48219. static _SceneComponentInitialization: (scene: Scene) => void;
  48220. /**
  48221. * Instantiates a lens flare system.
  48222. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  48223. * It is usually composed of several `lensFlare`.
  48224. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  48225. * @param name Define the name of the lens flare system in the scene
  48226. * @param emitter Define the source (the emitter) of the lens flares (it can be a camera, a light or a mesh).
  48227. * @param scene Define the scene the lens flare system belongs to
  48228. */
  48229. constructor(
  48230. /**
  48231. * Define the name of the lens flare system
  48232. */
  48233. name: string, emitter: any, scene: Scene);
  48234. /**
  48235. * Define if the lens flare system is enabled.
  48236. */
  48237. isEnabled: boolean;
  48238. /**
  48239. * Get the scene the effects belongs to.
  48240. * @returns the scene holding the lens flare system
  48241. */
  48242. getScene(): Scene;
  48243. /**
  48244. * Get the emitter of the lens flare system.
  48245. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  48246. * @returns the emitter of the lens flare system
  48247. */
  48248. getEmitter(): any;
  48249. /**
  48250. * Set the emitter of the lens flare system.
  48251. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  48252. * @param newEmitter Define the new emitter of the system
  48253. */
  48254. setEmitter(newEmitter: any): void;
  48255. /**
  48256. * Get the lens flare system emitter position.
  48257. * The emitter defines the source of the lens flares (it can be a camera, a light or a mesh).
  48258. * @returns the position
  48259. */
  48260. getEmitterPosition(): Vector3;
  48261. /**
  48262. * @hidden
  48263. */
  48264. computeEffectivePosition(globalViewport: Viewport): boolean;
  48265. /** @hidden */
  48266. _isVisible(): boolean;
  48267. /**
  48268. * @hidden
  48269. */
  48270. render(): boolean;
  48271. /**
  48272. * Dispose and release the lens flare with its associated resources.
  48273. */
  48274. dispose(): void;
  48275. /**
  48276. * Parse a lens flare system from a JSON repressentation
  48277. * @param parsedLensFlareSystem Define the JSON to parse
  48278. * @param scene Define the scene the parsed system should be instantiated in
  48279. * @param rootUrl Define the rootUrl of the load sequence to easily find a load relative dependencies such as textures
  48280. * @returns the parsed system
  48281. */
  48282. static Parse(parsedLensFlareSystem: any, scene: Scene, rootUrl: string): LensFlareSystem;
  48283. /**
  48284. * Serialize the current Lens Flare System into a JSON representation.
  48285. * @returns the serialized JSON
  48286. */
  48287. serialize(): any;
  48288. }
  48289. }
  48290. declare module "babylonjs/LensFlares/lensFlare" {
  48291. import { Nullable } from "babylonjs/types";
  48292. import { Color3 } from "babylonjs/Maths/math";
  48293. import { Texture } from "babylonjs/Materials/Textures/texture";
  48294. import { LensFlareSystem } from "babylonjs/LensFlares/lensFlareSystem";
  48295. /**
  48296. * This represents one of the lens effect in a `lensFlareSystem`.
  48297. * It controls one of the indiviual texture used in the effect.
  48298. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  48299. */
  48300. export class LensFlare {
  48301. /**
  48302. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  48303. */
  48304. size: number;
  48305. /**
  48306. * 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.
  48307. */
  48308. position: number;
  48309. /**
  48310. * Define the lens color.
  48311. */
  48312. color: Color3;
  48313. /**
  48314. * Define the lens texture.
  48315. */
  48316. texture: Nullable<Texture>;
  48317. /**
  48318. * Define the alpha mode to render this particular lens.
  48319. */
  48320. alphaMode: number;
  48321. private _system;
  48322. /**
  48323. * Creates a new Lens Flare.
  48324. * This represents one of the lens effect in a `lensFlareSystem`.
  48325. * It controls one of the indiviual texture used in the effect.
  48326. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  48327. * @param size Define the size of the lens flare (a floating value between 0 and 1)
  48328. * @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.
  48329. * @param color Define the lens color
  48330. * @param imgUrl Define the lens texture url
  48331. * @param system Define the `lensFlareSystem` this flare is part of
  48332. * @returns The newly created Lens Flare
  48333. */
  48334. static AddFlare(size: number, position: number, color: Color3, imgUrl: string, system: LensFlareSystem): LensFlare;
  48335. /**
  48336. * Instantiates a new Lens Flare.
  48337. * This represents one of the lens effect in a `lensFlareSystem`.
  48338. * It controls one of the indiviual texture used in the effect.
  48339. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  48340. * @param size Define the size of the lens flare in the system (a floating value between 0 and 1)
  48341. * @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.
  48342. * @param color Define the lens color
  48343. * @param imgUrl Define the lens texture url
  48344. * @param system Define the `lensFlareSystem` this flare is part of
  48345. */
  48346. constructor(
  48347. /**
  48348. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  48349. */
  48350. size: number,
  48351. /**
  48352. * 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.
  48353. */
  48354. position: number, color: Color3, imgUrl: string, system: LensFlareSystem);
  48355. /**
  48356. * Dispose and release the lens flare with its associated resources.
  48357. */
  48358. dispose(): void;
  48359. }
  48360. }
  48361. declare module "babylonjs/LensFlares/lensFlareSystemSceneComponent" {
  48362. import { Nullable } from "babylonjs/types";
  48363. import { Scene } from "babylonjs/scene";
  48364. import { ISceneSerializableComponent } from "babylonjs/sceneComponent";
  48365. import { AbstractScene } from "babylonjs/abstractScene";
  48366. import { LensFlareSystem } from "babylonjs/LensFlares/lensFlareSystem";
  48367. module "babylonjs/abstractScene" {
  48368. interface AbstractScene {
  48369. /**
  48370. * The list of lens flare system added to the scene
  48371. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  48372. */
  48373. lensFlareSystems: Array<LensFlareSystem>;
  48374. /**
  48375. * Removes the given lens flare system from this scene.
  48376. * @param toRemove The lens flare system to remove
  48377. * @returns The index of the removed lens flare system
  48378. */
  48379. removeLensFlareSystem(toRemove: LensFlareSystem): number;
  48380. /**
  48381. * Adds the given lens flare system to this scene
  48382. * @param newLensFlareSystem The lens flare system to add
  48383. */
  48384. addLensFlareSystem(newLensFlareSystem: LensFlareSystem): void;
  48385. /**
  48386. * Gets a lens flare system using its name
  48387. * @param name defines the name to look for
  48388. * @returns the lens flare system or null if not found
  48389. */
  48390. getLensFlareSystemByName(name: string): Nullable<LensFlareSystem>;
  48391. /**
  48392. * Gets a lens flare system using its id
  48393. * @param id defines the id to look for
  48394. * @returns the lens flare system or null if not found
  48395. */
  48396. getLensFlareSystemByID(id: string): Nullable<LensFlareSystem>;
  48397. }
  48398. }
  48399. /**
  48400. * Defines the lens flare scene component responsible to manage any lens flares
  48401. * in a given scene.
  48402. */
  48403. export class LensFlareSystemSceneComponent implements ISceneSerializableComponent {
  48404. /**
  48405. * The component name helpfull to identify the component in the list of scene components.
  48406. */
  48407. readonly name: string;
  48408. /**
  48409. * The scene the component belongs to.
  48410. */
  48411. scene: Scene;
  48412. /**
  48413. * Creates a new instance of the component for the given scene
  48414. * @param scene Defines the scene to register the component in
  48415. */
  48416. constructor(scene: Scene);
  48417. /**
  48418. * Registers the component in a given scene
  48419. */
  48420. register(): void;
  48421. /**
  48422. * Rebuilds the elements related to this component in case of
  48423. * context lost for instance.
  48424. */
  48425. rebuild(): void;
  48426. /**
  48427. * Adds all the element from the container to the scene
  48428. * @param container the container holding the elements
  48429. */
  48430. addFromContainer(container: AbstractScene): void;
  48431. /**
  48432. * Removes all the elements in the container from the scene
  48433. * @param container contains the elements to remove
  48434. */
  48435. removeFromContainer(container: AbstractScene): void;
  48436. /**
  48437. * Serializes the component data to the specified json object
  48438. * @param serializationObject The object to serialize to
  48439. */
  48440. serialize(serializationObject: any): void;
  48441. /**
  48442. * Disposes the component and the associated ressources.
  48443. */
  48444. dispose(): void;
  48445. private _draw;
  48446. }
  48447. }
  48448. declare module "babylonjs/LensFlares/index" {
  48449. export * from "babylonjs/LensFlares/lensFlare";
  48450. export * from "babylonjs/LensFlares/lensFlareSystem";
  48451. export * from "babylonjs/LensFlares/lensFlareSystemSceneComponent";
  48452. }
  48453. declare module "babylonjs/Lights/Shadows/shadowGeneratorSceneComponent" {
  48454. import { Scene } from "babylonjs/scene";
  48455. import { ISceneSerializableComponent } from "babylonjs/sceneComponent";
  48456. import { AbstractScene } from "babylonjs/abstractScene";
  48457. /**
  48458. * Defines the shadow generator component responsible to manage any shadow generators
  48459. * in a given scene.
  48460. */
  48461. export class ShadowGeneratorSceneComponent implements ISceneSerializableComponent {
  48462. /**
  48463. * The component name helpfull to identify the component in the list of scene components.
  48464. */
  48465. readonly name: string;
  48466. /**
  48467. * The scene the component belongs to.
  48468. */
  48469. scene: Scene;
  48470. /**
  48471. * Creates a new instance of the component for the given scene
  48472. * @param scene Defines the scene to register the component in
  48473. */
  48474. constructor(scene: Scene);
  48475. /**
  48476. * Registers the component in a given scene
  48477. */
  48478. register(): void;
  48479. /**
  48480. * Rebuilds the elements related to this component in case of
  48481. * context lost for instance.
  48482. */
  48483. rebuild(): void;
  48484. /**
  48485. * Serializes the component data to the specified json object
  48486. * @param serializationObject The object to serialize to
  48487. */
  48488. serialize(serializationObject: any): void;
  48489. /**
  48490. * Adds all the element from the container to the scene
  48491. * @param container the container holding the elements
  48492. */
  48493. addFromContainer(container: AbstractScene): void;
  48494. /**
  48495. * Removes all the elements in the container from the scene
  48496. * @param container contains the elements to remove
  48497. */
  48498. removeFromContainer(container: AbstractScene): void;
  48499. /**
  48500. * Rebuilds the elements related to this component in case of
  48501. * context lost for instance.
  48502. */
  48503. dispose(): void;
  48504. private _gatherRenderTargets;
  48505. }
  48506. }
  48507. declare module "babylonjs/Lights/Shadows/index" {
  48508. export * from "babylonjs/Lights/Shadows/shadowGenerator";
  48509. export * from "babylonjs/Lights/Shadows/shadowGeneratorSceneComponent";
  48510. }
  48511. declare module "babylonjs/Lights/directionalLight" {
  48512. import { Camera } from "babylonjs/Cameras/camera";
  48513. import { Scene } from "babylonjs/scene";
  48514. import { Matrix, Vector3 } from "babylonjs/Maths/math";
  48515. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  48516. import { ShadowLight } from "babylonjs/Lights/shadowLight";
  48517. import { Effect } from "babylonjs/Materials/effect";
  48518. /**
  48519. * A directional light is defined by a direction (what a surprise!).
  48520. * The light is emitted from everywhere in the specified direction, and has an infinite range.
  48521. * 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.
  48522. * Documentation: https://doc.babylonjs.com/babylon101/lights
  48523. */
  48524. export class DirectionalLight extends ShadowLight {
  48525. private _shadowFrustumSize;
  48526. /**
  48527. * Fix frustum size for the shadow generation. This is disabled if the value is 0.
  48528. */
  48529. /**
  48530. * Specifies a fix frustum size for the shadow generation.
  48531. */
  48532. shadowFrustumSize: number;
  48533. private _shadowOrthoScale;
  48534. /**
  48535. * Gets the shadow projection scale against the optimal computed one.
  48536. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  48537. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  48538. */
  48539. /**
  48540. * Sets the shadow projection scale against the optimal computed one.
  48541. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  48542. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  48543. */
  48544. shadowOrthoScale: number;
  48545. /**
  48546. * Automatically compute the projection matrix to best fit (including all the casters)
  48547. * on each frame.
  48548. */
  48549. autoUpdateExtends: boolean;
  48550. private _orthoLeft;
  48551. private _orthoRight;
  48552. private _orthoTop;
  48553. private _orthoBottom;
  48554. /**
  48555. * Creates a DirectionalLight object in the scene, oriented towards the passed direction (Vector3).
  48556. * The directional light is emitted from everywhere in the given direction.
  48557. * It can cast shadows.
  48558. * Documentation : https://doc.babylonjs.com/babylon101/lights
  48559. * @param name The friendly name of the light
  48560. * @param direction The direction of the light
  48561. * @param scene The scene the light belongs to
  48562. */
  48563. constructor(name: string, direction: Vector3, scene: Scene);
  48564. /**
  48565. * Returns the string "DirectionalLight".
  48566. * @return The class name
  48567. */
  48568. getClassName(): string;
  48569. /**
  48570. * Returns the integer 1.
  48571. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  48572. */
  48573. getTypeID(): number;
  48574. /**
  48575. * Sets the passed matrix "matrix" as projection matrix for the shadows cast by the light according to the passed view matrix.
  48576. * Returns the DirectionalLight Shadow projection matrix.
  48577. */
  48578. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  48579. /**
  48580. * Sets the passed matrix "matrix" as fixed frustum projection matrix for the shadows cast by the light according to the passed view matrix.
  48581. * Returns the DirectionalLight Shadow projection matrix.
  48582. */
  48583. protected _setDefaultFixedFrustumShadowProjectionMatrix(matrix: Matrix): void;
  48584. /**
  48585. * Sets the passed matrix "matrix" as auto extend projection matrix for the shadows cast by the light according to the passed view matrix.
  48586. * Returns the DirectionalLight Shadow projection matrix.
  48587. */
  48588. protected _setDefaultAutoExtendShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  48589. protected _buildUniformLayout(): void;
  48590. /**
  48591. * Sets the passed Effect object with the DirectionalLight transformed position (or position if not parented) and the passed name.
  48592. * @param effect The effect to update
  48593. * @param lightIndex The index of the light in the effect to update
  48594. * @returns The directional light
  48595. */
  48596. transferToEffect(effect: Effect, lightIndex: string): DirectionalLight;
  48597. /**
  48598. * Gets the minZ used for shadow according to both the scene and the light.
  48599. *
  48600. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  48601. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  48602. * @param activeCamera The camera we are returning the min for
  48603. * @returns the depth min z
  48604. */
  48605. getDepthMinZ(activeCamera: Camera): number;
  48606. /**
  48607. * Gets the maxZ used for shadow according to both the scene and the light.
  48608. *
  48609. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  48610. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  48611. * @param activeCamera The camera we are returning the max for
  48612. * @returns the depth max z
  48613. */
  48614. getDepthMaxZ(activeCamera: Camera): number;
  48615. /**
  48616. * Prepares the list of defines specific to the light type.
  48617. * @param defines the list of defines
  48618. * @param lightIndex defines the index of the light for the effect
  48619. */
  48620. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  48621. }
  48622. }
  48623. declare module "babylonjs/Lights/pointLight" {
  48624. import { Scene } from "babylonjs/scene";
  48625. import { Matrix, Vector3 } from "babylonjs/Maths/math";
  48626. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  48627. import { ShadowLight } from "babylonjs/Lights/shadowLight";
  48628. import { Effect } from "babylonjs/Materials/effect";
  48629. /**
  48630. * A point light is a light defined by an unique point in world space.
  48631. * The light is emitted in every direction from this point.
  48632. * A good example of a point light is a standard light bulb.
  48633. * Documentation: https://doc.babylonjs.com/babylon101/lights
  48634. */
  48635. export class PointLight extends ShadowLight {
  48636. private _shadowAngle;
  48637. /**
  48638. * Getter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  48639. * This specifies what angle the shadow will use to be created.
  48640. *
  48641. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  48642. */
  48643. /**
  48644. * Setter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  48645. * This specifies what angle the shadow will use to be created.
  48646. *
  48647. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  48648. */
  48649. shadowAngle: number;
  48650. /**
  48651. * Gets the direction if it has been set.
  48652. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  48653. */
  48654. /**
  48655. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  48656. */
  48657. direction: Vector3;
  48658. /**
  48659. * Creates a PointLight object from the passed name and position (Vector3) and adds it in the scene.
  48660. * A PointLight emits the light in every direction.
  48661. * It can cast shadows.
  48662. * If the scene camera is already defined and you want to set your PointLight at the camera position, just set it :
  48663. * ```javascript
  48664. * var pointLight = new PointLight("pl", camera.position, scene);
  48665. * ```
  48666. * Documentation : https://doc.babylonjs.com/babylon101/lights
  48667. * @param name The light friendly name
  48668. * @param position The position of the point light in the scene
  48669. * @param scene The scene the lights belongs to
  48670. */
  48671. constructor(name: string, position: Vector3, scene: Scene);
  48672. /**
  48673. * Returns the string "PointLight"
  48674. * @returns the class name
  48675. */
  48676. getClassName(): string;
  48677. /**
  48678. * Returns the integer 0.
  48679. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  48680. */
  48681. getTypeID(): number;
  48682. /**
  48683. * Specifies wether or not the shadowmap should be a cube texture.
  48684. * @returns true if the shadowmap needs to be a cube texture.
  48685. */
  48686. needCube(): boolean;
  48687. /**
  48688. * Returns a new Vector3 aligned with the PointLight cube system according to the passed cube face index (integer).
  48689. * @param faceIndex The index of the face we are computed the direction to generate shadow
  48690. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  48691. */
  48692. getShadowDirection(faceIndex?: number): Vector3;
  48693. /**
  48694. * Sets the passed matrix "matrix" as a left-handed perspective projection matrix with the following settings :
  48695. * - fov = PI / 2
  48696. * - aspect ratio : 1.0
  48697. * - z-near and far equal to the active camera minZ and maxZ.
  48698. * Returns the PointLight.
  48699. */
  48700. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  48701. protected _buildUniformLayout(): void;
  48702. /**
  48703. * Sets the passed Effect "effect" with the PointLight transformed position (or position, if none) and passed name (string).
  48704. * @param effect The effect to update
  48705. * @param lightIndex The index of the light in the effect to update
  48706. * @returns The point light
  48707. */
  48708. transferToEffect(effect: Effect, lightIndex: string): PointLight;
  48709. /**
  48710. * Prepares the list of defines specific to the light type.
  48711. * @param defines the list of defines
  48712. * @param lightIndex defines the index of the light for the effect
  48713. */
  48714. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  48715. }
  48716. }
  48717. declare module "babylonjs/Lights/spotLight" {
  48718. import { Nullable } from "babylonjs/types";
  48719. import { Scene } from "babylonjs/scene";
  48720. import { Matrix, Vector3 } from "babylonjs/Maths/math";
  48721. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  48722. import { Effect } from "babylonjs/Materials/effect";
  48723. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  48724. import { ShadowLight } from "babylonjs/Lights/shadowLight";
  48725. /**
  48726. * A spot light is defined by a position, a direction, an angle, and an exponent.
  48727. * These values define a cone of light starting from the position, emitting toward the direction.
  48728. * The angle, in radians, defines the size (field of illumination) of the spotlight's conical beam,
  48729. * and the exponent defines the speed of the decay of the light with distance (reach).
  48730. * Documentation: https://doc.babylonjs.com/babylon101/lights
  48731. */
  48732. export class SpotLight extends ShadowLight {
  48733. private _angle;
  48734. private _innerAngle;
  48735. private _cosHalfAngle;
  48736. private _lightAngleScale;
  48737. private _lightAngleOffset;
  48738. /**
  48739. * Gets the cone angle of the spot light in Radians.
  48740. */
  48741. /**
  48742. * Sets the cone angle of the spot light in Radians.
  48743. */
  48744. angle: number;
  48745. /**
  48746. * Only used in gltf falloff mode, this defines the angle where
  48747. * the directional falloff will start before cutting at angle which could be seen
  48748. * as outer angle.
  48749. */
  48750. /**
  48751. * Only used in gltf falloff mode, this defines the angle where
  48752. * the directional falloff will start before cutting at angle which could be seen
  48753. * as outer angle.
  48754. */
  48755. innerAngle: number;
  48756. private _shadowAngleScale;
  48757. /**
  48758. * Allows scaling the angle of the light for shadow generation only.
  48759. */
  48760. /**
  48761. * Allows scaling the angle of the light for shadow generation only.
  48762. */
  48763. shadowAngleScale: number;
  48764. /**
  48765. * The light decay speed with the distance from the emission spot.
  48766. */
  48767. exponent: number;
  48768. private _projectionTextureMatrix;
  48769. /**
  48770. * Allows reading the projecton texture
  48771. */
  48772. readonly projectionTextureMatrix: Matrix;
  48773. protected _projectionTextureLightNear: number;
  48774. /**
  48775. * Gets the near clip of the Spotlight for texture projection.
  48776. */
  48777. /**
  48778. * Sets the near clip of the Spotlight for texture projection.
  48779. */
  48780. projectionTextureLightNear: number;
  48781. protected _projectionTextureLightFar: number;
  48782. /**
  48783. * Gets the far clip of the Spotlight for texture projection.
  48784. */
  48785. /**
  48786. * Sets the far clip of the Spotlight for texture projection.
  48787. */
  48788. projectionTextureLightFar: number;
  48789. protected _projectionTextureUpDirection: Vector3;
  48790. /**
  48791. * Gets the Up vector of the Spotlight for texture projection.
  48792. */
  48793. /**
  48794. * Sets the Up vector of the Spotlight for texture projection.
  48795. */
  48796. projectionTextureUpDirection: Vector3;
  48797. private _projectionTexture;
  48798. /**
  48799. * Gets the projection texture of the light.
  48800. */
  48801. /**
  48802. * Sets the projection texture of the light.
  48803. */
  48804. projectionTexture: Nullable<BaseTexture>;
  48805. private _projectionTextureViewLightDirty;
  48806. private _projectionTextureProjectionLightDirty;
  48807. private _projectionTextureDirty;
  48808. private _projectionTextureViewTargetVector;
  48809. private _projectionTextureViewLightMatrix;
  48810. private _projectionTextureProjectionLightMatrix;
  48811. private _projectionTextureScalingMatrix;
  48812. /**
  48813. * Creates a SpotLight object in the scene. A spot light is a simply light oriented cone.
  48814. * It can cast shadows.
  48815. * Documentation : https://doc.babylonjs.com/babylon101/lights
  48816. * @param name The light friendly name
  48817. * @param position The position of the spot light in the scene
  48818. * @param direction The direction of the light in the scene
  48819. * @param angle The cone angle of the light in Radians
  48820. * @param exponent The light decay speed with the distance from the emission spot
  48821. * @param scene The scene the lights belongs to
  48822. */
  48823. constructor(name: string, position: Vector3, direction: Vector3, angle: number, exponent: number, scene: Scene);
  48824. /**
  48825. * Returns the string "SpotLight".
  48826. * @returns the class name
  48827. */
  48828. getClassName(): string;
  48829. /**
  48830. * Returns the integer 2.
  48831. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  48832. */
  48833. getTypeID(): number;
  48834. /**
  48835. * Overrides the direction setter to recompute the projection texture view light Matrix.
  48836. */
  48837. protected _setDirection(value: Vector3): void;
  48838. /**
  48839. * Overrides the position setter to recompute the projection texture view light Matrix.
  48840. */
  48841. protected _setPosition(value: Vector3): void;
  48842. /**
  48843. * 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.
  48844. * Returns the SpotLight.
  48845. */
  48846. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  48847. protected _computeProjectionTextureViewLightMatrix(): void;
  48848. protected _computeProjectionTextureProjectionLightMatrix(): void;
  48849. /**
  48850. * Main function for light texture projection matrix computing.
  48851. */
  48852. protected _computeProjectionTextureMatrix(): void;
  48853. protected _buildUniformLayout(): void;
  48854. private _computeAngleValues;
  48855. /**
  48856. * Sets the passed Effect object with the SpotLight transfomed position (or position if not parented) and normalized direction.
  48857. * @param effect The effect to update
  48858. * @param lightIndex The index of the light in the effect to update
  48859. * @returns The spot light
  48860. */
  48861. transferToEffect(effect: Effect, lightIndex: string): SpotLight;
  48862. /**
  48863. * Disposes the light and the associated resources.
  48864. */
  48865. dispose(): void;
  48866. /**
  48867. * Prepares the list of defines specific to the light type.
  48868. * @param defines the list of defines
  48869. * @param lightIndex defines the index of the light for the effect
  48870. */
  48871. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  48872. }
  48873. }
  48874. declare module "babylonjs/Lights/index" {
  48875. export * from "babylonjs/Lights/light";
  48876. export * from "babylonjs/Lights/shadowLight";
  48877. export * from "babylonjs/Lights/Shadows/index";
  48878. export * from "babylonjs/Lights/directionalLight";
  48879. export * from "babylonjs/Lights/hemisphericLight";
  48880. export * from "babylonjs/Lights/pointLight";
  48881. export * from "babylonjs/Lights/spotLight";
  48882. }
  48883. declare module "babylonjs/Misc/HighDynamicRange/hdr" {
  48884. import { CubeMapInfo } from "babylonjs/Misc/HighDynamicRange/panoramaToCubemap";
  48885. /**
  48886. * Header information of HDR texture files.
  48887. */
  48888. export interface HDRInfo {
  48889. /**
  48890. * The height of the texture in pixels.
  48891. */
  48892. height: number;
  48893. /**
  48894. * The width of the texture in pixels.
  48895. */
  48896. width: number;
  48897. /**
  48898. * The index of the beginning of the data in the binary file.
  48899. */
  48900. dataPosition: number;
  48901. }
  48902. /**
  48903. * This groups tools to convert HDR texture to native colors array.
  48904. */
  48905. export class HDRTools {
  48906. private static Ldexp;
  48907. private static Rgbe2float;
  48908. private static readStringLine;
  48909. /**
  48910. * Reads header information from an RGBE texture stored in a native array.
  48911. * More information on this format are available here:
  48912. * https://en.wikipedia.org/wiki/RGBE_image_format
  48913. *
  48914. * @param uint8array The binary file stored in native array.
  48915. * @return The header information.
  48916. */
  48917. static RGBE_ReadHeader(uint8array: Uint8Array): HDRInfo;
  48918. /**
  48919. * Returns the cubemap information (each faces texture data) extracted from an RGBE texture.
  48920. * This RGBE texture needs to store the information as a panorama.
  48921. *
  48922. * More information on this format are available here:
  48923. * https://en.wikipedia.org/wiki/RGBE_image_format
  48924. *
  48925. * @param buffer The binary file stored in an array buffer.
  48926. * @param size The expected size of the extracted cubemap.
  48927. * @return The Cube Map information.
  48928. */
  48929. static GetCubeMapTextureData(buffer: ArrayBuffer, size: number): CubeMapInfo;
  48930. /**
  48931. * Returns the pixels data extracted from an RGBE texture.
  48932. * This pixels will be stored left to right up to down in the R G B order in one array.
  48933. *
  48934. * More information on this format are available here:
  48935. * https://en.wikipedia.org/wiki/RGBE_image_format
  48936. *
  48937. * @param uint8array The binary file stored in an array buffer.
  48938. * @param hdrInfo The header information of the file.
  48939. * @return The pixels data in RGB right to left up to down order.
  48940. */
  48941. static RGBE_ReadPixels(uint8array: Uint8Array, hdrInfo: HDRInfo): Float32Array;
  48942. private static RGBE_ReadPixels_RLE;
  48943. }
  48944. }
  48945. declare module "babylonjs/Materials/Textures/hdrCubeTexture" {
  48946. import { Nullable } from "babylonjs/types";
  48947. import { Scene } from "babylonjs/scene";
  48948. import { Matrix, Vector3 } from "babylonjs/Maths/math";
  48949. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  48950. /**
  48951. * This represents a texture coming from an HDR input.
  48952. *
  48953. * The only supported format is currently panorama picture stored in RGBE format.
  48954. * Example of such files can be found on HDRLib: http://hdrlib.com/
  48955. */
  48956. export class HDRCubeTexture extends BaseTexture {
  48957. private static _facesMapping;
  48958. private _generateHarmonics;
  48959. private _noMipmap;
  48960. private _textureMatrix;
  48961. private _size;
  48962. private _onLoad;
  48963. private _onError;
  48964. /**
  48965. * The texture URL.
  48966. */
  48967. url: string;
  48968. /**
  48969. * The texture coordinates mode. As this texture is stored in a cube format, please modify carefully.
  48970. */
  48971. coordinatesMode: number;
  48972. protected _isBlocking: boolean;
  48973. /**
  48974. * Sets wether or not the texture is blocking during loading.
  48975. */
  48976. /**
  48977. * Gets wether or not the texture is blocking during loading.
  48978. */
  48979. isBlocking: boolean;
  48980. protected _rotationY: number;
  48981. /**
  48982. * Sets texture matrix rotation angle around Y axis in radians.
  48983. */
  48984. /**
  48985. * Gets texture matrix rotation angle around Y axis radians.
  48986. */
  48987. rotationY: number;
  48988. /**
  48989. * Gets or sets the center of the bounding box associated with the cube texture
  48990. * It must define where the camera used to render the texture was set
  48991. */
  48992. boundingBoxPosition: Vector3;
  48993. private _boundingBoxSize;
  48994. /**
  48995. * Gets or sets the size of the bounding box associated with the cube texture
  48996. * When defined, the cubemap will switch to local mode
  48997. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  48998. * @example https://www.babylonjs-playground.com/#RNASML
  48999. */
  49000. boundingBoxSize: Vector3;
  49001. /**
  49002. * Instantiates an HDRTexture from the following parameters.
  49003. *
  49004. * @param url The location of the HDR raw data (Panorama stored in RGBE format)
  49005. * @param scene The scene the texture will be used in
  49006. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  49007. * @param noMipmap Forces to not generate the mipmap if true
  49008. * @param generateHarmonics Specifies whether you want to extract the polynomial harmonics during the generation process
  49009. * @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)
  49010. * @param reserved Reserved flag for internal use.
  49011. */
  49012. 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>);
  49013. /**
  49014. * Get the current class name of the texture useful for serialization or dynamic coding.
  49015. * @returns "HDRCubeTexture"
  49016. */
  49017. getClassName(): string;
  49018. /**
  49019. * Occurs when the file is raw .hdr file.
  49020. */
  49021. private loadTexture;
  49022. clone(): HDRCubeTexture;
  49023. delayLoad(): void;
  49024. /**
  49025. * Get the texture reflection matrix used to rotate/transform the reflection.
  49026. * @returns the reflection matrix
  49027. */
  49028. getReflectionTextureMatrix(): Matrix;
  49029. /**
  49030. * Set the texture reflection matrix used to rotate/transform the reflection.
  49031. * @param value Define the reflection matrix to set
  49032. */
  49033. setReflectionTextureMatrix(value: Matrix): void;
  49034. /**
  49035. * Parses a JSON representation of an HDR Texture in order to create the texture
  49036. * @param parsedTexture Define the JSON representation
  49037. * @param scene Define the scene the texture should be created in
  49038. * @param rootUrl Define the root url in case we need to load relative dependencies
  49039. * @returns the newly created texture after parsing
  49040. */
  49041. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<HDRCubeTexture>;
  49042. serialize(): any;
  49043. }
  49044. }
  49045. declare module "babylonjs/Physics/physicsEngine" {
  49046. import { Nullable } from "babylonjs/types";
  49047. import { Vector3 } from "babylonjs/Maths/math";
  49048. import { IPhysicsEngine, IPhysicsEnginePlugin } from "babylonjs/Physics/IPhysicsEngine";
  49049. import { PhysicsImpostor, IPhysicsEnabledObject } from "babylonjs/Physics/physicsImpostor";
  49050. import { PhysicsJoint } from "babylonjs/Physics/physicsJoint";
  49051. import { PhysicsRaycastResult } from "babylonjs/Physics/physicsRaycastResult";
  49052. /**
  49053. * Class used to control physics engine
  49054. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  49055. */
  49056. export class PhysicsEngine implements IPhysicsEngine {
  49057. private _physicsPlugin;
  49058. /**
  49059. * Global value used to control the smallest number supported by the simulation
  49060. */
  49061. static Epsilon: number;
  49062. private _impostors;
  49063. private _joints;
  49064. /**
  49065. * Gets the gravity vector used by the simulation
  49066. */
  49067. gravity: Vector3;
  49068. /**
  49069. * Factory used to create the default physics plugin.
  49070. * @returns The default physics plugin
  49071. */
  49072. static DefaultPluginFactory(): IPhysicsEnginePlugin;
  49073. /**
  49074. * Creates a new Physics Engine
  49075. * @param gravity defines the gravity vector used by the simulation
  49076. * @param _physicsPlugin defines the plugin to use (CannonJS by default)
  49077. */
  49078. constructor(gravity: Nullable<Vector3>, _physicsPlugin?: IPhysicsEnginePlugin);
  49079. /**
  49080. * Sets the gravity vector used by the simulation
  49081. * @param gravity defines the gravity vector to use
  49082. */
  49083. setGravity(gravity: Vector3): void;
  49084. /**
  49085. * Set the time step of the physics engine.
  49086. * Default is 1/60.
  49087. * To slow it down, enter 1/600 for example.
  49088. * To speed it up, 1/30
  49089. * @param newTimeStep defines the new timestep to apply to this world.
  49090. */
  49091. setTimeStep(newTimeStep?: number): void;
  49092. /**
  49093. * Get the time step of the physics engine.
  49094. * @returns the current time step
  49095. */
  49096. getTimeStep(): number;
  49097. /**
  49098. * Release all resources
  49099. */
  49100. dispose(): void;
  49101. /**
  49102. * Gets the name of the current physics plugin
  49103. * @returns the name of the plugin
  49104. */
  49105. getPhysicsPluginName(): string;
  49106. /**
  49107. * Adding a new impostor for the impostor tracking.
  49108. * This will be done by the impostor itself.
  49109. * @param impostor the impostor to add
  49110. */
  49111. addImpostor(impostor: PhysicsImpostor): void;
  49112. /**
  49113. * Remove an impostor from the engine.
  49114. * This impostor and its mesh will not longer be updated by the physics engine.
  49115. * @param impostor the impostor to remove
  49116. */
  49117. removeImpostor(impostor: PhysicsImpostor): void;
  49118. /**
  49119. * Add a joint to the physics engine
  49120. * @param mainImpostor defines the main impostor to which the joint is added.
  49121. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  49122. * @param joint defines the joint that will connect both impostors.
  49123. */
  49124. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  49125. /**
  49126. * Removes a joint from the simulation
  49127. * @param mainImpostor defines the impostor used with the joint
  49128. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  49129. * @param joint defines the joint to remove
  49130. */
  49131. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  49132. /**
  49133. * Called by the scene. No need to call it.
  49134. * @param delta defines the timespam between frames
  49135. */
  49136. _step(delta: number): void;
  49137. /**
  49138. * Gets the current plugin used to run the simulation
  49139. * @returns current plugin
  49140. */
  49141. getPhysicsPlugin(): IPhysicsEnginePlugin;
  49142. /**
  49143. * Gets the list of physic impostors
  49144. * @returns an array of PhysicsImpostor
  49145. */
  49146. getImpostors(): Array<PhysicsImpostor>;
  49147. /**
  49148. * Gets the impostor for a physics enabled object
  49149. * @param object defines the object impersonated by the impostor
  49150. * @returns the PhysicsImpostor or null if not found
  49151. */
  49152. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  49153. /**
  49154. * Gets the impostor for a physics body object
  49155. * @param body defines physics body used by the impostor
  49156. * @returns the PhysicsImpostor or null if not found
  49157. */
  49158. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  49159. /**
  49160. * Does a raycast in the physics world
  49161. * @param from when should the ray start?
  49162. * @param to when should the ray end?
  49163. * @returns PhysicsRaycastResult
  49164. */
  49165. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  49166. }
  49167. }
  49168. declare module "babylonjs/Physics/Plugins/cannonJSPlugin" {
  49169. import { Nullable } from "babylonjs/types";
  49170. import { Vector3, Quaternion } from "babylonjs/Maths/math";
  49171. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  49172. import { IPhysicsEnginePlugin, PhysicsImpostorJoint } from "babylonjs/Physics/IPhysicsEngine";
  49173. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  49174. import { PhysicsJoint, IMotorEnabledJoint } from "babylonjs/Physics/physicsJoint";
  49175. import { PhysicsRaycastResult } from "babylonjs/Physics/physicsRaycastResult";
  49176. /** @hidden */
  49177. export class CannonJSPlugin implements IPhysicsEnginePlugin {
  49178. private _useDeltaForWorldStep;
  49179. world: any;
  49180. name: string;
  49181. private _physicsMaterials;
  49182. private _fixedTimeStep;
  49183. private _cannonRaycastResult;
  49184. private _raycastResult;
  49185. BJSCANNON: any;
  49186. constructor(_useDeltaForWorldStep?: boolean, iterations?: number, cannonInjection?: any);
  49187. setGravity(gravity: Vector3): void;
  49188. setTimeStep(timeStep: number): void;
  49189. getTimeStep(): number;
  49190. executeStep(delta: number): void;
  49191. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  49192. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  49193. generatePhysicsBody(impostor: PhysicsImpostor): void;
  49194. private _processChildMeshes;
  49195. removePhysicsBody(impostor: PhysicsImpostor): void;
  49196. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  49197. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  49198. private _addMaterial;
  49199. private _checkWithEpsilon;
  49200. private _createShape;
  49201. private _createHeightmap;
  49202. private _minus90X;
  49203. private _plus90X;
  49204. private _tmpPosition;
  49205. private _tmpDeltaPosition;
  49206. private _tmpUnityRotation;
  49207. private _updatePhysicsBodyTransformation;
  49208. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  49209. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  49210. isSupported(): boolean;
  49211. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  49212. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  49213. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  49214. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  49215. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  49216. getBodyMass(impostor: PhysicsImpostor): number;
  49217. getBodyFriction(impostor: PhysicsImpostor): number;
  49218. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  49219. getBodyRestitution(impostor: PhysicsImpostor): number;
  49220. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  49221. sleepBody(impostor: PhysicsImpostor): void;
  49222. wakeUpBody(impostor: PhysicsImpostor): void;
  49223. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number): void;
  49224. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  49225. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  49226. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  49227. getRadius(impostor: PhysicsImpostor): number;
  49228. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  49229. dispose(): void;
  49230. private _extendNamespace;
  49231. /**
  49232. * Does a raycast in the physics world
  49233. * @param from when should the ray start?
  49234. * @param to when should the ray end?
  49235. * @returns PhysicsRaycastResult
  49236. */
  49237. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  49238. }
  49239. }
  49240. declare module "babylonjs/Physics/Plugins/oimoJSPlugin" {
  49241. import { IPhysicsEnginePlugin, PhysicsImpostorJoint } from "babylonjs/Physics/IPhysicsEngine";
  49242. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  49243. import { PhysicsJoint, IMotorEnabledJoint } from "babylonjs/Physics/physicsJoint";
  49244. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  49245. import { Vector3, Quaternion } from "babylonjs/Maths/math";
  49246. import { Nullable } from "babylonjs/types";
  49247. import { PhysicsRaycastResult } from "babylonjs/Physics/physicsRaycastResult";
  49248. /** @hidden */
  49249. export class OimoJSPlugin implements IPhysicsEnginePlugin {
  49250. world: any;
  49251. name: string;
  49252. BJSOIMO: any;
  49253. private _raycastResult;
  49254. constructor(iterations?: number, oimoInjection?: any);
  49255. setGravity(gravity: Vector3): void;
  49256. setTimeStep(timeStep: number): void;
  49257. getTimeStep(): number;
  49258. private _tmpImpostorsArray;
  49259. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  49260. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  49261. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  49262. generatePhysicsBody(impostor: PhysicsImpostor): void;
  49263. private _tmpPositionVector;
  49264. removePhysicsBody(impostor: PhysicsImpostor): void;
  49265. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  49266. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  49267. isSupported(): boolean;
  49268. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  49269. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  49270. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  49271. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  49272. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  49273. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  49274. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  49275. getBodyMass(impostor: PhysicsImpostor): number;
  49276. getBodyFriction(impostor: PhysicsImpostor): number;
  49277. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  49278. getBodyRestitution(impostor: PhysicsImpostor): number;
  49279. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  49280. sleepBody(impostor: PhysicsImpostor): void;
  49281. wakeUpBody(impostor: PhysicsImpostor): void;
  49282. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  49283. setMotor(joint: IMotorEnabledJoint, speed: number, force?: number, motorIndex?: number): void;
  49284. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  49285. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  49286. getRadius(impostor: PhysicsImpostor): number;
  49287. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  49288. dispose(): void;
  49289. /**
  49290. * Does a raycast in the physics world
  49291. * @param from when should the ray start?
  49292. * @param to when should the ray end?
  49293. * @returns PhysicsRaycastResult
  49294. */
  49295. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  49296. }
  49297. }
  49298. declare module "babylonjs/Probes/reflectionProbe" {
  49299. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  49300. import { Vector3 } from "babylonjs/Maths/math";
  49301. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  49302. import { Nullable } from "babylonjs/types";
  49303. import { Scene } from "babylonjs/scene";
  49304. module "babylonjs/abstractScene" {
  49305. interface AbstractScene {
  49306. /**
  49307. * The list of reflection probes added to the scene
  49308. * @see http://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  49309. */
  49310. reflectionProbes: Array<ReflectionProbe>;
  49311. /**
  49312. * Removes the given reflection probe from this scene.
  49313. * @param toRemove The reflection probe to remove
  49314. * @returns The index of the removed reflection probe
  49315. */
  49316. removeReflectionProbe(toRemove: ReflectionProbe): number;
  49317. /**
  49318. * Adds the given reflection probe to this scene.
  49319. * @param newReflectionProbe The reflection probe to add
  49320. */
  49321. addReflectionProbe(newReflectionProbe: ReflectionProbe): void;
  49322. }
  49323. }
  49324. /**
  49325. * Class used to generate realtime reflection / refraction cube textures
  49326. * @see http://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  49327. */
  49328. export class ReflectionProbe {
  49329. /** defines the name of the probe */
  49330. name: string;
  49331. private _scene;
  49332. private _renderTargetTexture;
  49333. private _projectionMatrix;
  49334. private _viewMatrix;
  49335. private _target;
  49336. private _add;
  49337. private _attachedMesh;
  49338. private _invertYAxis;
  49339. /** Gets or sets probe position (center of the cube map) */
  49340. position: Vector3;
  49341. /**
  49342. * Creates a new reflection probe
  49343. * @param name defines the name of the probe
  49344. * @param size defines the texture resolution (for each face)
  49345. * @param scene defines the hosting scene
  49346. * @param generateMipMaps defines if mip maps should be generated automatically (true by default)
  49347. * @param useFloat defines if HDR data (flaot data) should be used to store colors (false by default)
  49348. */
  49349. constructor(
  49350. /** defines the name of the probe */
  49351. name: string, size: number, scene: Scene, generateMipMaps?: boolean, useFloat?: boolean);
  49352. /** Gets or sets the number of samples to use for multi-sampling (0 by default). Required WebGL2 */
  49353. samples: number;
  49354. /** Gets or sets the refresh rate to use (on every frame by default) */
  49355. refreshRate: number;
  49356. /**
  49357. * Gets the hosting scene
  49358. * @returns a Scene
  49359. */
  49360. getScene(): Scene;
  49361. /** Gets the internal CubeTexture used to render to */
  49362. readonly cubeTexture: RenderTargetTexture;
  49363. /** Gets the list of meshes to render */
  49364. readonly renderList: Nullable<AbstractMesh[]>;
  49365. /**
  49366. * Attach the probe to a specific mesh (Rendering will be done from attached mesh's position)
  49367. * @param mesh defines the mesh to attach to
  49368. */
  49369. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  49370. /**
  49371. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups
  49372. * @param renderingGroupId The rendering group id corresponding to its index
  49373. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  49374. */
  49375. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  49376. /**
  49377. * Clean all associated resources
  49378. */
  49379. dispose(): void;
  49380. /**
  49381. * Converts the reflection probe information to a readable string for debug purpose.
  49382. * @param fullDetails Supports for multiple levels of logging within scene loading
  49383. * @returns the human readable reflection probe info
  49384. */
  49385. toString(fullDetails?: boolean): string;
  49386. /**
  49387. * Get the class name of the relfection probe.
  49388. * @returns "ReflectionProbe"
  49389. */
  49390. getClassName(): string;
  49391. /**
  49392. * Serialize the reflection probe to a JSON representation we can easily use in the resepective Parse function.
  49393. * @returns The JSON representation of the texture
  49394. */
  49395. serialize(): any;
  49396. /**
  49397. * Parse the JSON representation of a reflection probe in order to recreate the reflection probe in the given scene.
  49398. * @param parsedReflectionProbe Define the JSON representation of the reflection probe
  49399. * @param scene Define the scene the parsed reflection probe should be instantiated in
  49400. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  49401. * @returns The parsed reflection probe if successful
  49402. */
  49403. static Parse(parsedReflectionProbe: any, scene: Scene, rootUrl: string): Nullable<ReflectionProbe>;
  49404. }
  49405. }
  49406. declare module "babylonjs/Loading/Plugins/babylonFileLoader" {
  49407. /** @hidden */
  49408. export var _BabylonLoaderRegistered: boolean;
  49409. }
  49410. declare module "babylonjs/Loading/Plugins/index" {
  49411. export * from "babylonjs/Loading/Plugins/babylonFileLoader";
  49412. }
  49413. declare module "babylonjs/Loading/index" {
  49414. export * from "babylonjs/Loading/loadingScreen";
  49415. export * from "babylonjs/Loading/Plugins/index";
  49416. export * from "babylonjs/Loading/sceneLoader";
  49417. export * from "babylonjs/Loading/sceneLoaderFlags";
  49418. }
  49419. declare module "babylonjs/Materials/Background/index" {
  49420. export * from "babylonjs/Materials/Background/backgroundMaterial";
  49421. }
  49422. declare module "babylonjs/Materials/PBR/pbrBaseSimpleMaterial" {
  49423. import { Scene } from "babylonjs/scene";
  49424. import { Color3 } from "babylonjs/Maths/math";
  49425. import { PBRBaseMaterial } from "babylonjs/Materials/PBR/pbrBaseMaterial";
  49426. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  49427. /**
  49428. * The Physically based simple base material of BJS.
  49429. *
  49430. * This enables better naming and convention enforcements on top of the pbrMaterial.
  49431. * It is used as the base class for both the specGloss and metalRough conventions.
  49432. */
  49433. export abstract class PBRBaseSimpleMaterial extends PBRBaseMaterial {
  49434. /**
  49435. * Number of Simultaneous lights allowed on the material.
  49436. */
  49437. maxSimultaneousLights: number;
  49438. /**
  49439. * If sets to true, disables all the lights affecting the material.
  49440. */
  49441. disableLighting: boolean;
  49442. /**
  49443. * Environment Texture used in the material (this is use for both reflection and environment lighting).
  49444. */
  49445. environmentTexture: BaseTexture;
  49446. /**
  49447. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  49448. */
  49449. invertNormalMapX: boolean;
  49450. /**
  49451. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  49452. */
  49453. invertNormalMapY: boolean;
  49454. /**
  49455. * Normal map used in the model.
  49456. */
  49457. normalTexture: BaseTexture;
  49458. /**
  49459. * Emissivie color used to self-illuminate the model.
  49460. */
  49461. emissiveColor: Color3;
  49462. /**
  49463. * Emissivie texture used to self-illuminate the model.
  49464. */
  49465. emissiveTexture: BaseTexture;
  49466. /**
  49467. * Occlusion Channel Strenght.
  49468. */
  49469. occlusionStrength: number;
  49470. /**
  49471. * Occlusion Texture of the material (adding extra occlusion effects).
  49472. */
  49473. occlusionTexture: BaseTexture;
  49474. /**
  49475. * Defines the alpha limits in alpha test mode.
  49476. */
  49477. alphaCutOff: number;
  49478. /**
  49479. * Gets the current double sided mode.
  49480. */
  49481. /**
  49482. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  49483. */
  49484. doubleSided: boolean;
  49485. /**
  49486. * Stores the pre-calculated light information of a mesh in a texture.
  49487. */
  49488. lightmapTexture: BaseTexture;
  49489. /**
  49490. * If true, the light map contains occlusion information instead of lighting info.
  49491. */
  49492. useLightmapAsShadowmap: boolean;
  49493. /**
  49494. * Instantiates a new PBRMaterial instance.
  49495. *
  49496. * @param name The material name
  49497. * @param scene The scene the material will be use in.
  49498. */
  49499. constructor(name: string, scene: Scene);
  49500. getClassName(): string;
  49501. }
  49502. }
  49503. declare module "babylonjs/Materials/PBR/pbrMetallicRoughnessMaterial" {
  49504. import { Scene } from "babylonjs/scene";
  49505. import { Color3 } from "babylonjs/Maths/math";
  49506. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  49507. import { PBRBaseSimpleMaterial } from "babylonjs/Materials/PBR/pbrBaseSimpleMaterial";
  49508. /**
  49509. * The PBR material of BJS following the metal roughness convention.
  49510. *
  49511. * This fits to the PBR convention in the GLTF definition:
  49512. * https://github.com/KhronosGroup/glTF/tree/2.0/specification/2.0
  49513. */
  49514. export class PBRMetallicRoughnessMaterial extends PBRBaseSimpleMaterial {
  49515. /**
  49516. * The base color has two different interpretations depending on the value of metalness.
  49517. * When the material is a metal, the base color is the specific measured reflectance value
  49518. * at normal incidence (F0). For a non-metal the base color represents the reflected diffuse color
  49519. * of the material.
  49520. */
  49521. baseColor: Color3;
  49522. /**
  49523. * Base texture of the metallic workflow. It contains both the baseColor information in RGB as
  49524. * well as opacity information in the alpha channel.
  49525. */
  49526. baseTexture: BaseTexture;
  49527. /**
  49528. * Specifies the metallic scalar value of the material.
  49529. * Can also be used to scale the metalness values of the metallic texture.
  49530. */
  49531. metallic: number;
  49532. /**
  49533. * Specifies the roughness scalar value of the material.
  49534. * Can also be used to scale the roughness values of the metallic texture.
  49535. */
  49536. roughness: number;
  49537. /**
  49538. * Texture containing both the metallic value in the B channel and the
  49539. * roughness value in the G channel to keep better precision.
  49540. */
  49541. metallicRoughnessTexture: BaseTexture;
  49542. /**
  49543. * Instantiates a new PBRMetalRoughnessMaterial instance.
  49544. *
  49545. * @param name The material name
  49546. * @param scene The scene the material will be use in.
  49547. */
  49548. constructor(name: string, scene: Scene);
  49549. /**
  49550. * Return the currrent class name of the material.
  49551. */
  49552. getClassName(): string;
  49553. /**
  49554. * Makes a duplicate of the current material.
  49555. * @param name - name to use for the new material.
  49556. */
  49557. clone(name: string): PBRMetallicRoughnessMaterial;
  49558. /**
  49559. * Serialize the material to a parsable JSON object.
  49560. */
  49561. serialize(): any;
  49562. /**
  49563. * Parses a JSON object correponding to the serialize function.
  49564. */
  49565. static Parse(source: any, scene: Scene, rootUrl: string): PBRMetallicRoughnessMaterial;
  49566. }
  49567. }
  49568. declare module "babylonjs/Materials/PBR/pbrSpecularGlossinessMaterial" {
  49569. import { Scene } from "babylonjs/scene";
  49570. import { Color3 } from "babylonjs/Maths/math";
  49571. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  49572. import { PBRBaseSimpleMaterial } from "babylonjs/Materials/PBR/pbrBaseSimpleMaterial";
  49573. /**
  49574. * The PBR material of BJS following the specular glossiness convention.
  49575. *
  49576. * This fits to the PBR convention in the GLTF definition:
  49577. * https://github.com/KhronosGroup/glTF/tree/2.0/extensions/Khronos/KHR_materials_pbrSpecularGlossiness
  49578. */
  49579. export class PBRSpecularGlossinessMaterial extends PBRBaseSimpleMaterial {
  49580. /**
  49581. * Specifies the diffuse color of the material.
  49582. */
  49583. diffuseColor: Color3;
  49584. /**
  49585. * Specifies the diffuse texture of the material. This can also contains the opcity value in its alpha
  49586. * channel.
  49587. */
  49588. diffuseTexture: BaseTexture;
  49589. /**
  49590. * Specifies the specular color of the material. This indicates how reflective is the material (none to mirror).
  49591. */
  49592. specularColor: Color3;
  49593. /**
  49594. * Specifies the glossiness of the material. This indicates "how sharp is the reflection".
  49595. */
  49596. glossiness: number;
  49597. /**
  49598. * Specifies both the specular color RGB and the glossiness A of the material per pixels.
  49599. */
  49600. specularGlossinessTexture: BaseTexture;
  49601. /**
  49602. * Instantiates a new PBRSpecularGlossinessMaterial instance.
  49603. *
  49604. * @param name The material name
  49605. * @param scene The scene the material will be use in.
  49606. */
  49607. constructor(name: string, scene: Scene);
  49608. /**
  49609. * Return the currrent class name of the material.
  49610. */
  49611. getClassName(): string;
  49612. /**
  49613. * Makes a duplicate of the current material.
  49614. * @param name - name to use for the new material.
  49615. */
  49616. clone(name: string): PBRSpecularGlossinessMaterial;
  49617. /**
  49618. * Serialize the material to a parsable JSON object.
  49619. */
  49620. serialize(): any;
  49621. /**
  49622. * Parses a JSON object correponding to the serialize function.
  49623. */
  49624. static Parse(source: any, scene: Scene, rootUrl: string): PBRSpecularGlossinessMaterial;
  49625. }
  49626. }
  49627. declare module "babylonjs/Materials/PBR/index" {
  49628. export * from "babylonjs/Materials/PBR/pbrBaseMaterial";
  49629. export * from "babylonjs/Materials/PBR/pbrBaseSimpleMaterial";
  49630. export * from "babylonjs/Materials/PBR/pbrMaterial";
  49631. export * from "babylonjs/Materials/PBR/pbrMetallicRoughnessMaterial";
  49632. export * from "babylonjs/Materials/PBR/pbrSpecularGlossinessMaterial";
  49633. }
  49634. declare module "babylonjs/Materials/Textures/colorGradingTexture" {
  49635. import { Nullable } from "babylonjs/types";
  49636. import { Scene } from "babylonjs/scene";
  49637. import { Matrix } from "babylonjs/Maths/math";
  49638. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  49639. /**
  49640. * This represents a color grading texture. This acts as a lookup table LUT, useful during post process
  49641. * It can help converting any input color in a desired output one. This can then be used to create effects
  49642. * from sepia, black and white to sixties or futuristic rendering...
  49643. *
  49644. * The only supported format is currently 3dl.
  49645. * More information on LUT: https://en.wikipedia.org/wiki/3D_lookup_table
  49646. */
  49647. export class ColorGradingTexture extends BaseTexture {
  49648. /**
  49649. * The current texture matrix. (will always be identity in color grading texture)
  49650. */
  49651. private _textureMatrix;
  49652. /**
  49653. * The texture URL.
  49654. */
  49655. url: string;
  49656. /**
  49657. * Empty line regex stored for GC.
  49658. */
  49659. private static _noneEmptyLineRegex;
  49660. private _engine;
  49661. /**
  49662. * Instantiates a ColorGradingTexture from the following parameters.
  49663. *
  49664. * @param url The location of the color gradind data (currently only supporting 3dl)
  49665. * @param scene The scene the texture will be used in
  49666. */
  49667. constructor(url: string, scene: Scene);
  49668. /**
  49669. * Returns the texture matrix used in most of the material.
  49670. * This is not used in color grading but keep for troubleshooting purpose (easily swap diffuse by colorgrading to look in).
  49671. */
  49672. getTextureMatrix(): Matrix;
  49673. /**
  49674. * Occurs when the file being loaded is a .3dl LUT file.
  49675. */
  49676. private load3dlTexture;
  49677. /**
  49678. * Starts the loading process of the texture.
  49679. */
  49680. private loadTexture;
  49681. /**
  49682. * Clones the color gradind texture.
  49683. */
  49684. clone(): ColorGradingTexture;
  49685. /**
  49686. * Called during delayed load for textures.
  49687. */
  49688. delayLoad(): void;
  49689. /**
  49690. * Parses a color grading texture serialized by Babylon.
  49691. * @param parsedTexture The texture information being parsedTexture
  49692. * @param scene The scene to load the texture in
  49693. * @param rootUrl The root url of the data assets to load
  49694. * @return A color gradind texture
  49695. */
  49696. static Parse(parsedTexture: any, scene: Scene): Nullable<ColorGradingTexture>;
  49697. /**
  49698. * Serializes the LUT texture to json format.
  49699. */
  49700. serialize(): any;
  49701. }
  49702. }
  49703. declare module "babylonjs/Materials/Textures/equiRectangularCubeTexture" {
  49704. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  49705. import { Scene } from "babylonjs/scene";
  49706. import { Nullable } from "babylonjs/types";
  49707. /**
  49708. * This represents a texture coming from an equirectangular image supported by the web browser canvas.
  49709. */
  49710. export class EquiRectangularCubeTexture extends BaseTexture {
  49711. /** The six faces of the cube. */
  49712. private static _FacesMapping;
  49713. private _noMipmap;
  49714. private _onLoad;
  49715. private _onError;
  49716. /** The size of the cubemap. */
  49717. private _size;
  49718. /** The buffer of the image. */
  49719. private _buffer;
  49720. /** The width of the input image. */
  49721. private _width;
  49722. /** The height of the input image. */
  49723. private _height;
  49724. /** The URL to the image. */
  49725. url: string;
  49726. /** The texture coordinates mode. As this texture is stored in a cube format, please modify carefully. */
  49727. coordinatesMode: number;
  49728. /**
  49729. * Instantiates an EquiRectangularCubeTexture from the following parameters.
  49730. * @param url The location of the image
  49731. * @param scene The scene the texture will be used in
  49732. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  49733. * @param noMipmap Forces to not generate the mipmap if true
  49734. * @param gammaSpace Specifies if the texture will be used in gamma or linear space
  49735. * (the PBR material requires those textures in linear space, but the standard material would require them in Gamma space)
  49736. * @param onLoad — defines a callback called when texture is loaded
  49737. * @param onError — defines a callback called if there is an error
  49738. */
  49739. constructor(url: string, scene: Scene, size: number, noMipmap?: boolean, gammaSpace?: boolean, onLoad?: Nullable<() => void>, onError?: Nullable<(message?: string, exception?: any) => void>);
  49740. /**
  49741. * Load the image data, by putting the image on a canvas and extracting its buffer.
  49742. */
  49743. private loadImage;
  49744. /**
  49745. * Convert the image buffer into a cubemap and create a CubeTexture.
  49746. */
  49747. private loadTexture;
  49748. /**
  49749. * Convert the ArrayBuffer into a Float32Array and drop the transparency channel.
  49750. * @param buffer The ArrayBuffer that should be converted.
  49751. * @returns The buffer as Float32Array.
  49752. */
  49753. private getFloat32ArrayFromArrayBuffer;
  49754. /**
  49755. * Get the current class name of the texture useful for serialization or dynamic coding.
  49756. * @returns "EquiRectangularCubeTexture"
  49757. */
  49758. getClassName(): string;
  49759. /**
  49760. * Create a clone of the current EquiRectangularCubeTexture and return it.
  49761. * @returns A clone of the current EquiRectangularCubeTexture.
  49762. */
  49763. clone(): EquiRectangularCubeTexture;
  49764. }
  49765. }
  49766. declare module "babylonjs/Misc/tga" {
  49767. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  49768. /**
  49769. * Based on jsTGALoader - Javascript loader for TGA file
  49770. * By Vincent Thibault
  49771. * @see http://blog.robrowser.com/javascript-tga-loader.html
  49772. */
  49773. export class TGATools {
  49774. private static _TYPE_INDEXED;
  49775. private static _TYPE_RGB;
  49776. private static _TYPE_GREY;
  49777. private static _TYPE_RLE_INDEXED;
  49778. private static _TYPE_RLE_RGB;
  49779. private static _TYPE_RLE_GREY;
  49780. private static _ORIGIN_MASK;
  49781. private static _ORIGIN_SHIFT;
  49782. private static _ORIGIN_BL;
  49783. private static _ORIGIN_BR;
  49784. private static _ORIGIN_UL;
  49785. private static _ORIGIN_UR;
  49786. /**
  49787. * Gets the header of a TGA file
  49788. * @param data defines the TGA data
  49789. * @returns the header
  49790. */
  49791. static GetTGAHeader(data: Uint8Array): any;
  49792. /**
  49793. * Uploads TGA content to a Babylon Texture
  49794. * @hidden
  49795. */
  49796. static UploadContent(texture: InternalTexture, data: Uint8Array): void;
  49797. /** @hidden */
  49798. 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;
  49799. /** @hidden */
  49800. 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;
  49801. /** @hidden */
  49802. 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;
  49803. /** @hidden */
  49804. 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;
  49805. /** @hidden */
  49806. 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;
  49807. /** @hidden */
  49808. 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;
  49809. }
  49810. }
  49811. declare module "babylonjs/Materials/Textures/Loaders/tgaTextureLoader" {
  49812. import { Nullable } from "babylonjs/types";
  49813. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  49814. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  49815. /**
  49816. * Implementation of the TGA Texture Loader.
  49817. * @hidden
  49818. */
  49819. export class _TGATextureLoader implements IInternalTextureLoader {
  49820. /**
  49821. * Defines wether the loader supports cascade loading the different faces.
  49822. */
  49823. readonly supportCascades: boolean;
  49824. /**
  49825. * This returns if the loader support the current file information.
  49826. * @param extension defines the file extension of the file being loaded
  49827. * @param textureFormatInUse defines the current compressed format in use iun the engine
  49828. * @param fallback defines the fallback internal texture if any
  49829. * @param isBase64 defines whether the texture is encoded as a base64
  49830. * @param isBuffer defines whether the texture data are stored as a buffer
  49831. * @returns true if the loader can load the specified file
  49832. */
  49833. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  49834. /**
  49835. * Transform the url before loading if required.
  49836. * @param rootUrl the url of the texture
  49837. * @param textureFormatInUse defines the current compressed format in use iun the engine
  49838. * @returns the transformed texture
  49839. */
  49840. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  49841. /**
  49842. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  49843. * @param rootUrl the url of the texture
  49844. * @param textureFormatInUse defines the current compressed format in use iun the engine
  49845. * @returns the fallback texture
  49846. */
  49847. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  49848. /**
  49849. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  49850. * @param data contains the texture data
  49851. * @param texture defines the BabylonJS internal texture
  49852. * @param createPolynomials will be true if polynomials have been requested
  49853. * @param onLoad defines the callback to trigger once the texture is ready
  49854. * @param onError defines the callback to trigger in case of error
  49855. */
  49856. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  49857. /**
  49858. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  49859. * @param data contains the texture data
  49860. * @param texture defines the BabylonJS internal texture
  49861. * @param callback defines the method to call once ready to upload
  49862. */
  49863. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  49864. }
  49865. }
  49866. declare module "babylonjs/Materials/Textures/Loaders/index" {
  49867. export * from "babylonjs/Materials/Textures/Loaders/ddsTextureLoader";
  49868. export * from "babylonjs/Materials/Textures/Loaders/envTextureLoader";
  49869. export * from "babylonjs/Materials/Textures/Loaders/ktxTextureLoader";
  49870. export * from "babylonjs/Materials/Textures/Loaders/tgaTextureLoader";
  49871. }
  49872. declare module "babylonjs/Materials/Textures/Procedurals/customProceduralTexture" {
  49873. import { Scene } from "babylonjs/scene";
  49874. import { Texture } from "babylonjs/Materials/Textures/texture";
  49875. import { ProceduralTexture } from "babylonjs/Materials/Textures/Procedurals/proceduralTexture";
  49876. /**
  49877. * 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.
  49878. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  49879. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  49880. */
  49881. export class CustomProceduralTexture extends ProceduralTexture {
  49882. private _animate;
  49883. private _time;
  49884. private _config;
  49885. private _texturePath;
  49886. /**
  49887. * Instantiates a new Custom Procedural Texture.
  49888. * 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.
  49889. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  49890. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  49891. * @param name Define the name of the texture
  49892. * @param texturePath Define the folder path containing all the cutom texture related files (config, shaders...)
  49893. * @param size Define the size of the texture to create
  49894. * @param scene Define the scene the texture belongs to
  49895. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  49896. * @param generateMipMaps Define if the texture should creates mip maps or not
  49897. */
  49898. constructor(name: string, texturePath: string, size: number, scene: Scene, fallbackTexture?: Texture, generateMipMaps?: boolean);
  49899. private _loadJson;
  49900. /**
  49901. * Is the texture ready to be used ? (rendered at least once)
  49902. * @returns true if ready, otherwise, false.
  49903. */
  49904. isReady(): boolean;
  49905. /**
  49906. * Render the texture to its associated render target.
  49907. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  49908. */
  49909. render(useCameraPostProcess?: boolean): void;
  49910. /**
  49911. * Update the list of dependant textures samplers in the shader.
  49912. */
  49913. updateTextures(): void;
  49914. /**
  49915. * Update the uniform values of the procedural texture in the shader.
  49916. */
  49917. updateShaderUniforms(): void;
  49918. /**
  49919. * Define if the texture animates or not.
  49920. */
  49921. animate: boolean;
  49922. }
  49923. }
  49924. declare module "babylonjs/Shaders/noise.fragment" {
  49925. /** @hidden */
  49926. export var noisePixelShader: {
  49927. name: string;
  49928. shader: string;
  49929. };
  49930. }
  49931. declare module "babylonjs/Materials/Textures/Procedurals/noiseProceduralTexture" {
  49932. import { Nullable } from "babylonjs/types";
  49933. import { Scene } from "babylonjs/scene";
  49934. import { Texture } from "babylonjs/Materials/Textures/texture";
  49935. import { ProceduralTexture } from "babylonjs/Materials/Textures/Procedurals/proceduralTexture";
  49936. import "babylonjs/Shaders/noise.fragment";
  49937. /**
  49938. * Class used to generate noise procedural textures
  49939. */
  49940. export class NoiseProceduralTexture extends ProceduralTexture {
  49941. private _time;
  49942. /** Gets or sets a value between 0 and 1 indicating the overall brightness of the texture (default is 0.2) */
  49943. brightness: number;
  49944. /** Defines the number of octaves to process */
  49945. octaves: number;
  49946. /** Defines the level of persistence (0.8 by default) */
  49947. persistence: number;
  49948. /** Gets or sets animation speed factor (default is 1) */
  49949. animationSpeedFactor: number;
  49950. /**
  49951. * Creates a new NoiseProceduralTexture
  49952. * @param name defines the name fo the texture
  49953. * @param size defines the size of the texture (default is 256)
  49954. * @param scene defines the hosting scene
  49955. * @param fallbackTexture defines the texture to use if the NoiseProceduralTexture can't be created
  49956. * @param generateMipMaps defines if mipmaps must be generated (true by default)
  49957. */
  49958. constructor(name: string, size?: number, scene?: Nullable<Scene>, fallbackTexture?: Texture, generateMipMaps?: boolean);
  49959. private _updateShaderUniforms;
  49960. protected _getDefines(): string;
  49961. /** Generate the current state of the procedural texture */
  49962. render(useCameraPostProcess?: boolean): void;
  49963. /**
  49964. * Serializes this noise procedural texture
  49965. * @returns a serialized noise procedural texture object
  49966. */
  49967. serialize(): any;
  49968. /**
  49969. * Creates a NoiseProceduralTexture from parsed noise procedural texture data
  49970. * @param parsedTexture defines parsed texture data
  49971. * @param scene defines the current scene
  49972. * @param rootUrl defines the root URL containing noise procedural texture information
  49973. * @returns a parsed NoiseProceduralTexture
  49974. */
  49975. static Parse(parsedTexture: any, scene: Scene): NoiseProceduralTexture;
  49976. }
  49977. }
  49978. declare module "babylonjs/Materials/Textures/Procedurals/index" {
  49979. export * from "babylonjs/Materials/Textures/Procedurals/customProceduralTexture";
  49980. export * from "babylonjs/Materials/Textures/Procedurals/noiseProceduralTexture";
  49981. export * from "babylonjs/Materials/Textures/Procedurals/proceduralTexture";
  49982. export * from "babylonjs/Materials/Textures/Procedurals/proceduralTextureSceneComponent";
  49983. }
  49984. declare module "babylonjs/Materials/Textures/rawCubeTexture" {
  49985. import { Nullable } from "babylonjs/types";
  49986. import { Scene } from "babylonjs/scene";
  49987. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  49988. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  49989. import { CubeTexture } from "babylonjs/Materials/Textures/cubeTexture";
  49990. /**
  49991. * Raw cube texture where the raw buffers are passed in
  49992. */
  49993. export class RawCubeTexture extends CubeTexture {
  49994. /**
  49995. * Creates a cube texture where the raw buffers are passed in.
  49996. * @param scene defines the scene the texture is attached to
  49997. * @param data defines the array of data to use to create each face
  49998. * @param size defines the size of the textures
  49999. * @param format defines the format of the data
  50000. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  50001. * @param generateMipMaps defines if the engine should generate the mip levels
  50002. * @param invertY defines if data must be stored with Y axis inverted
  50003. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  50004. * @param compression defines the compression used (null by default)
  50005. */
  50006. constructor(scene: Scene, data: Nullable<ArrayBufferView[]>, size: number, format?: number, type?: number, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, compression?: Nullable<string>);
  50007. /**
  50008. * Updates the raw cube texture.
  50009. * @param data defines the data to store
  50010. * @param format defines the data format
  50011. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  50012. * @param invertY defines if data must be stored with Y axis inverted
  50013. * @param compression defines the compression used (null by default)
  50014. * @param level defines which level of the texture to update
  50015. */
  50016. update(data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression?: Nullable<string>): void;
  50017. /**
  50018. * Updates a raw cube texture with RGBD encoded data.
  50019. * @param data defines the array of data [mipmap][face] to use to create each face
  50020. * @param sphericalPolynomial defines the spherical polynomial for irradiance
  50021. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  50022. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  50023. * @returns a promsie that resolves when the operation is complete
  50024. */
  50025. updateRGBDAsync(data: ArrayBufferView[][], sphericalPolynomial?: Nullable<SphericalPolynomial>, lodScale?: number, lodOffset?: number): Promise<void>;
  50026. /**
  50027. * Clones the raw cube texture.
  50028. * @return a new cube texture
  50029. */
  50030. clone(): CubeTexture;
  50031. /** @hidden */
  50032. static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  50033. }
  50034. }
  50035. declare module "babylonjs/Materials/Textures/rawTexture3D" {
  50036. import { Scene } from "babylonjs/scene";
  50037. import { Texture } from "babylonjs/Materials/Textures/texture";
  50038. /**
  50039. * Class used to store 3D textures containing user data
  50040. */
  50041. export class RawTexture3D extends Texture {
  50042. /** Gets or sets the texture format to use */
  50043. format: number;
  50044. private _engine;
  50045. /**
  50046. * Create a new RawTexture3D
  50047. * @param data defines the data of the texture
  50048. * @param width defines the width of the texture
  50049. * @param height defines the height of the texture
  50050. * @param depth defines the depth of the texture
  50051. * @param format defines the texture format to use
  50052. * @param scene defines the hosting scene
  50053. * @param generateMipMaps defines a boolean indicating if mip levels should be generated (true by default)
  50054. * @param invertY defines if texture must be stored with Y axis inverted
  50055. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  50056. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  50057. */
  50058. constructor(data: ArrayBufferView, width: number, height: number, depth: number,
  50059. /** Gets or sets the texture format to use */
  50060. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, textureType?: number);
  50061. /**
  50062. * Update the texture with new data
  50063. * @param data defines the data to store in the texture
  50064. */
  50065. update(data: ArrayBufferView): void;
  50066. }
  50067. }
  50068. declare module "babylonjs/Materials/Textures/refractionTexture" {
  50069. import { Scene } from "babylonjs/scene";
  50070. import { Plane } from "babylonjs/Maths/math";
  50071. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  50072. /**
  50073. * Creates a refraction texture used by refraction channel of the standard material.
  50074. * It is like a mirror but to see through a material.
  50075. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  50076. */
  50077. export class RefractionTexture extends RenderTargetTexture {
  50078. /**
  50079. * Define the reflection plane we want to use. The refractionPlane is usually set to the constructed refractor.
  50080. * 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.
  50081. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  50082. */
  50083. refractionPlane: Plane;
  50084. /**
  50085. * Define how deep under the surface we should see.
  50086. */
  50087. depth: number;
  50088. /**
  50089. * Creates a refraction texture used by refraction channel of the standard material.
  50090. * It is like a mirror but to see through a material.
  50091. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  50092. * @param name Define the texture name
  50093. * @param size Define the size of the underlying texture
  50094. * @param scene Define the scene the refraction belongs to
  50095. * @param generateMipMaps Define if we need to generate mips level for the refraction
  50096. */
  50097. constructor(name: string, size: number, scene: Scene, generateMipMaps?: boolean);
  50098. /**
  50099. * Clone the refraction texture.
  50100. * @returns the cloned texture
  50101. */
  50102. clone(): RefractionTexture;
  50103. /**
  50104. * Serialize the texture to a JSON representation you could use in Parse later on
  50105. * @returns the serialized JSON representation
  50106. */
  50107. serialize(): any;
  50108. }
  50109. }
  50110. declare module "babylonjs/Materials/Textures/index" {
  50111. export * from "babylonjs/Materials/Textures/baseTexture";
  50112. export * from "babylonjs/Materials/Textures/colorGradingTexture";
  50113. export * from "babylonjs/Materials/Textures/cubeTexture";
  50114. export * from "babylonjs/Materials/Textures/dynamicTexture";
  50115. export * from "babylonjs/Materials/Textures/equiRectangularCubeTexture";
  50116. export * from "babylonjs/Materials/Textures/hdrCubeTexture";
  50117. export * from "babylonjs/Materials/Textures/internalTexture";
  50118. export * from "babylonjs/Materials/Textures/internalTextureLoader";
  50119. export * from "babylonjs/Materials/Textures/internalTextureTracker";
  50120. export * from "babylonjs/Materials/Textures/Loaders/index";
  50121. export * from "babylonjs/Materials/Textures/mirrorTexture";
  50122. export * from "babylonjs/Materials/Textures/multiRenderTarget";
  50123. export * from "babylonjs/Materials/Textures/Procedurals/index";
  50124. export * from "babylonjs/Materials/Textures/rawCubeTexture";
  50125. export * from "babylonjs/Materials/Textures/rawTexture";
  50126. export * from "babylonjs/Materials/Textures/rawTexture3D";
  50127. export * from "babylonjs/Materials/Textures/refractionTexture";
  50128. export * from "babylonjs/Materials/Textures/renderTargetTexture";
  50129. export * from "babylonjs/Materials/Textures/texture";
  50130. export * from "babylonjs/Materials/Textures/videoTexture";
  50131. }
  50132. declare module "babylonjs/Materials/index" {
  50133. export * from "babylonjs/Materials/Background/index";
  50134. export * from "babylonjs/Materials/colorCurves";
  50135. export * from "babylonjs/Materials/effect";
  50136. export * from "babylonjs/Materials/fresnelParameters";
  50137. export * from "babylonjs/Materials/imageProcessingConfiguration";
  50138. export * from "babylonjs/Materials/material";
  50139. export * from "babylonjs/Materials/materialDefines";
  50140. export * from "babylonjs/Materials/materialHelper";
  50141. export * from "babylonjs/Materials/multiMaterial";
  50142. export * from "babylonjs/Materials/PBR/index";
  50143. export * from "babylonjs/Materials/pushMaterial";
  50144. export * from "babylonjs/Materials/shaderMaterial";
  50145. export * from "babylonjs/Materials/standardMaterial";
  50146. export * from "babylonjs/Materials/Textures/index";
  50147. export * from "babylonjs/Materials/uniformBuffer";
  50148. export * from "babylonjs/Materials/materialFlags";
  50149. }
  50150. declare module "babylonjs/Maths/index" {
  50151. export * from "babylonjs/Maths/math.scalar";
  50152. export * from "babylonjs/Maths/math";
  50153. export * from "babylonjs/Maths/sphericalPolynomial";
  50154. }
  50155. declare module "babylonjs/Meshes/Compression/dracoCompression" {
  50156. import { IDisposable } from "babylonjs/scene";
  50157. import { VertexData } from "babylonjs/Meshes/mesh.vertexData";
  50158. /**
  50159. * Configuration for Draco compression
  50160. */
  50161. export interface IDracoCompressionConfiguration {
  50162. /**
  50163. * Configuration for the decoder.
  50164. */
  50165. decoder?: {
  50166. /**
  50167. * The url to the WebAssembly module.
  50168. */
  50169. wasmUrl?: string;
  50170. /**
  50171. * The url to the WebAssembly binary.
  50172. */
  50173. wasmBinaryUrl?: string;
  50174. /**
  50175. * The url to the fallback JavaScript module.
  50176. */
  50177. fallbackUrl?: string;
  50178. };
  50179. }
  50180. /**
  50181. * Draco compression (https://google.github.io/draco/)
  50182. *
  50183. * This class wraps the Draco module.
  50184. *
  50185. * **Encoder**
  50186. *
  50187. * The encoder is not currently implemented.
  50188. *
  50189. * **Decoder**
  50190. *
  50191. * 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.
  50192. *
  50193. * To update the configuration, use the following code:
  50194. * ```javascript
  50195. * DracoCompression.Configuration = {
  50196. * decoder: {
  50197. * wasmUrl: "<url to the WebAssembly library>",
  50198. * wasmBinaryUrl: "<url to the WebAssembly binary>",
  50199. * fallbackUrl: "<url to the fallback JavaScript library>",
  50200. * }
  50201. * };
  50202. * ```
  50203. *
  50204. * 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.
  50205. * Decoding will automatically fallback to the JavaScript version if WebAssembly version is not configured or if WebAssembly is not supported by the browser.
  50206. * Use `DracoCompression.DecoderAvailable` to determine if the decoder is available for the current session.
  50207. *
  50208. * To decode Draco compressed data, create a DracoCompression object and call decodeMeshAsync:
  50209. * ```javascript
  50210. * var dracoCompression = new DracoCompression();
  50211. * var vertexData = await dracoCompression.decodeMeshAsync(data, {
  50212. * [VertexBuffer.PositionKind]: 0
  50213. * });
  50214. * ```
  50215. *
  50216. * @see https://www.babylonjs-playground.com/#N3EK4B#0
  50217. */
  50218. export class DracoCompression implements IDisposable {
  50219. private static _DecoderModulePromise;
  50220. /**
  50221. * The configuration. Defaults to the following urls:
  50222. * - wasmUrl: "https://preview.babylonjs.com/draco_wasm_wrapper_gltf.js"
  50223. * - wasmBinaryUrl: "https://preview.babylonjs.com/draco_decoder_gltf.wasm"
  50224. * - fallbackUrl: "https://preview.babylonjs.com/draco_decoder_gltf.js"
  50225. */
  50226. static Configuration: IDracoCompressionConfiguration;
  50227. /**
  50228. * Returns true if the decoder is available.
  50229. */
  50230. static readonly DecoderAvailable: boolean;
  50231. /**
  50232. * Constructor
  50233. */
  50234. constructor();
  50235. /**
  50236. * Stop all async operations and release resources.
  50237. */
  50238. dispose(): void;
  50239. /**
  50240. * Decode Draco compressed mesh data to vertex data.
  50241. * @param data The ArrayBuffer or ArrayBufferView for the Draco compression data
  50242. * @param attributes A map of attributes from vertex buffer kinds to Draco unique ids
  50243. * @returns A promise that resolves with the decoded vertex data
  50244. */
  50245. decodeMeshAsync(data: ArrayBuffer | ArrayBufferView, attributes: {
  50246. [kind: string]: number;
  50247. }): Promise<VertexData>;
  50248. private static _GetDecoderModule;
  50249. private static _LoadScriptAsync;
  50250. private static _LoadFileAsync;
  50251. }
  50252. }
  50253. declare module "babylonjs/Meshes/Compression/index" {
  50254. export * from "babylonjs/Meshes/Compression/dracoCompression";
  50255. }
  50256. declare module "babylonjs/Meshes/csg" {
  50257. import { Nullable } from "babylonjs/types";
  50258. import { Scene } from "babylonjs/scene";
  50259. import { Quaternion, Matrix, Vector3 } from "babylonjs/Maths/math";
  50260. import { Mesh } from "babylonjs/Meshes/mesh";
  50261. import { Material } from "babylonjs/Materials/material";
  50262. /**
  50263. * Class for building Constructive Solid Geometry
  50264. */
  50265. export class CSG {
  50266. private polygons;
  50267. /**
  50268. * The world matrix
  50269. */
  50270. matrix: Matrix;
  50271. /**
  50272. * Stores the position
  50273. */
  50274. position: Vector3;
  50275. /**
  50276. * Stores the rotation
  50277. */
  50278. rotation: Vector3;
  50279. /**
  50280. * Stores the rotation quaternion
  50281. */
  50282. rotationQuaternion: Nullable<Quaternion>;
  50283. /**
  50284. * Stores the scaling vector
  50285. */
  50286. scaling: Vector3;
  50287. /**
  50288. * Convert the Mesh to CSG
  50289. * @param mesh The Mesh to convert to CSG
  50290. * @returns A new CSG from the Mesh
  50291. */
  50292. static FromMesh(mesh: Mesh): CSG;
  50293. /**
  50294. * Construct a CSG solid from a list of `CSG.Polygon` instances.
  50295. * @param polygons Polygons used to construct a CSG solid
  50296. */
  50297. private static FromPolygons;
  50298. /**
  50299. * Clones, or makes a deep copy, of the CSG
  50300. * @returns A new CSG
  50301. */
  50302. clone(): CSG;
  50303. /**
  50304. * Unions this CSG with another CSG
  50305. * @param csg The CSG to union against this CSG
  50306. * @returns The unioned CSG
  50307. */
  50308. union(csg: CSG): CSG;
  50309. /**
  50310. * Unions this CSG with another CSG in place
  50311. * @param csg The CSG to union against this CSG
  50312. */
  50313. unionInPlace(csg: CSG): void;
  50314. /**
  50315. * Subtracts this CSG with another CSG
  50316. * @param csg The CSG to subtract against this CSG
  50317. * @returns A new CSG
  50318. */
  50319. subtract(csg: CSG): CSG;
  50320. /**
  50321. * Subtracts this CSG with another CSG in place
  50322. * @param csg The CSG to subtact against this CSG
  50323. */
  50324. subtractInPlace(csg: CSG): void;
  50325. /**
  50326. * Intersect this CSG with another CSG
  50327. * @param csg The CSG to intersect against this CSG
  50328. * @returns A new CSG
  50329. */
  50330. intersect(csg: CSG): CSG;
  50331. /**
  50332. * Intersects this CSG with another CSG in place
  50333. * @param csg The CSG to intersect against this CSG
  50334. */
  50335. intersectInPlace(csg: CSG): void;
  50336. /**
  50337. * Return a new CSG solid with solid and empty space switched. This solid is
  50338. * not modified.
  50339. * @returns A new CSG solid with solid and empty space switched
  50340. */
  50341. inverse(): CSG;
  50342. /**
  50343. * Inverses the CSG in place
  50344. */
  50345. inverseInPlace(): void;
  50346. /**
  50347. * This is used to keep meshes transformations so they can be restored
  50348. * when we build back a Babylon Mesh
  50349. * NB : All CSG operations are performed in world coordinates
  50350. * @param csg The CSG to copy the transform attributes from
  50351. * @returns This CSG
  50352. */
  50353. copyTransformAttributes(csg: CSG): CSG;
  50354. /**
  50355. * Build Raw mesh from CSG
  50356. * Coordinates here are in world space
  50357. * @param name The name of the mesh geometry
  50358. * @param scene The Scene
  50359. * @param keepSubMeshes Specifies if the submeshes should be kept
  50360. * @returns A new Mesh
  50361. */
  50362. buildMeshGeometry(name: string, scene: Scene, keepSubMeshes: boolean): Mesh;
  50363. /**
  50364. * Build Mesh from CSG taking material and transforms into account
  50365. * @param name The name of the Mesh
  50366. * @param material The material of the Mesh
  50367. * @param scene The Scene
  50368. * @param keepSubMeshes Specifies if submeshes should be kept
  50369. * @returns The new Mesh
  50370. */
  50371. toMesh(name: string, material: Nullable<Material>, scene: Scene, keepSubMeshes: boolean): Mesh;
  50372. }
  50373. }
  50374. declare module "babylonjs/Meshes/trailMesh" {
  50375. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  50376. import { Mesh } from "babylonjs/Meshes/mesh";
  50377. import { Scene } from "babylonjs/scene";
  50378. /**
  50379. * Class used to create a trail following a mesh
  50380. */
  50381. export class TrailMesh extends Mesh {
  50382. private _generator;
  50383. private _autoStart;
  50384. private _running;
  50385. private _diameter;
  50386. private _length;
  50387. private _sectionPolygonPointsCount;
  50388. private _sectionVectors;
  50389. private _sectionNormalVectors;
  50390. private _beforeRenderObserver;
  50391. /**
  50392. * @constructor
  50393. * @param name The value used by scene.getMeshByName() to do a lookup.
  50394. * @param generator The mesh to generate a trail.
  50395. * @param scene The scene to add this mesh to.
  50396. * @param diameter Diameter of trailing mesh. Default is 1.
  50397. * @param length Length of trailing mesh. Default is 60.
  50398. * @param autoStart Automatically start trailing mesh. Default true.
  50399. */
  50400. constructor(name: string, generator: AbstractMesh, scene: Scene, diameter?: number, length?: number, autoStart?: boolean);
  50401. /**
  50402. * "TrailMesh"
  50403. * @returns "TrailMesh"
  50404. */
  50405. getClassName(): string;
  50406. private _createMesh;
  50407. /**
  50408. * Start trailing mesh.
  50409. */
  50410. start(): void;
  50411. /**
  50412. * Stop trailing mesh.
  50413. */
  50414. stop(): void;
  50415. /**
  50416. * Update trailing mesh geometry.
  50417. */
  50418. update(): void;
  50419. /**
  50420. * Returns a new TrailMesh object.
  50421. * @param name is a string, the name given to the new mesh
  50422. * @param newGenerator use new generator object for cloned trail mesh
  50423. * @returns a new mesh
  50424. */
  50425. clone(name: string | undefined, newGenerator: AbstractMesh): TrailMesh;
  50426. /**
  50427. * Serializes this trail mesh
  50428. * @param serializationObject object to write serialization to
  50429. */
  50430. serialize(serializationObject: any): void;
  50431. /**
  50432. * Parses a serialized trail mesh
  50433. * @param parsedMesh the serialized mesh
  50434. * @param scene the scene to create the trail mesh in
  50435. * @returns the created trail mesh
  50436. */
  50437. static Parse(parsedMesh: any, scene: Scene): TrailMesh;
  50438. }
  50439. }
  50440. declare module "babylonjs/Meshes/Builders/ribbonBuilder" {
  50441. import { Nullable } from "babylonjs/types";
  50442. import { Scene } from "babylonjs/scene";
  50443. import { Vector3, Vector2, Color4, Vector4 } from "babylonjs/Maths/math";
  50444. import { Mesh } from "babylonjs/Meshes/mesh";
  50445. /**
  50446. * Class containing static functions to help procedurally build meshes
  50447. */
  50448. export class RibbonBuilder {
  50449. /**
  50450. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  50451. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  50452. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  50453. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  50454. * * 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
  50455. * * 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
  50456. * * 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
  50457. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  50458. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  50459. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  50460. * * 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
  50461. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  50462. * * 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
  50463. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  50464. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  50465. * @param name defines the name of the mesh
  50466. * @param options defines the options used to create the mesh
  50467. * @param scene defines the hosting scene
  50468. * @returns the ribbon mesh
  50469. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  50470. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  50471. */
  50472. static CreateRibbon(name: string, options: {
  50473. pathArray: Vector3[][];
  50474. closeArray?: boolean;
  50475. closePath?: boolean;
  50476. offset?: number;
  50477. updatable?: boolean;
  50478. sideOrientation?: number;
  50479. frontUVs?: Vector4;
  50480. backUVs?: Vector4;
  50481. instance?: Mesh;
  50482. invertUV?: boolean;
  50483. uvs?: Vector2[];
  50484. colors?: Color4[];
  50485. }, scene?: Nullable<Scene>): Mesh;
  50486. }
  50487. }
  50488. declare module "babylonjs/Meshes/Builders/torusKnotBuilder" {
  50489. import { Vector4 } from "babylonjs/Maths/math";
  50490. import { Mesh } from "babylonjs/Meshes/mesh";
  50491. /**
  50492. * Class containing static functions to help procedurally build meshes
  50493. */
  50494. export class TorusKnotBuilder {
  50495. /**
  50496. * Creates a torus knot mesh
  50497. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  50498. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  50499. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  50500. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  50501. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  50502. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  50503. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  50504. * @param name defines the name of the mesh
  50505. * @param options defines the options used to create the mesh
  50506. * @param scene defines the hosting scene
  50507. * @returns the torus knot mesh
  50508. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  50509. */
  50510. static CreateTorusKnot(name: string, options: {
  50511. radius?: number;
  50512. tube?: number;
  50513. radialSegments?: number;
  50514. tubularSegments?: number;
  50515. p?: number;
  50516. q?: number;
  50517. updatable?: boolean;
  50518. sideOrientation?: number;
  50519. frontUVs?: Vector4;
  50520. backUVs?: Vector4;
  50521. }, scene: any): Mesh;
  50522. }
  50523. }
  50524. declare module "babylonjs/Meshes/polygonMesh" {
  50525. import { Scene } from "babylonjs/scene";
  50526. import { Vector2, Path2 } from "babylonjs/Maths/math";
  50527. import { Mesh } from "babylonjs/Meshes/mesh";
  50528. import { VertexData } from "babylonjs/Meshes/mesh.vertexData";
  50529. /**
  50530. * Polygon
  50531. * @see https://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  50532. */
  50533. export class Polygon {
  50534. /**
  50535. * Creates a rectangle
  50536. * @param xmin bottom X coord
  50537. * @param ymin bottom Y coord
  50538. * @param xmax top X coord
  50539. * @param ymax top Y coord
  50540. * @returns points that make the resulting rectation
  50541. */
  50542. static Rectangle(xmin: number, ymin: number, xmax: number, ymax: number): Vector2[];
  50543. /**
  50544. * Creates a circle
  50545. * @param radius radius of circle
  50546. * @param cx scale in x
  50547. * @param cy scale in y
  50548. * @param numberOfSides number of sides that make up the circle
  50549. * @returns points that make the resulting circle
  50550. */
  50551. static Circle(radius: number, cx?: number, cy?: number, numberOfSides?: number): Vector2[];
  50552. /**
  50553. * Creates a polygon from input string
  50554. * @param input Input polygon data
  50555. * @returns the parsed points
  50556. */
  50557. static Parse(input: string): Vector2[];
  50558. /**
  50559. * Starts building a polygon from x and y coordinates
  50560. * @param x x coordinate
  50561. * @param y y coordinate
  50562. * @returns the started path2
  50563. */
  50564. static StartingAt(x: number, y: number): Path2;
  50565. }
  50566. /**
  50567. * Builds a polygon
  50568. * @see https://doc.babylonjs.com/how_to/polygonmeshbuilder
  50569. */
  50570. export class PolygonMeshBuilder {
  50571. private _points;
  50572. private _outlinepoints;
  50573. private _holes;
  50574. private _name;
  50575. private _scene;
  50576. private _epoints;
  50577. private _eholes;
  50578. private _addToepoint;
  50579. /**
  50580. * Babylon reference to the earcut plugin.
  50581. */
  50582. bjsEarcut: any;
  50583. /**
  50584. * Creates a PolygonMeshBuilder
  50585. * @param name name of the builder
  50586. * @param contours Path of the polygon
  50587. * @param scene scene to add to when creating the mesh
  50588. * @param earcutInjection can be used to inject your own earcut reference
  50589. */
  50590. constructor(name: string, contours: Path2 | Vector2[] | any, scene?: Scene, earcutInjection?: any);
  50591. /**
  50592. * Adds a whole within the polygon
  50593. * @param hole Array of points defining the hole
  50594. * @returns this
  50595. */
  50596. addHole(hole: Vector2[]): PolygonMeshBuilder;
  50597. /**
  50598. * Creates the polygon
  50599. * @param updatable If the mesh should be updatable
  50600. * @param depth The depth of the mesh created
  50601. * @returns the created mesh
  50602. */
  50603. build(updatable?: boolean, depth?: number): Mesh;
  50604. /**
  50605. * Creates the polygon
  50606. * @param depth The depth of the mesh created
  50607. * @returns the created VertexData
  50608. */
  50609. buildVertexData(depth?: number): VertexData;
  50610. /**
  50611. * Adds a side to the polygon
  50612. * @param positions points that make the polygon
  50613. * @param normals normals of the polygon
  50614. * @param uvs uvs of the polygon
  50615. * @param indices indices of the polygon
  50616. * @param bounds bounds of the polygon
  50617. * @param points points of the polygon
  50618. * @param depth depth of the polygon
  50619. * @param flip flip of the polygon
  50620. */
  50621. private addSide;
  50622. }
  50623. }
  50624. declare module "babylonjs/Meshes/Builders/polygonBuilder" {
  50625. import { Scene } from "babylonjs/scene";
  50626. import { Vector3, Color4, Vector4 } from "babylonjs/Maths/math";
  50627. import { Mesh } from "babylonjs/Meshes/mesh";
  50628. /**
  50629. * Class containing static functions to help procedurally build meshes
  50630. */
  50631. export class PolygonBuilder {
  50632. /**
  50633. * Creates a polygon mesh
  50634. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  50635. * * 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
  50636. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  50637. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  50638. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4)
  50639. * * Remember you can only change the shape positions, not their number when updating a polygon
  50640. * @param name defines the name of the mesh
  50641. * @param options defines the options used to create the mesh
  50642. * @param scene defines the hosting scene
  50643. * @param earcutInjection can be used to inject your own earcut reference
  50644. * @returns the polygon mesh
  50645. */
  50646. static CreatePolygon(name: string, options: {
  50647. shape: Vector3[];
  50648. holes?: Vector3[][];
  50649. depth?: number;
  50650. faceUV?: Vector4[];
  50651. faceColors?: Color4[];
  50652. updatable?: boolean;
  50653. sideOrientation?: number;
  50654. frontUVs?: Vector4;
  50655. backUVs?: Vector4;
  50656. }, scene: Scene, earcutInjection?: any): Mesh;
  50657. /**
  50658. * Creates an extruded polygon mesh, with depth in the Y direction.
  50659. * * 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)
  50660. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  50661. * @param name defines the name of the mesh
  50662. * @param options defines the options used to create the mesh
  50663. * @param scene defines the hosting scene
  50664. * @param earcutInjection can be used to inject your own earcut reference
  50665. * @returns the polygon mesh
  50666. */
  50667. static ExtrudePolygon(name: string, options: {
  50668. shape: Vector3[];
  50669. holes?: Vector3[][];
  50670. depth?: number;
  50671. faceUV?: Vector4[];
  50672. faceColors?: Color4[];
  50673. updatable?: boolean;
  50674. sideOrientation?: number;
  50675. frontUVs?: Vector4;
  50676. backUVs?: Vector4;
  50677. }, scene: Scene, earcutInjection?: any): Mesh;
  50678. }
  50679. }
  50680. declare module "babylonjs/Meshes/Builders/shapeBuilder" {
  50681. import { Nullable } from "babylonjs/types";
  50682. import { Scene } from "babylonjs/scene";
  50683. import { Vector3, Vector4 } from "babylonjs/Maths/math";
  50684. import { Mesh } from "babylonjs/Meshes/mesh";
  50685. /**
  50686. * Class containing static functions to help procedurally build meshes
  50687. */
  50688. export class ShapeBuilder {
  50689. /**
  50690. * 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.
  50691. * * 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.
  50692. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  50693. * * 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.
  50694. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  50695. * * 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
  50696. * * 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
  50697. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  50698. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  50699. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  50700. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  50701. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  50702. * @param name defines the name of the mesh
  50703. * @param options defines the options used to create the mesh
  50704. * @param scene defines the hosting scene
  50705. * @returns the extruded shape mesh
  50706. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  50707. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  50708. */
  50709. static ExtrudeShape(name: string, options: {
  50710. shape: Vector3[];
  50711. path: Vector3[];
  50712. scale?: number;
  50713. rotation?: number;
  50714. cap?: number;
  50715. updatable?: boolean;
  50716. sideOrientation?: number;
  50717. frontUVs?: Vector4;
  50718. backUVs?: Vector4;
  50719. instance?: Mesh;
  50720. invertUV?: boolean;
  50721. }, scene?: Nullable<Scene>): Mesh;
  50722. /**
  50723. * Creates an custom extruded shape mesh.
  50724. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  50725. * * 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.
  50726. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  50727. * * 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
  50728. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  50729. * * 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
  50730. * * It must returns a float value that will be the scale value applied to the shape on each path point
  50731. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  50732. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  50733. * * 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
  50734. * * 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
  50735. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  50736. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  50737. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  50738. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  50739. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  50740. * @param name defines the name of the mesh
  50741. * @param options defines the options used to create the mesh
  50742. * @param scene defines the hosting scene
  50743. * @returns the custom extruded shape mesh
  50744. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  50745. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  50746. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  50747. */
  50748. static ExtrudeShapeCustom(name: string, options: {
  50749. shape: Vector3[];
  50750. path: Vector3[];
  50751. scaleFunction?: any;
  50752. rotationFunction?: any;
  50753. ribbonCloseArray?: boolean;
  50754. ribbonClosePath?: boolean;
  50755. cap?: number;
  50756. updatable?: boolean;
  50757. sideOrientation?: number;
  50758. frontUVs?: Vector4;
  50759. backUVs?: Vector4;
  50760. instance?: Mesh;
  50761. invertUV?: boolean;
  50762. }, scene: Scene): Mesh;
  50763. private static _ExtrudeShapeGeneric;
  50764. }
  50765. }
  50766. declare module "babylonjs/Meshes/Builders/latheBuilder" {
  50767. import { Scene } from "babylonjs/scene";
  50768. import { Vector3, Vector4 } from "babylonjs/Maths/math";
  50769. import { Mesh } from "babylonjs/Meshes/mesh";
  50770. /**
  50771. * Class containing static functions to help procedurally build meshes
  50772. */
  50773. export class LatheBuilder {
  50774. /**
  50775. * Creates lathe mesh.
  50776. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  50777. * * 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
  50778. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  50779. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  50780. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  50781. * * 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
  50782. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  50783. * * 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
  50784. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  50785. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  50786. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  50787. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  50788. * @param name defines the name of the mesh
  50789. * @param options defines the options used to create the mesh
  50790. * @param scene defines the hosting scene
  50791. * @returns the lathe mesh
  50792. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  50793. */
  50794. static CreateLathe(name: string, options: {
  50795. shape: Vector3[];
  50796. radius?: number;
  50797. tessellation?: number;
  50798. clip?: number;
  50799. arc?: number;
  50800. closed?: boolean;
  50801. updatable?: boolean;
  50802. sideOrientation?: number;
  50803. frontUVs?: Vector4;
  50804. backUVs?: Vector4;
  50805. cap?: number;
  50806. invertUV?: boolean;
  50807. }, scene: Scene): Mesh;
  50808. }
  50809. }
  50810. declare module "babylonjs/Meshes/Builders/tubeBuilder" {
  50811. import { Scene } from "babylonjs/scene";
  50812. import { Vector3, Vector4 } from "babylonjs/Maths/math";
  50813. import { Mesh } from "babylonjs/Meshes/mesh";
  50814. /**
  50815. * Class containing static functions to help procedurally build meshes
  50816. */
  50817. export class TubeBuilder {
  50818. /**
  50819. * Creates a tube mesh.
  50820. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  50821. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  50822. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  50823. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  50824. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  50825. * * 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)
  50826. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  50827. * * 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
  50828. * * 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
  50829. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  50830. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  50831. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  50832. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  50833. * @param name defines the name of the mesh
  50834. * @param options defines the options used to create the mesh
  50835. * @param scene defines the hosting scene
  50836. * @returns the tube mesh
  50837. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  50838. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  50839. */
  50840. static CreateTube(name: string, options: {
  50841. path: Vector3[];
  50842. radius?: number;
  50843. tessellation?: number;
  50844. radiusFunction?: {
  50845. (i: number, distance: number): number;
  50846. };
  50847. cap?: number;
  50848. arc?: number;
  50849. updatable?: boolean;
  50850. sideOrientation?: number;
  50851. frontUVs?: Vector4;
  50852. backUVs?: Vector4;
  50853. instance?: Mesh;
  50854. invertUV?: boolean;
  50855. }, scene: Scene): Mesh;
  50856. }
  50857. }
  50858. declare module "babylonjs/Meshes/Builders/icoSphereBuilder" {
  50859. import { Scene } from "babylonjs/scene";
  50860. import { Vector4 } from "babylonjs/Maths/math";
  50861. import { Mesh } from "babylonjs/Meshes/mesh";
  50862. /**
  50863. * Class containing static functions to help procedurally build meshes
  50864. */
  50865. export class IcoSphereBuilder {
  50866. /**
  50867. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  50868. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  50869. * * 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`)
  50870. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  50871. * * 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
  50872. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  50873. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  50874. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  50875. * @param name defines the name of the mesh
  50876. * @param options defines the options used to create the mesh
  50877. * @param scene defines the hosting scene
  50878. * @returns the icosahedron mesh
  50879. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  50880. */
  50881. static CreateIcoSphere(name: string, options: {
  50882. radius?: number;
  50883. radiusX?: number;
  50884. radiusY?: number;
  50885. radiusZ?: number;
  50886. flat?: boolean;
  50887. subdivisions?: number;
  50888. sideOrientation?: number;
  50889. frontUVs?: Vector4;
  50890. backUVs?: Vector4;
  50891. updatable?: boolean;
  50892. }, scene: Scene): Mesh;
  50893. }
  50894. }
  50895. declare module "babylonjs/Meshes/Builders/decalBuilder" {
  50896. import { Vector3 } from "babylonjs/Maths/math";
  50897. import { Mesh } from "babylonjs/Meshes/mesh";
  50898. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  50899. /**
  50900. * Class containing static functions to help procedurally build meshes
  50901. */
  50902. export class DecalBuilder {
  50903. /**
  50904. * Creates a decal mesh.
  50905. * 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
  50906. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  50907. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  50908. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  50909. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  50910. * @param name defines the name of the mesh
  50911. * @param sourceMesh defines the mesh where the decal must be applied
  50912. * @param options defines the options used to create the mesh
  50913. * @param scene defines the hosting scene
  50914. * @returns the decal mesh
  50915. * @see https://doc.babylonjs.com/how_to/decals
  50916. */
  50917. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  50918. position?: Vector3;
  50919. normal?: Vector3;
  50920. size?: Vector3;
  50921. angle?: number;
  50922. }): Mesh;
  50923. }
  50924. }
  50925. declare module "babylonjs/Meshes/meshBuilder" {
  50926. import { Vector4, Color4, Vector3, Vector2, Plane, Color3 } from "babylonjs/Maths/math";
  50927. import { Nullable } from "babylonjs/types";
  50928. import { Scene } from "babylonjs/scene";
  50929. import { Mesh } from "babylonjs/Meshes/mesh";
  50930. import { LinesMesh } from "babylonjs/Meshes/linesMesh";
  50931. import { GroundMesh } from "babylonjs/Meshes/groundMesh";
  50932. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  50933. /**
  50934. * Class containing static functions to help procedurally build meshes
  50935. */
  50936. export class MeshBuilder {
  50937. /**
  50938. * Creates a box mesh
  50939. * * The parameter `size` sets the size (float) of each box side (default 1)
  50940. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  50941. * * 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)
  50942. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  50943. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  50944. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  50945. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  50946. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  50947. * @param name defines the name of the mesh
  50948. * @param options defines the options used to create the mesh
  50949. * @param scene defines the hosting scene
  50950. * @returns the box mesh
  50951. */
  50952. static CreateBox(name: string, options: {
  50953. size?: number;
  50954. width?: number;
  50955. height?: number;
  50956. depth?: number;
  50957. faceUV?: Vector4[];
  50958. faceColors?: Color4[];
  50959. sideOrientation?: number;
  50960. frontUVs?: Vector4;
  50961. backUVs?: Vector4;
  50962. updatable?: boolean;
  50963. }, scene?: Nullable<Scene>): Mesh;
  50964. /**
  50965. * Creates a sphere mesh
  50966. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  50967. * * 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`)
  50968. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  50969. * * 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
  50970. * * 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)
  50971. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  50972. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  50973. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  50974. * @param name defines the name of the mesh
  50975. * @param options defines the options used to create the mesh
  50976. * @param scene defines the hosting scene
  50977. * @returns the sphere mesh
  50978. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  50979. */
  50980. static CreateSphere(name: string, options: {
  50981. segments?: number;
  50982. diameter?: number;
  50983. diameterX?: number;
  50984. diameterY?: number;
  50985. diameterZ?: number;
  50986. arc?: number;
  50987. slice?: number;
  50988. sideOrientation?: number;
  50989. frontUVs?: Vector4;
  50990. backUVs?: Vector4;
  50991. updatable?: boolean;
  50992. }, scene: any): Mesh;
  50993. /**
  50994. * Creates a plane polygonal mesh. By default, this is a disc
  50995. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  50996. * * 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
  50997. * * 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
  50998. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  50999. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  51000. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  51001. * @param name defines the name of the mesh
  51002. * @param options defines the options used to create the mesh
  51003. * @param scene defines the hosting scene
  51004. * @returns the plane polygonal mesh
  51005. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  51006. */
  51007. static CreateDisc(name: string, options: {
  51008. radius?: number;
  51009. tessellation?: number;
  51010. arc?: number;
  51011. updatable?: boolean;
  51012. sideOrientation?: number;
  51013. frontUVs?: Vector4;
  51014. backUVs?: Vector4;
  51015. }, scene?: Nullable<Scene>): Mesh;
  51016. /**
  51017. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  51018. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  51019. * * 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`)
  51020. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  51021. * * 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
  51022. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  51023. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  51024. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  51025. * @param name defines the name of the mesh
  51026. * @param options defines the options used to create the mesh
  51027. * @param scene defines the hosting scene
  51028. * @returns the icosahedron mesh
  51029. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  51030. */
  51031. static CreateIcoSphere(name: string, options: {
  51032. radius?: number;
  51033. radiusX?: number;
  51034. radiusY?: number;
  51035. radiusZ?: number;
  51036. flat?: boolean;
  51037. subdivisions?: number;
  51038. sideOrientation?: number;
  51039. frontUVs?: Vector4;
  51040. backUVs?: Vector4;
  51041. updatable?: boolean;
  51042. }, scene: Scene): Mesh;
  51043. /**
  51044. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  51045. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  51046. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  51047. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  51048. * * 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
  51049. * * 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
  51050. * * 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
  51051. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  51052. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  51053. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  51054. * * 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
  51055. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  51056. * * 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
  51057. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  51058. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  51059. * @param name defines the name of the mesh
  51060. * @param options defines the options used to create the mesh
  51061. * @param scene defines the hosting scene
  51062. * @returns the ribbon mesh
  51063. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  51064. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  51065. */
  51066. static CreateRibbon(name: string, options: {
  51067. pathArray: Vector3[][];
  51068. closeArray?: boolean;
  51069. closePath?: boolean;
  51070. offset?: number;
  51071. updatable?: boolean;
  51072. sideOrientation?: number;
  51073. frontUVs?: Vector4;
  51074. backUVs?: Vector4;
  51075. instance?: Mesh;
  51076. invertUV?: boolean;
  51077. uvs?: Vector2[];
  51078. colors?: Color4[];
  51079. }, scene?: Nullable<Scene>): Mesh;
  51080. /**
  51081. * Creates a cylinder or a cone mesh
  51082. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  51083. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  51084. * * 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.
  51085. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  51086. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  51087. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  51088. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  51089. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  51090. * * 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).
  51091. * * 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
  51092. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  51093. * * 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
  51094. * * 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.
  51095. * * If `enclose` is false, a ring surface is one element.
  51096. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  51097. * * 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
  51098. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  51099. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  51100. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  51101. * @param name defines the name of the mesh
  51102. * @param options defines the options used to create the mesh
  51103. * @param scene defines the hosting scene
  51104. * @returns the cylinder mesh
  51105. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  51106. */
  51107. static CreateCylinder(name: string, options: {
  51108. height?: number;
  51109. diameterTop?: number;
  51110. diameterBottom?: number;
  51111. diameter?: number;
  51112. tessellation?: number;
  51113. subdivisions?: number;
  51114. arc?: number;
  51115. faceColors?: Color4[];
  51116. faceUV?: Vector4[];
  51117. updatable?: boolean;
  51118. hasRings?: boolean;
  51119. enclose?: boolean;
  51120. sideOrientation?: number;
  51121. frontUVs?: Vector4;
  51122. backUVs?: Vector4;
  51123. }, scene: any): Mesh;
  51124. /**
  51125. * Creates a torus mesh
  51126. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  51127. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  51128. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  51129. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  51130. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  51131. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  51132. * @param name defines the name of the mesh
  51133. * @param options defines the options used to create the mesh
  51134. * @param scene defines the hosting scene
  51135. * @returns the torus mesh
  51136. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  51137. */
  51138. static CreateTorus(name: string, options: {
  51139. diameter?: number;
  51140. thickness?: number;
  51141. tessellation?: number;
  51142. updatable?: boolean;
  51143. sideOrientation?: number;
  51144. frontUVs?: Vector4;
  51145. backUVs?: Vector4;
  51146. }, scene: any): Mesh;
  51147. /**
  51148. * Creates a torus knot mesh
  51149. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  51150. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  51151. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  51152. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  51153. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  51154. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  51155. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  51156. * @param name defines the name of the mesh
  51157. * @param options defines the options used to create the mesh
  51158. * @param scene defines the hosting scene
  51159. * @returns the torus knot mesh
  51160. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  51161. */
  51162. static CreateTorusKnot(name: string, options: {
  51163. radius?: number;
  51164. tube?: number;
  51165. radialSegments?: number;
  51166. tubularSegments?: number;
  51167. p?: number;
  51168. q?: number;
  51169. updatable?: boolean;
  51170. sideOrientation?: number;
  51171. frontUVs?: Vector4;
  51172. backUVs?: Vector4;
  51173. }, scene: any): Mesh;
  51174. /**
  51175. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  51176. * * 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
  51177. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  51178. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  51179. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  51180. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  51181. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  51182. * * 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
  51183. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  51184. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  51185. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  51186. * @param name defines the name of the new line system
  51187. * @param options defines the options used to create the line system
  51188. * @param scene defines the hosting scene
  51189. * @returns a new line system mesh
  51190. */
  51191. static CreateLineSystem(name: string, options: {
  51192. lines: Vector3[][];
  51193. updatable?: boolean;
  51194. instance?: Nullable<LinesMesh>;
  51195. colors?: Nullable<Color4[][]>;
  51196. useVertexAlpha?: boolean;
  51197. }, scene: Nullable<Scene>): LinesMesh;
  51198. /**
  51199. * Creates a line mesh
  51200. * 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
  51201. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  51202. * * The parameter `points` is an array successive Vector3
  51203. * * 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
  51204. * * The optional parameter `colors` is an array of successive Color4, one per line point
  51205. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  51206. * * When updating an instance, remember that only point positions can change, not the number of points
  51207. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  51208. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  51209. * @param name defines the name of the new line system
  51210. * @param options defines the options used to create the line system
  51211. * @param scene defines the hosting scene
  51212. * @returns a new line mesh
  51213. */
  51214. static CreateLines(name: string, options: {
  51215. points: Vector3[];
  51216. updatable?: boolean;
  51217. instance?: Nullable<LinesMesh>;
  51218. colors?: Color4[];
  51219. useVertexAlpha?: boolean;
  51220. }, scene?: Nullable<Scene>): LinesMesh;
  51221. /**
  51222. * Creates a dashed line mesh
  51223. * * 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
  51224. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  51225. * * The parameter `points` is an array successive Vector3
  51226. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  51227. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  51228. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  51229. * * 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
  51230. * * When updating an instance, remember that only point positions can change, not the number of points
  51231. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  51232. * @param name defines the name of the mesh
  51233. * @param options defines the options used to create the mesh
  51234. * @param scene defines the hosting scene
  51235. * @returns the dashed line mesh
  51236. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  51237. */
  51238. static CreateDashedLines(name: string, options: {
  51239. points: Vector3[];
  51240. dashSize?: number;
  51241. gapSize?: number;
  51242. dashNb?: number;
  51243. updatable?: boolean;
  51244. instance?: LinesMesh;
  51245. }, scene?: Nullable<Scene>): LinesMesh;
  51246. /**
  51247. * 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.
  51248. * * 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.
  51249. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  51250. * * 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.
  51251. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  51252. * * 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
  51253. * * 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
  51254. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  51255. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  51256. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  51257. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  51258. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  51259. * @param name defines the name of the mesh
  51260. * @param options defines the options used to create the mesh
  51261. * @param scene defines the hosting scene
  51262. * @returns the extruded shape mesh
  51263. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  51264. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  51265. */
  51266. static ExtrudeShape(name: string, options: {
  51267. shape: Vector3[];
  51268. path: Vector3[];
  51269. scale?: number;
  51270. rotation?: number;
  51271. cap?: number;
  51272. updatable?: boolean;
  51273. sideOrientation?: number;
  51274. frontUVs?: Vector4;
  51275. backUVs?: Vector4;
  51276. instance?: Mesh;
  51277. invertUV?: boolean;
  51278. }, scene?: Nullable<Scene>): Mesh;
  51279. /**
  51280. * Creates an custom extruded shape mesh.
  51281. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  51282. * * 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.
  51283. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  51284. * * 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
  51285. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  51286. * * 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
  51287. * * It must returns a float value that will be the scale value applied to the shape on each path point
  51288. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  51289. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  51290. * * 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
  51291. * * 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
  51292. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  51293. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  51294. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  51295. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  51296. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  51297. * @param name defines the name of the mesh
  51298. * @param options defines the options used to create the mesh
  51299. * @param scene defines the hosting scene
  51300. * @returns the custom extruded shape mesh
  51301. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  51302. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  51303. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  51304. */
  51305. static ExtrudeShapeCustom(name: string, options: {
  51306. shape: Vector3[];
  51307. path: Vector3[];
  51308. scaleFunction?: any;
  51309. rotationFunction?: any;
  51310. ribbonCloseArray?: boolean;
  51311. ribbonClosePath?: boolean;
  51312. cap?: number;
  51313. updatable?: boolean;
  51314. sideOrientation?: number;
  51315. frontUVs?: Vector4;
  51316. backUVs?: Vector4;
  51317. instance?: Mesh;
  51318. invertUV?: boolean;
  51319. }, scene: Scene): Mesh;
  51320. /**
  51321. * Creates lathe mesh.
  51322. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  51323. * * 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
  51324. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  51325. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  51326. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  51327. * * 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
  51328. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  51329. * * 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
  51330. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  51331. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  51332. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  51333. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  51334. * @param name defines the name of the mesh
  51335. * @param options defines the options used to create the mesh
  51336. * @param scene defines the hosting scene
  51337. * @returns the lathe mesh
  51338. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  51339. */
  51340. static CreateLathe(name: string, options: {
  51341. shape: Vector3[];
  51342. radius?: number;
  51343. tessellation?: number;
  51344. clip?: number;
  51345. arc?: number;
  51346. closed?: boolean;
  51347. updatable?: boolean;
  51348. sideOrientation?: number;
  51349. frontUVs?: Vector4;
  51350. backUVs?: Vector4;
  51351. cap?: number;
  51352. invertUV?: boolean;
  51353. }, scene: Scene): Mesh;
  51354. /**
  51355. * Creates a plane mesh
  51356. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  51357. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  51358. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  51359. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  51360. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  51361. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  51362. * @param name defines the name of the mesh
  51363. * @param options defines the options used to create the mesh
  51364. * @param scene defines the hosting scene
  51365. * @returns the plane mesh
  51366. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  51367. */
  51368. static CreatePlane(name: string, options: {
  51369. size?: number;
  51370. width?: number;
  51371. height?: number;
  51372. sideOrientation?: number;
  51373. frontUVs?: Vector4;
  51374. backUVs?: Vector4;
  51375. updatable?: boolean;
  51376. sourcePlane?: Plane;
  51377. }, scene: Scene): Mesh;
  51378. /**
  51379. * Creates a ground mesh
  51380. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  51381. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  51382. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  51383. * @param name defines the name of the mesh
  51384. * @param options defines the options used to create the mesh
  51385. * @param scene defines the hosting scene
  51386. * @returns the ground mesh
  51387. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  51388. */
  51389. static CreateGround(name: string, options: {
  51390. width?: number;
  51391. height?: number;
  51392. subdivisions?: number;
  51393. subdivisionsX?: number;
  51394. subdivisionsY?: number;
  51395. updatable?: boolean;
  51396. }, scene: any): Mesh;
  51397. /**
  51398. * Creates a tiled ground mesh
  51399. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  51400. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  51401. * * 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
  51402. * * 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
  51403. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  51404. * @param name defines the name of the mesh
  51405. * @param options defines the options used to create the mesh
  51406. * @param scene defines the hosting scene
  51407. * @returns the tiled ground mesh
  51408. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  51409. */
  51410. static CreateTiledGround(name: string, options: {
  51411. xmin: number;
  51412. zmin: number;
  51413. xmax: number;
  51414. zmax: number;
  51415. subdivisions?: {
  51416. w: number;
  51417. h: number;
  51418. };
  51419. precision?: {
  51420. w: number;
  51421. h: number;
  51422. };
  51423. updatable?: boolean;
  51424. }, scene: Scene): Mesh;
  51425. /**
  51426. * Creates a ground mesh from a height map
  51427. * * The parameter `url` sets the URL of the height map image resource.
  51428. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  51429. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  51430. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  51431. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  51432. * * 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.
  51433. * * 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).
  51434. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  51435. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  51436. * @param name defines the name of the mesh
  51437. * @param url defines the url to the height map
  51438. * @param options defines the options used to create the mesh
  51439. * @param scene defines the hosting scene
  51440. * @returns the ground mesh
  51441. * @see https://doc.babylonjs.com/babylon101/height_map
  51442. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  51443. */
  51444. static CreateGroundFromHeightMap(name: string, url: string, options: {
  51445. width?: number;
  51446. height?: number;
  51447. subdivisions?: number;
  51448. minHeight?: number;
  51449. maxHeight?: number;
  51450. colorFilter?: Color3;
  51451. alphaFilter?: number;
  51452. updatable?: boolean;
  51453. onReady?: (mesh: GroundMesh) => void;
  51454. }, scene: Scene): GroundMesh;
  51455. /**
  51456. * Creates a polygon mesh
  51457. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  51458. * * 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
  51459. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  51460. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  51461. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4)
  51462. * * Remember you can only change the shape positions, not their number when updating a polygon
  51463. * @param name defines the name of the mesh
  51464. * @param options defines the options used to create the mesh
  51465. * @param scene defines the hosting scene
  51466. * @param earcutInjection can be used to inject your own earcut reference
  51467. * @returns the polygon mesh
  51468. */
  51469. static CreatePolygon(name: string, options: {
  51470. shape: Vector3[];
  51471. holes?: Vector3[][];
  51472. depth?: number;
  51473. faceUV?: Vector4[];
  51474. faceColors?: Color4[];
  51475. updatable?: boolean;
  51476. sideOrientation?: number;
  51477. frontUVs?: Vector4;
  51478. backUVs?: Vector4;
  51479. }, scene: Scene, earcutInjection?: any): Mesh;
  51480. /**
  51481. * Creates an extruded polygon mesh, with depth in the Y direction.
  51482. * * 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)
  51483. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  51484. * @param name defines the name of the mesh
  51485. * @param options defines the options used to create the mesh
  51486. * @param scene defines the hosting scene
  51487. * @param earcutInjection can be used to inject your own earcut reference
  51488. * @returns the polygon mesh
  51489. */
  51490. static ExtrudePolygon(name: string, options: {
  51491. shape: Vector3[];
  51492. holes?: Vector3[][];
  51493. depth?: number;
  51494. faceUV?: Vector4[];
  51495. faceColors?: Color4[];
  51496. updatable?: boolean;
  51497. sideOrientation?: number;
  51498. frontUVs?: Vector4;
  51499. backUVs?: Vector4;
  51500. }, scene: Scene, earcutInjection?: any): Mesh;
  51501. /**
  51502. * Creates a tube mesh.
  51503. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  51504. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  51505. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  51506. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  51507. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  51508. * * 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)
  51509. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  51510. * * 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
  51511. * * 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
  51512. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  51513. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  51514. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  51515. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  51516. * @param name defines the name of the mesh
  51517. * @param options defines the options used to create the mesh
  51518. * @param scene defines the hosting scene
  51519. * @returns the tube mesh
  51520. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  51521. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  51522. */
  51523. static CreateTube(name: string, options: {
  51524. path: Vector3[];
  51525. radius?: number;
  51526. tessellation?: number;
  51527. radiusFunction?: {
  51528. (i: number, distance: number): number;
  51529. };
  51530. cap?: number;
  51531. arc?: number;
  51532. updatable?: boolean;
  51533. sideOrientation?: number;
  51534. frontUVs?: Vector4;
  51535. backUVs?: Vector4;
  51536. instance?: Mesh;
  51537. invertUV?: boolean;
  51538. }, scene: Scene): Mesh;
  51539. /**
  51540. * Creates a polyhedron mesh
  51541. * * 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
  51542. * * The parameter `size` (positive float, default 1) sets the polygon size
  51543. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  51544. * * 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`
  51545. * * 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
  51546. * * 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)`)
  51547. * * 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
  51548. * * 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
  51549. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  51550. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  51551. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  51552. * @param name defines the name of the mesh
  51553. * @param options defines the options used to create the mesh
  51554. * @param scene defines the hosting scene
  51555. * @returns the polyhedron mesh
  51556. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  51557. */
  51558. static CreatePolyhedron(name: string, options: {
  51559. type?: number;
  51560. size?: number;
  51561. sizeX?: number;
  51562. sizeY?: number;
  51563. sizeZ?: number;
  51564. custom?: any;
  51565. faceUV?: Vector4[];
  51566. faceColors?: Color4[];
  51567. flat?: boolean;
  51568. updatable?: boolean;
  51569. sideOrientation?: number;
  51570. frontUVs?: Vector4;
  51571. backUVs?: Vector4;
  51572. }, scene: Scene): Mesh;
  51573. /**
  51574. * Creates a decal mesh.
  51575. * 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
  51576. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  51577. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  51578. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  51579. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  51580. * @param name defines the name of the mesh
  51581. * @param sourceMesh defines the mesh where the decal must be applied
  51582. * @param options defines the options used to create the mesh
  51583. * @param scene defines the hosting scene
  51584. * @returns the decal mesh
  51585. * @see https://doc.babylonjs.com/how_to/decals
  51586. */
  51587. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  51588. position?: Vector3;
  51589. normal?: Vector3;
  51590. size?: Vector3;
  51591. angle?: number;
  51592. }): Mesh;
  51593. }
  51594. }
  51595. declare module "babylonjs/Meshes/meshSimplification" {
  51596. import { Mesh } from "babylonjs/Meshes/mesh";
  51597. /**
  51598. * A simplifier interface for future simplification implementations
  51599. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  51600. */
  51601. export interface ISimplifier {
  51602. /**
  51603. * Simplification of a given mesh according to the given settings.
  51604. * Since this requires computation, it is assumed that the function runs async.
  51605. * @param settings The settings of the simplification, including quality and distance
  51606. * @param successCallback A callback that will be called after the mesh was simplified.
  51607. * @param errorCallback in case of an error, this callback will be called. optional.
  51608. */
  51609. simplify(settings: ISimplificationSettings, successCallback: (simplifiedMeshes: Mesh) => void, errorCallback?: () => void): void;
  51610. }
  51611. /**
  51612. * Expected simplification settings.
  51613. * Quality should be between 0 and 1 (1 being 100%, 0 being 0%)
  51614. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  51615. */
  51616. export interface ISimplificationSettings {
  51617. /**
  51618. * Gets or sets the expected quality
  51619. */
  51620. quality: number;
  51621. /**
  51622. * Gets or sets the distance when this optimized version should be used
  51623. */
  51624. distance: number;
  51625. /**
  51626. * Gets an already optimized mesh
  51627. */
  51628. optimizeMesh?: boolean;
  51629. }
  51630. /**
  51631. * Class used to specify simplification options
  51632. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  51633. */
  51634. export class SimplificationSettings implements ISimplificationSettings {
  51635. /** expected quality */
  51636. quality: number;
  51637. /** distance when this optimized version should be used */
  51638. distance: number;
  51639. /** already optimized mesh */
  51640. optimizeMesh?: boolean | undefined;
  51641. /**
  51642. * Creates a SimplificationSettings
  51643. * @param quality expected quality
  51644. * @param distance distance when this optimized version should be used
  51645. * @param optimizeMesh already optimized mesh
  51646. */
  51647. constructor(
  51648. /** expected quality */
  51649. quality: number,
  51650. /** distance when this optimized version should be used */
  51651. distance: number,
  51652. /** already optimized mesh */
  51653. optimizeMesh?: boolean | undefined);
  51654. }
  51655. /**
  51656. * Interface used to define a simplification task
  51657. */
  51658. export interface ISimplificationTask {
  51659. /**
  51660. * Array of settings
  51661. */
  51662. settings: Array<ISimplificationSettings>;
  51663. /**
  51664. * Simplification type
  51665. */
  51666. simplificationType: SimplificationType;
  51667. /**
  51668. * Mesh to simplify
  51669. */
  51670. mesh: Mesh;
  51671. /**
  51672. * Callback called on success
  51673. */
  51674. successCallback?: () => void;
  51675. /**
  51676. * Defines if parallel processing can be used
  51677. */
  51678. parallelProcessing: boolean;
  51679. }
  51680. /**
  51681. * Queue used to order the simplification tasks
  51682. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  51683. */
  51684. export class SimplificationQueue {
  51685. private _simplificationArray;
  51686. /**
  51687. * Gets a boolean indicating that the process is still running
  51688. */
  51689. running: boolean;
  51690. /**
  51691. * Creates a new queue
  51692. */
  51693. constructor();
  51694. /**
  51695. * Adds a new simplification task
  51696. * @param task defines a task to add
  51697. */
  51698. addTask(task: ISimplificationTask): void;
  51699. /**
  51700. * Execute next task
  51701. */
  51702. executeNext(): void;
  51703. /**
  51704. * Execute a simplification task
  51705. * @param task defines the task to run
  51706. */
  51707. runSimplification(task: ISimplificationTask): void;
  51708. private getSimplifier;
  51709. }
  51710. /**
  51711. * The implemented types of simplification
  51712. * At the moment only Quadratic Error Decimation is implemented
  51713. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  51714. */
  51715. export enum SimplificationType {
  51716. /** Quadratic error decimation */
  51717. QUADRATIC = 0
  51718. }
  51719. }
  51720. declare module "babylonjs/Meshes/meshSimplificationSceneComponent" {
  51721. import { Scene } from "babylonjs/scene";
  51722. import { SimplificationQueue, ISimplificationSettings, SimplificationType } from "babylonjs/Meshes/meshSimplification";
  51723. import { ISceneComponent } from "babylonjs/sceneComponent";
  51724. module "babylonjs/scene" {
  51725. interface Scene {
  51726. /** @hidden (Backing field) */
  51727. _simplificationQueue: SimplificationQueue;
  51728. /**
  51729. * Gets or sets the simplification queue attached to the scene
  51730. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  51731. */
  51732. simplificationQueue: SimplificationQueue;
  51733. }
  51734. }
  51735. module "babylonjs/Meshes/mesh" {
  51736. interface Mesh {
  51737. /**
  51738. * Simplify the mesh according to the given array of settings.
  51739. * Function will return immediately and will simplify async
  51740. * @param settings a collection of simplification settings
  51741. * @param parallelProcessing should all levels calculate parallel or one after the other
  51742. * @param simplificationType the type of simplification to run
  51743. * @param successCallback optional success callback to be called after the simplification finished processing all settings
  51744. * @returns the current mesh
  51745. */
  51746. simplify(settings: Array<ISimplificationSettings>, parallelProcessing?: boolean, simplificationType?: SimplificationType, successCallback?: (mesh?: Mesh, submeshIndex?: number) => void): Mesh;
  51747. }
  51748. }
  51749. /**
  51750. * Defines the simplification queue scene component responsible to help scheduling the various simplification task
  51751. * created in a scene
  51752. */
  51753. export class SimplicationQueueSceneComponent implements ISceneComponent {
  51754. /**
  51755. * The component name helpfull to identify the component in the list of scene components.
  51756. */
  51757. readonly name: string;
  51758. /**
  51759. * The scene the component belongs to.
  51760. */
  51761. scene: Scene;
  51762. /**
  51763. * Creates a new instance of the component for the given scene
  51764. * @param scene Defines the scene to register the component in
  51765. */
  51766. constructor(scene: Scene);
  51767. /**
  51768. * Registers the component in a given scene
  51769. */
  51770. register(): void;
  51771. /**
  51772. * Rebuilds the elements related to this component in case of
  51773. * context lost for instance.
  51774. */
  51775. rebuild(): void;
  51776. /**
  51777. * Disposes the component and the associated ressources
  51778. */
  51779. dispose(): void;
  51780. private _beforeCameraUpdate;
  51781. }
  51782. }
  51783. declare module "babylonjs/Meshes/Builders/index" {
  51784. export * from "babylonjs/Meshes/Builders/boxBuilder";
  51785. export * from "babylonjs/Meshes/Builders/discBuilder";
  51786. export * from "babylonjs/Meshes/Builders/ribbonBuilder";
  51787. export * from "babylonjs/Meshes/Builders/sphereBuilder";
  51788. export * from "babylonjs/Meshes/Builders/cylinderBuilder";
  51789. export * from "babylonjs/Meshes/Builders/torusBuilder";
  51790. export * from "babylonjs/Meshes/Builders/torusKnotBuilder";
  51791. export * from "babylonjs/Meshes/Builders/linesBuilder";
  51792. export * from "babylonjs/Meshes/Builders/polygonBuilder";
  51793. export * from "babylonjs/Meshes/Builders/shapeBuilder";
  51794. export * from "babylonjs/Meshes/Builders/latheBuilder";
  51795. export * from "babylonjs/Meshes/Builders/planeBuilder";
  51796. export * from "babylonjs/Meshes/Builders/groundBuilder";
  51797. export * from "babylonjs/Meshes/Builders/tubeBuilder";
  51798. export * from "babylonjs/Meshes/Builders/polyhedronBuilder";
  51799. export * from "babylonjs/Meshes/Builders/icoSphereBuilder";
  51800. export * from "babylonjs/Meshes/Builders/decalBuilder";
  51801. }
  51802. declare module "babylonjs/Meshes/index" {
  51803. export * from "babylonjs/Meshes/abstractMesh";
  51804. export * from "babylonjs/Meshes/buffer";
  51805. export * from "babylonjs/Meshes/Compression/index";
  51806. export * from "babylonjs/Meshes/csg";
  51807. export * from "babylonjs/Meshes/geometry";
  51808. export * from "babylonjs/Meshes/groundMesh";
  51809. export * from "babylonjs/Meshes/trailMesh";
  51810. export * from "babylonjs/Meshes/instancedMesh";
  51811. export * from "babylonjs/Meshes/linesMesh";
  51812. export * from "babylonjs/Meshes/mesh";
  51813. export * from "babylonjs/Meshes/mesh.vertexData";
  51814. export * from "babylonjs/Meshes/meshBuilder";
  51815. export * from "babylonjs/Meshes/meshSimplification";
  51816. export * from "babylonjs/Meshes/meshSimplificationSceneComponent";
  51817. export * from "babylonjs/Meshes/polygonMesh";
  51818. export * from "babylonjs/Meshes/subMesh";
  51819. export * from "babylonjs/Meshes/transformNode";
  51820. export * from "babylonjs/Meshes/Builders/index";
  51821. }
  51822. declare module "babylonjs/Morph/index" {
  51823. export * from "babylonjs/Morph/morphTarget";
  51824. export * from "babylonjs/Morph/morphTargetManager";
  51825. }
  51826. declare module "babylonjs/Offline/database" {
  51827. import { IOfflineProvider } from "babylonjs/Offline/IOfflineProvider";
  51828. /**
  51829. * Class used to enable access to IndexedDB
  51830. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  51831. */
  51832. export class Database implements IOfflineProvider {
  51833. private _callbackManifestChecked;
  51834. private _currentSceneUrl;
  51835. private _db;
  51836. private _enableSceneOffline;
  51837. private _enableTexturesOffline;
  51838. private _manifestVersionFound;
  51839. private _mustUpdateRessources;
  51840. private _hasReachedQuota;
  51841. private _isSupported;
  51842. private _idbFactory;
  51843. /** Gets a boolean indicating if the user agent supports blob storage (this value will be updated after creating the first Database object) */
  51844. private static IsUASupportingBlobStorage;
  51845. /**
  51846. * Gets a boolean indicating if Database storate is enabled (off by default)
  51847. */
  51848. static IDBStorageEnabled: boolean;
  51849. /**
  51850. * Gets a boolean indicating if scene must be saved in the database
  51851. */
  51852. readonly enableSceneOffline: boolean;
  51853. /**
  51854. * Gets a boolean indicating if textures must be saved in the database
  51855. */
  51856. readonly enableTexturesOffline: boolean;
  51857. /**
  51858. * Creates a new Database
  51859. * @param urlToScene defines the url to load the scene
  51860. * @param callbackManifestChecked defines the callback to use when manifest is checked
  51861. * @param disableManifestCheck defines a boolean indicating that we want to skip the manifest validation (it will be considered validated and up to date)
  51862. */
  51863. constructor(urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck?: boolean);
  51864. private static _ParseURL;
  51865. private static _ReturnFullUrlLocation;
  51866. private _checkManifestFile;
  51867. /**
  51868. * Open the database and make it available
  51869. * @param successCallback defines the callback to call on success
  51870. * @param errorCallback defines the callback to call on error
  51871. */
  51872. open(successCallback: () => void, errorCallback: () => void): void;
  51873. /**
  51874. * Loads an image from the database
  51875. * @param url defines the url to load from
  51876. * @param image defines the target DOM image
  51877. */
  51878. loadImage(url: string, image: HTMLImageElement): void;
  51879. private _loadImageFromDBAsync;
  51880. private _saveImageIntoDBAsync;
  51881. private _checkVersionFromDB;
  51882. private _loadVersionFromDBAsync;
  51883. private _saveVersionIntoDBAsync;
  51884. /**
  51885. * Loads a file from database
  51886. * @param url defines the URL to load from
  51887. * @param sceneLoaded defines a callback to call on success
  51888. * @param progressCallBack defines a callback to call when progress changed
  51889. * @param errorCallback defines a callback to call on error
  51890. * @param useArrayBuffer defines a boolean to use array buffer instead of text string
  51891. */
  51892. loadFile(url: string, sceneLoaded: (data: any) => void, progressCallBack?: (data: any) => void, errorCallback?: () => void, useArrayBuffer?: boolean): void;
  51893. private _loadFileAsync;
  51894. private _saveFileAsync;
  51895. /**
  51896. * Validates if xhr data is correct
  51897. * @param xhr defines the request to validate
  51898. * @param dataType defines the expected data type
  51899. * @returns true if data is correct
  51900. */
  51901. private static _ValidateXHRData;
  51902. }
  51903. }
  51904. declare module "babylonjs/Offline/index" {
  51905. export * from "babylonjs/Offline/database";
  51906. export * from "babylonjs/Offline/IOfflineProvider";
  51907. }
  51908. declare module "babylonjs/Shaders/gpuUpdateParticles.fragment" {
  51909. /** @hidden */
  51910. export var gpuUpdateParticlesPixelShader: {
  51911. name: string;
  51912. shader: string;
  51913. };
  51914. }
  51915. declare module "babylonjs/Shaders/gpuUpdateParticles.vertex" {
  51916. /** @hidden */
  51917. export var gpuUpdateParticlesVertexShader: {
  51918. name: string;
  51919. shader: string;
  51920. };
  51921. }
  51922. declare module "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration2" {
  51923. /** @hidden */
  51924. export var clipPlaneFragmentDeclaration2: {
  51925. name: string;
  51926. shader: string;
  51927. };
  51928. }
  51929. declare module "babylonjs/Shaders/gpuRenderParticles.fragment" {
  51930. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration2";
  51931. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  51932. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  51933. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  51934. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  51935. /** @hidden */
  51936. export var gpuRenderParticlesPixelShader: {
  51937. name: string;
  51938. shader: string;
  51939. };
  51940. }
  51941. declare module "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration2" {
  51942. /** @hidden */
  51943. export var clipPlaneVertexDeclaration2: {
  51944. name: string;
  51945. shader: string;
  51946. };
  51947. }
  51948. declare module "babylonjs/Shaders/gpuRenderParticles.vertex" {
  51949. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration2";
  51950. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  51951. /** @hidden */
  51952. export var gpuRenderParticlesVertexShader: {
  51953. name: string;
  51954. shader: string;
  51955. };
  51956. }
  51957. declare module "babylonjs/Particles/gpuParticleSystem" {
  51958. import { Nullable } from "babylonjs/types";
  51959. import { IAnimatable, IValueGradient, Color3Gradient } from "babylonjs/Misc/tools";
  51960. import { Observable } from "babylonjs/Misc/observable";
  51961. import { Color4, Color3 } from "babylonjs/Maths/math";
  51962. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  51963. import { BaseParticleSystem } from "babylonjs/Particles/baseParticleSystem";
  51964. import { Scene, IDisposable } from "babylonjs/scene";
  51965. import { RawTexture } from "babylonjs/Materials/Textures/rawTexture";
  51966. import "babylonjs/Shaders/gpuUpdateParticles.fragment";
  51967. import "babylonjs/Shaders/gpuUpdateParticles.vertex";
  51968. import "babylonjs/Shaders/gpuRenderParticles.fragment";
  51969. import "babylonjs/Shaders/gpuRenderParticles.vertex";
  51970. /**
  51971. * This represents a GPU particle system in Babylon
  51972. * This is the fastest particle system in Babylon as it uses the GPU to update the individual particle data
  51973. * @see https://www.babylonjs-playground.com/#PU4WYI#4
  51974. */
  51975. export class GPUParticleSystem extends BaseParticleSystem implements IDisposable, IParticleSystem, IAnimatable {
  51976. /**
  51977. * The layer mask we are rendering the particles through.
  51978. */
  51979. layerMask: number;
  51980. private _capacity;
  51981. private _activeCount;
  51982. private _currentActiveCount;
  51983. private _accumulatedCount;
  51984. private _renderEffect;
  51985. private _updateEffect;
  51986. private _buffer0;
  51987. private _buffer1;
  51988. private _spriteBuffer;
  51989. private _updateVAO;
  51990. private _renderVAO;
  51991. private _targetIndex;
  51992. private _sourceBuffer;
  51993. private _targetBuffer;
  51994. private _engine;
  51995. private _currentRenderId;
  51996. private _started;
  51997. private _stopped;
  51998. private _timeDelta;
  51999. private _randomTexture;
  52000. private _randomTexture2;
  52001. private _attributesStrideSize;
  52002. private _updateEffectOptions;
  52003. private _randomTextureSize;
  52004. private _actualFrame;
  52005. private readonly _rawTextureWidth;
  52006. /**
  52007. * Gets a boolean indicating if the GPU particles can be rendered on current browser
  52008. */
  52009. static readonly IsSupported: boolean;
  52010. /**
  52011. * An event triggered when the system is disposed.
  52012. */
  52013. onDisposeObservable: Observable<GPUParticleSystem>;
  52014. /**
  52015. * Gets the maximum number of particles active at the same time.
  52016. * @returns The max number of active particles.
  52017. */
  52018. getCapacity(): number;
  52019. /**
  52020. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  52021. * to override the particles.
  52022. */
  52023. forceDepthWrite: boolean;
  52024. /**
  52025. * Gets or set the number of active particles
  52026. */
  52027. activeParticleCount: number;
  52028. private _preWarmDone;
  52029. /**
  52030. * Is this system ready to be used/rendered
  52031. * @return true if the system is ready
  52032. */
  52033. isReady(): boolean;
  52034. /**
  52035. * Gets if the system has been started. (Note: this will still be true after stop is called)
  52036. * @returns True if it has been started, otherwise false.
  52037. */
  52038. isStarted(): boolean;
  52039. /**
  52040. * Starts the particle system and begins to emit
  52041. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  52042. */
  52043. start(delay?: number): void;
  52044. /**
  52045. * Stops the particle system.
  52046. */
  52047. stop(): void;
  52048. /**
  52049. * Remove all active particles
  52050. */
  52051. reset(): void;
  52052. /**
  52053. * Returns the string "GPUParticleSystem"
  52054. * @returns a string containing the class name
  52055. */
  52056. getClassName(): string;
  52057. private _colorGradientsTexture;
  52058. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: RawTexture): BaseParticleSystem;
  52059. /**
  52060. * Adds a new color gradient
  52061. * @param gradient defines the gradient to use (between 0 and 1)
  52062. * @param color1 defines the color to affect to the specified gradient
  52063. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  52064. * @returns the current particle system
  52065. */
  52066. addColorGradient(gradient: number, color1: Color4, color2?: Color4): GPUParticleSystem;
  52067. /**
  52068. * Remove a specific color gradient
  52069. * @param gradient defines the gradient to remove
  52070. * @returns the current particle system
  52071. */
  52072. removeColorGradient(gradient: number): GPUParticleSystem;
  52073. private _angularSpeedGradientsTexture;
  52074. private _sizeGradientsTexture;
  52075. private _velocityGradientsTexture;
  52076. private _limitVelocityGradientsTexture;
  52077. private _dragGradientsTexture;
  52078. private _addFactorGradient;
  52079. /**
  52080. * Adds a new size gradient
  52081. * @param gradient defines the gradient to use (between 0 and 1)
  52082. * @param factor defines the size factor to affect to the specified gradient
  52083. * @returns the current particle system
  52084. */
  52085. addSizeGradient(gradient: number, factor: number): GPUParticleSystem;
  52086. /**
  52087. * Remove a specific size gradient
  52088. * @param gradient defines the gradient to remove
  52089. * @returns the current particle system
  52090. */
  52091. removeSizeGradient(gradient: number): GPUParticleSystem;
  52092. /**
  52093. * Adds a new angular speed gradient
  52094. * @param gradient defines the gradient to use (between 0 and 1)
  52095. * @param factor defines the angular speed to affect to the specified gradient
  52096. * @returns the current particle system
  52097. */
  52098. addAngularSpeedGradient(gradient: number, factor: number): GPUParticleSystem;
  52099. /**
  52100. * Remove a specific angular speed gradient
  52101. * @param gradient defines the gradient to remove
  52102. * @returns the current particle system
  52103. */
  52104. removeAngularSpeedGradient(gradient: number): GPUParticleSystem;
  52105. /**
  52106. * Adds a new velocity gradient
  52107. * @param gradient defines the gradient to use (between 0 and 1)
  52108. * @param factor defines the velocity to affect to the specified gradient
  52109. * @returns the current particle system
  52110. */
  52111. addVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  52112. /**
  52113. * Remove a specific velocity gradient
  52114. * @param gradient defines the gradient to remove
  52115. * @returns the current particle system
  52116. */
  52117. removeVelocityGradient(gradient: number): GPUParticleSystem;
  52118. /**
  52119. * Adds a new limit velocity gradient
  52120. * @param gradient defines the gradient to use (between 0 and 1)
  52121. * @param factor defines the limit velocity value to affect to the specified gradient
  52122. * @returns the current particle system
  52123. */
  52124. addLimitVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  52125. /**
  52126. * Remove a specific limit velocity gradient
  52127. * @param gradient defines the gradient to remove
  52128. * @returns the current particle system
  52129. */
  52130. removeLimitVelocityGradient(gradient: number): GPUParticleSystem;
  52131. /**
  52132. * Adds a new drag gradient
  52133. * @param gradient defines the gradient to use (between 0 and 1)
  52134. * @param factor defines the drag value to affect to the specified gradient
  52135. * @returns the current particle system
  52136. */
  52137. addDragGradient(gradient: number, factor: number): GPUParticleSystem;
  52138. /**
  52139. * Remove a specific drag gradient
  52140. * @param gradient defines the gradient to remove
  52141. * @returns the current particle system
  52142. */
  52143. removeDragGradient(gradient: number): GPUParticleSystem;
  52144. /**
  52145. * Not supported by GPUParticleSystem
  52146. * @param gradient defines the gradient to use (between 0 and 1)
  52147. * @param factor defines the emit rate value to affect to the specified gradient
  52148. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  52149. * @returns the current particle system
  52150. */
  52151. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  52152. /**
  52153. * Not supported by GPUParticleSystem
  52154. * @param gradient defines the gradient to remove
  52155. * @returns the current particle system
  52156. */
  52157. removeEmitRateGradient(gradient: number): IParticleSystem;
  52158. /**
  52159. * Not supported by GPUParticleSystem
  52160. * @param gradient defines the gradient to use (between 0 and 1)
  52161. * @param factor defines the start size value to affect to the specified gradient
  52162. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  52163. * @returns the current particle system
  52164. */
  52165. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  52166. /**
  52167. * Not supported by GPUParticleSystem
  52168. * @param gradient defines the gradient to remove
  52169. * @returns the current particle system
  52170. */
  52171. removeStartSizeGradient(gradient: number): IParticleSystem;
  52172. /**
  52173. * Not supported by GPUParticleSystem
  52174. * @param gradient defines the gradient to use (between 0 and 1)
  52175. * @param min defines the color remap minimal range
  52176. * @param max defines the color remap maximal range
  52177. * @returns the current particle system
  52178. */
  52179. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  52180. /**
  52181. * Not supported by GPUParticleSystem
  52182. * @param gradient defines the gradient to remove
  52183. * @returns the current particle system
  52184. */
  52185. removeColorRemapGradient(): IParticleSystem;
  52186. /**
  52187. * Not supported by GPUParticleSystem
  52188. * @param gradient defines the gradient to use (between 0 and 1)
  52189. * @param min defines the alpha remap minimal range
  52190. * @param max defines the alpha remap maximal range
  52191. * @returns the current particle system
  52192. */
  52193. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  52194. /**
  52195. * Not supported by GPUParticleSystem
  52196. * @param gradient defines the gradient to remove
  52197. * @returns the current particle system
  52198. */
  52199. removeAlphaRemapGradient(): IParticleSystem;
  52200. /**
  52201. * Not supported by GPUParticleSystem
  52202. * @param gradient defines the gradient to use (between 0 and 1)
  52203. * @param color defines the color to affect to the specified gradient
  52204. * @returns the current particle system
  52205. */
  52206. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  52207. /**
  52208. * Not supported by GPUParticleSystem
  52209. * @param gradient defines the gradient to remove
  52210. * @returns the current particle system
  52211. */
  52212. removeRampGradient(): IParticleSystem;
  52213. /**
  52214. * Not supported by GPUParticleSystem
  52215. * @returns the list of ramp gradients
  52216. */
  52217. getRampGradients(): Nullable<Array<Color3Gradient>>;
  52218. /**
  52219. * Not supported by GPUParticleSystem
  52220. * Gets or sets a boolean indicating that ramp gradients must be used
  52221. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  52222. */
  52223. useRampGradients: boolean;
  52224. /**
  52225. * Not supported by GPUParticleSystem
  52226. * @param gradient defines the gradient to use (between 0 and 1)
  52227. * @param factor defines the life time factor to affect to the specified gradient
  52228. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  52229. * @returns the current particle system
  52230. */
  52231. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  52232. /**
  52233. * Not supported by GPUParticleSystem
  52234. * @param gradient defines the gradient to remove
  52235. * @returns the current particle system
  52236. */
  52237. removeLifeTimeGradient(gradient: number): IParticleSystem;
  52238. /**
  52239. * Instantiates a GPU particle system.
  52240. * 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.
  52241. * @param name The name of the particle system
  52242. * @param options The options used to create the system
  52243. * @param scene The scene the particle system belongs to
  52244. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  52245. */
  52246. constructor(name: string, options: Partial<{
  52247. capacity: number;
  52248. randomTextureSize: number;
  52249. }>, scene: Scene, isAnimationSheetEnabled?: boolean);
  52250. protected _reset(): void;
  52251. private _createUpdateVAO;
  52252. private _createRenderVAO;
  52253. private _initialize;
  52254. /** @hidden */
  52255. _recreateUpdateEffect(): void;
  52256. /** @hidden */
  52257. _recreateRenderEffect(): void;
  52258. /**
  52259. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  52260. * @param preWarm defines if we are in the pre-warmimg phase
  52261. */
  52262. animate(preWarm?: boolean): void;
  52263. private _createFactorGradientTexture;
  52264. private _createSizeGradientTexture;
  52265. private _createAngularSpeedGradientTexture;
  52266. private _createVelocityGradientTexture;
  52267. private _createLimitVelocityGradientTexture;
  52268. private _createDragGradientTexture;
  52269. private _createColorGradientTexture;
  52270. /**
  52271. * Renders the particle system in its current state
  52272. * @param preWarm defines if the system should only update the particles but not render them
  52273. * @returns the current number of particles
  52274. */
  52275. render(preWarm?: boolean): number;
  52276. /**
  52277. * Rebuilds the particle system
  52278. */
  52279. rebuild(): void;
  52280. private _releaseBuffers;
  52281. private _releaseVAOs;
  52282. /**
  52283. * Disposes the particle system and free the associated resources
  52284. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  52285. */
  52286. dispose(disposeTexture?: boolean): void;
  52287. /**
  52288. * Clones the particle system.
  52289. * @param name The name of the cloned object
  52290. * @param newEmitter The new emitter to use
  52291. * @returns the cloned particle system
  52292. */
  52293. clone(name: string, newEmitter: any): GPUParticleSystem;
  52294. /**
  52295. * Serializes the particle system to a JSON object.
  52296. * @returns the JSON object
  52297. */
  52298. serialize(): any;
  52299. /**
  52300. * Parses a JSON object to create a GPU particle system.
  52301. * @param parsedParticleSystem The JSON object to parse
  52302. * @param scene The scene to create the particle system in
  52303. * @param rootUrl The root url to use to load external dependencies like texture
  52304. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  52305. * @returns the parsed GPU particle system
  52306. */
  52307. static Parse(parsedParticleSystem: any, scene: Scene, rootUrl: string, doNotStart?: boolean): GPUParticleSystem;
  52308. }
  52309. }
  52310. declare module "babylonjs/Particles/particleSystemSet" {
  52311. import { Nullable } from "babylonjs/types";
  52312. import { Color3 } from "babylonjs/Maths/math";
  52313. import { TransformNode } from "babylonjs/Meshes/transformNode";
  52314. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  52315. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  52316. import { Scene, IDisposable } from "babylonjs/scene";
  52317. /**
  52318. * Represents a set of particle systems working together to create a specific effect
  52319. */
  52320. export class ParticleSystemSet implements IDisposable {
  52321. private _emitterCreationOptions;
  52322. private _emitterNode;
  52323. /**
  52324. * Gets the particle system list
  52325. */
  52326. systems: IParticleSystem[];
  52327. /**
  52328. * Gets the emitter node used with this set
  52329. */
  52330. readonly emitterNode: Nullable<TransformNode>;
  52331. /**
  52332. * Creates a new emitter mesh as a sphere
  52333. * @param options defines the options used to create the sphere
  52334. * @param renderingGroupId defines the renderingGroupId to use for the sphere
  52335. * @param scene defines the hosting scene
  52336. */
  52337. setEmitterAsSphere(options: {
  52338. diameter: number;
  52339. segments: number;
  52340. color: Color3;
  52341. }, renderingGroupId: number, scene: Scene): void;
  52342. /**
  52343. * Starts all particle systems of the set
  52344. * @param emitter defines an optional mesh to use as emitter for the particle systems
  52345. */
  52346. start(emitter?: AbstractMesh): void;
  52347. /**
  52348. * Release all associated resources
  52349. */
  52350. dispose(): void;
  52351. /**
  52352. * Serialize the set into a JSON compatible object
  52353. * @returns a JSON compatible representation of the set
  52354. */
  52355. serialize(): any;
  52356. /**
  52357. * Parse a new ParticleSystemSet from a serialized source
  52358. * @param data defines a JSON compatible representation of the set
  52359. * @param scene defines the hosting scene
  52360. * @param gpu defines if we want GPU particles or CPU particles
  52361. * @returns a new ParticleSystemSet
  52362. */
  52363. static Parse(data: any, scene: Scene, gpu?: boolean): ParticleSystemSet;
  52364. }
  52365. }
  52366. declare module "babylonjs/Particles/particleHelper" {
  52367. import { Nullable } from "babylonjs/types";
  52368. import { Scene } from "babylonjs/scene";
  52369. import { Vector3 } from "babylonjs/Maths/math";
  52370. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  52371. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  52372. import { ParticleSystemSet } from "babylonjs/Particles/particleSystemSet";
  52373. /**
  52374. * This class is made for on one-liner static method to help creating particle system set.
  52375. */
  52376. export class ParticleHelper {
  52377. /**
  52378. * Gets or sets base Assets URL
  52379. */
  52380. static BaseAssetsUrl: string;
  52381. /**
  52382. * Create a default particle system that you can tweak
  52383. * @param emitter defines the emitter to use
  52384. * @param capacity defines the system capacity (default is 500 particles)
  52385. * @param scene defines the hosting scene
  52386. * @param useGPU defines if a GPUParticleSystem must be created (default is false)
  52387. * @returns the new Particle system
  52388. */
  52389. static CreateDefault(emitter: Nullable<AbstractMesh | Vector3>, capacity?: number, scene?: Scene, useGPU?: boolean): IParticleSystem;
  52390. /**
  52391. * This is the main static method (one-liner) of this helper to create different particle systems
  52392. * @param type This string represents the type to the particle system to create
  52393. * @param scene The scene where the particle system should live
  52394. * @param gpu If the system will use gpu
  52395. * @returns the ParticleSystemSet created
  52396. */
  52397. static CreateAsync(type: string, scene: Nullable<Scene>, gpu?: boolean): Promise<ParticleSystemSet>;
  52398. /**
  52399. * Static function used to export a particle system to a ParticleSystemSet variable.
  52400. * Please note that the emitter shape is not exported
  52401. * @param systems defines the particle systems to export
  52402. * @returns the created particle system set
  52403. */
  52404. static ExportSet(systems: IParticleSystem[]): ParticleSystemSet;
  52405. }
  52406. }
  52407. declare module "babylonjs/Particles/particleSystemComponent" {
  52408. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  52409. import { Effect, EffectFallbacks } from "babylonjs/Materials/effect";
  52410. import "babylonjs/Shaders/particles.vertex";
  52411. module "babylonjs/Engines/engine" {
  52412. interface Engine {
  52413. /**
  52414. * Create an effect to use with particle systems.
  52415. * Please note that some parameters like animation sheets or not being billboard are not supported in this configuration
  52416. * @param fragmentName defines the base name of the effect (The name of file without .fragment.fx)
  52417. * @param uniformsNames defines a list of attribute names
  52418. * @param samplers defines an array of string used to represent textures
  52419. * @param defines defines the string containing the defines to use to compile the shaders
  52420. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  52421. * @param onCompiled defines a function to call when the effect creation is successful
  52422. * @param onError defines a function to call when the effect creation has failed
  52423. * @returns the new Effect
  52424. */
  52425. createEffectForParticles(fragmentName: string, uniformsNames: string[], samplers: string[], defines: string, fallbacks?: EffectFallbacks, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): Effect;
  52426. }
  52427. }
  52428. module "babylonjs/Meshes/mesh" {
  52429. interface Mesh {
  52430. /**
  52431. * Returns an array populated with IParticleSystem objects whose the mesh is the emitter
  52432. * @returns an array of IParticleSystem
  52433. */
  52434. getEmittedParticleSystems(): IParticleSystem[];
  52435. /**
  52436. * Returns an array populated with IParticleSystem objects whose the mesh or its children are the emitter
  52437. * @returns an array of IParticleSystem
  52438. */
  52439. getHierarchyEmittedParticleSystems(): IParticleSystem[];
  52440. }
  52441. }
  52442. /**
  52443. * @hidden
  52444. */
  52445. export var _IDoNeedToBeInTheBuild: number;
  52446. }
  52447. declare module "babylonjs/Particles/index" {
  52448. export * from "babylonjs/Particles/baseParticleSystem";
  52449. export * from "babylonjs/Particles/EmitterTypes/index";
  52450. export * from "babylonjs/Particles/gpuParticleSystem";
  52451. export * from "babylonjs/Particles/IParticleSystem";
  52452. export * from "babylonjs/Particles/particle";
  52453. export * from "babylonjs/Particles/particleHelper";
  52454. export * from "babylonjs/Particles/particleSystem";
  52455. export * from "babylonjs/Particles/particleSystemComponent";
  52456. export * from "babylonjs/Particles/particleSystemSet";
  52457. export * from "babylonjs/Particles/solidParticle";
  52458. export * from "babylonjs/Particles/solidParticleSystem";
  52459. export * from "babylonjs/Particles/subEmitter";
  52460. }
  52461. declare module "babylonjs/Physics/physicsEngineComponent" {
  52462. import { Nullable } from "babylonjs/types";
  52463. import { Observable, Observer } from "babylonjs/Misc/observable";
  52464. import { Vector3 } from "babylonjs/Maths/math";
  52465. import { Mesh } from "babylonjs/Meshes/mesh";
  52466. import { ISceneComponent } from "babylonjs/sceneComponent";
  52467. import { Scene } from "babylonjs/scene";
  52468. import { Node } from "babylonjs/node";
  52469. import { IPhysicsEngine, IPhysicsEnginePlugin } from "babylonjs/Physics/IPhysicsEngine";
  52470. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  52471. module "babylonjs/scene" {
  52472. interface Scene {
  52473. /** @hidden (Backing field) */
  52474. _physicsEngine: Nullable<IPhysicsEngine>;
  52475. /**
  52476. * Gets the current physics engine
  52477. * @returns a IPhysicsEngine or null if none attached
  52478. */
  52479. getPhysicsEngine(): Nullable<IPhysicsEngine>;
  52480. /**
  52481. * Enables physics to the current scene
  52482. * @param gravity defines the scene's gravity for the physics engine
  52483. * @param plugin defines the physics engine to be used. defaults to OimoJS.
  52484. * @return a boolean indicating if the physics engine was initialized
  52485. */
  52486. enablePhysics(gravity: Nullable<Vector3>, plugin?: IPhysicsEnginePlugin): boolean;
  52487. /**
  52488. * Disables and disposes the physics engine associated with the scene
  52489. */
  52490. disablePhysicsEngine(): void;
  52491. /**
  52492. * Gets a boolean indicating if there is an active physics engine
  52493. * @returns a boolean indicating if there is an active physics engine
  52494. */
  52495. isPhysicsEnabled(): boolean;
  52496. /**
  52497. * Deletes a physics compound impostor
  52498. * @param compound defines the compound to delete
  52499. */
  52500. deleteCompoundImpostor(compound: any): void;
  52501. /**
  52502. * An event triggered when physic simulation is about to be run
  52503. */
  52504. onBeforePhysicsObservable: Observable<Scene>;
  52505. /**
  52506. * An event triggered when physic simulation has been done
  52507. */
  52508. onAfterPhysicsObservable: Observable<Scene>;
  52509. }
  52510. }
  52511. module "babylonjs/Meshes/abstractMesh" {
  52512. interface AbstractMesh {
  52513. /** @hidden */
  52514. _physicsImpostor: Nullable<PhysicsImpostor>;
  52515. /**
  52516. * Gets or sets impostor used for physic simulation
  52517. * @see http://doc.babylonjs.com/features/physics_engine
  52518. */
  52519. physicsImpostor: Nullable<PhysicsImpostor>;
  52520. /**
  52521. * Gets the current physics impostor
  52522. * @see http://doc.babylonjs.com/features/physics_engine
  52523. * @returns a physics impostor or null
  52524. */
  52525. getPhysicsImpostor(): Nullable<PhysicsImpostor>;
  52526. /** Apply a physic impulse to the mesh
  52527. * @param force defines the force to apply
  52528. * @param contactPoint defines where to apply the force
  52529. * @returns the current mesh
  52530. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  52531. */
  52532. applyImpulse(force: Vector3, contactPoint: Vector3): AbstractMesh;
  52533. /**
  52534. * Creates a physic joint between two meshes
  52535. * @param otherMesh defines the other mesh to use
  52536. * @param pivot1 defines the pivot to use on this mesh
  52537. * @param pivot2 defines the pivot to use on the other mesh
  52538. * @param options defines additional options (can be plugin dependent)
  52539. * @returns the current mesh
  52540. * @see https://www.babylonjs-playground.com/#0BS5U0#0
  52541. */
  52542. setPhysicsLinkWith(otherMesh: Mesh, pivot1: Vector3, pivot2: Vector3, options?: any): AbstractMesh;
  52543. /** @hidden */
  52544. _disposePhysicsObserver: Nullable<Observer<Node>>;
  52545. }
  52546. }
  52547. /**
  52548. * Defines the physics engine scene component responsible to manage a physics engine
  52549. */
  52550. export class PhysicsEngineSceneComponent implements ISceneComponent {
  52551. /**
  52552. * The component name helpful to identify the component in the list of scene components.
  52553. */
  52554. readonly name: string;
  52555. /**
  52556. * The scene the component belongs to.
  52557. */
  52558. scene: Scene;
  52559. /**
  52560. * Creates a new instance of the component for the given scene
  52561. * @param scene Defines the scene to register the component in
  52562. */
  52563. constructor(scene: Scene);
  52564. /**
  52565. * Registers the component in a given scene
  52566. */
  52567. register(): void;
  52568. /**
  52569. * Rebuilds the elements related to this component in case of
  52570. * context lost for instance.
  52571. */
  52572. rebuild(): void;
  52573. /**
  52574. * Disposes the component and the associated ressources
  52575. */
  52576. dispose(): void;
  52577. }
  52578. }
  52579. declare module "babylonjs/Physics/physicsHelper" {
  52580. import { Nullable } from "babylonjs/types";
  52581. import { Vector3 } from "babylonjs/Maths/math";
  52582. import { Mesh } from "babylonjs/Meshes/mesh";
  52583. import { Scene } from "babylonjs/scene";
  52584. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  52585. /**
  52586. * A helper for physics simulations
  52587. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  52588. */
  52589. export class PhysicsHelper {
  52590. private _scene;
  52591. private _physicsEngine;
  52592. /**
  52593. * Initializes the Physics helper
  52594. * @param scene Babylon.js scene
  52595. */
  52596. constructor(scene: Scene);
  52597. /**
  52598. * Applies a radial explosion impulse
  52599. * @param origin the origin of the explosion
  52600. * @param radiusOrEventOptions the radius or the options of radial explosion
  52601. * @param strength the explosion strength
  52602. * @param falloff possible options: Constant & Linear. Defaults to Constant
  52603. * @returns A physics radial explosion event, or null
  52604. */
  52605. applyRadialExplosionImpulse(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  52606. /**
  52607. * Applies a radial explosion force
  52608. * @param origin the origin of the explosion
  52609. * @param radiusOrEventOptions the radius or the options of radial explosion
  52610. * @param strength the explosion strength
  52611. * @param falloff possible options: Constant & Linear. Defaults to Constant
  52612. * @returns A physics radial explosion event, or null
  52613. */
  52614. applyRadialExplosionForce(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  52615. /**
  52616. * Creates a gravitational field
  52617. * @param origin the origin of the explosion
  52618. * @param radiusOrEventOptions the radius or the options of radial explosion
  52619. * @param strength the explosion strength
  52620. * @param falloff possible options: Constant & Linear. Defaults to Constant
  52621. * @returns A physics gravitational field event, or null
  52622. */
  52623. gravitationalField(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsGravitationalFieldEvent>;
  52624. /**
  52625. * Creates a physics updraft event
  52626. * @param origin the origin of the updraft
  52627. * @param radiusOrEventOptions the radius or the options of the updraft
  52628. * @param strength the strength of the updraft
  52629. * @param height the height of the updraft
  52630. * @param updraftMode possible options: Center & Perpendicular. Defaults to Center
  52631. * @returns A physics updraft event, or null
  52632. */
  52633. updraft(origin: Vector3, radiusOrEventOptions: number | PhysicsUpdraftEventOptions, strength?: number, height?: number, updraftMode?: PhysicsUpdraftMode): Nullable<PhysicsUpdraftEvent>;
  52634. /**
  52635. * Creates a physics vortex event
  52636. * @param origin the of the vortex
  52637. * @param radiusOrEventOptions the radius or the options of the vortex
  52638. * @param strength the strength of the vortex
  52639. * @param height the height of the vortex
  52640. * @returns a Physics vortex event, or null
  52641. * A physics vortex event or null
  52642. */
  52643. vortex(origin: Vector3, radiusOrEventOptions: number | PhysicsVortexEventOptions, strength?: number, height?: number): Nullable<PhysicsVortexEvent>;
  52644. }
  52645. /**
  52646. * Represents a physics radial explosion event
  52647. */
  52648. class PhysicsRadialExplosionEvent {
  52649. private _scene;
  52650. private _options;
  52651. private _sphere;
  52652. private _dataFetched;
  52653. /**
  52654. * Initializes a radial explosioin event
  52655. * @param _scene BabylonJS scene
  52656. * @param _options The options for the vortex event
  52657. */
  52658. constructor(_scene: Scene, _options: PhysicsRadialExplosionEventOptions);
  52659. /**
  52660. * Returns the data related to the radial explosion event (sphere).
  52661. * @returns The radial explosion event data
  52662. */
  52663. getData(): PhysicsRadialExplosionEventData;
  52664. /**
  52665. * Returns the force and contact point of the impostor or false, if the impostor is not affected by the force/impulse.
  52666. * @param impostor A physics imposter
  52667. * @param origin the origin of the explosion
  52668. * @returns {Nullable<PhysicsForceAndContactPoint>} A physics force and contact point, or null
  52669. */
  52670. getImpostorForceAndContactPoint(impostor: PhysicsImpostor, origin: Vector3): Nullable<PhysicsForceAndContactPoint>;
  52671. /**
  52672. * Disposes the sphere.
  52673. * @param force Specifies if the sphere should be disposed by force
  52674. */
  52675. dispose(force?: boolean): void;
  52676. /*** Helpers ***/
  52677. private _prepareSphere;
  52678. private _intersectsWithSphere;
  52679. }
  52680. /**
  52681. * Represents a gravitational field event
  52682. */
  52683. class PhysicsGravitationalFieldEvent {
  52684. private _physicsHelper;
  52685. private _scene;
  52686. private _origin;
  52687. private _options;
  52688. private _tickCallback;
  52689. private _sphere;
  52690. private _dataFetched;
  52691. /**
  52692. * Initializes the physics gravitational field event
  52693. * @param _physicsHelper A physics helper
  52694. * @param _scene BabylonJS scene
  52695. * @param _origin The origin position of the gravitational field event
  52696. * @param _options The options for the vortex event
  52697. */
  52698. constructor(_physicsHelper: PhysicsHelper, _scene: Scene, _origin: Vector3, _options: PhysicsRadialExplosionEventOptions);
  52699. /**
  52700. * Returns the data related to the gravitational field event (sphere).
  52701. * @returns A gravitational field event
  52702. */
  52703. getData(): PhysicsGravitationalFieldEventData;
  52704. /**
  52705. * Enables the gravitational field.
  52706. */
  52707. enable(): void;
  52708. /**
  52709. * Disables the gravitational field.
  52710. */
  52711. disable(): void;
  52712. /**
  52713. * Disposes the sphere.
  52714. * @param force The force to dispose from the gravitational field event
  52715. */
  52716. dispose(force?: boolean): void;
  52717. private _tick;
  52718. }
  52719. /**
  52720. * Represents a physics updraft event
  52721. */
  52722. class PhysicsUpdraftEvent {
  52723. private _scene;
  52724. private _origin;
  52725. private _options;
  52726. private _physicsEngine;
  52727. private _originTop;
  52728. private _originDirection;
  52729. private _tickCallback;
  52730. private _cylinder;
  52731. private _cylinderPosition;
  52732. private _dataFetched;
  52733. /**
  52734. * Initializes the physics updraft event
  52735. * @param _scene BabylonJS scene
  52736. * @param _origin The origin position of the updraft
  52737. * @param _options The options for the updraft event
  52738. */
  52739. constructor(_scene: Scene, _origin: Vector3, _options: PhysicsUpdraftEventOptions);
  52740. /**
  52741. * Returns the data related to the updraft event (cylinder).
  52742. * @returns A physics updraft event
  52743. */
  52744. getData(): PhysicsUpdraftEventData;
  52745. /**
  52746. * Enables the updraft.
  52747. */
  52748. enable(): void;
  52749. /**
  52750. * Disables the updraft.
  52751. */
  52752. disable(): void;
  52753. /**
  52754. * Disposes the cylinder.
  52755. * @param force Specifies if the updraft should be disposed by force
  52756. */
  52757. dispose(force?: boolean): void;
  52758. private getImpostorForceAndContactPoint;
  52759. private _tick;
  52760. /*** Helpers ***/
  52761. private _prepareCylinder;
  52762. private _intersectsWithCylinder;
  52763. }
  52764. /**
  52765. * Represents a physics vortex event
  52766. */
  52767. class PhysicsVortexEvent {
  52768. private _scene;
  52769. private _origin;
  52770. private _options;
  52771. private _physicsEngine;
  52772. private _originTop;
  52773. private _tickCallback;
  52774. private _cylinder;
  52775. private _cylinderPosition;
  52776. private _dataFetched;
  52777. /**
  52778. * Initializes the physics vortex event
  52779. * @param _scene The BabylonJS scene
  52780. * @param _origin The origin position of the vortex
  52781. * @param _options The options for the vortex event
  52782. */
  52783. constructor(_scene: Scene, _origin: Vector3, _options: PhysicsVortexEventOptions);
  52784. /**
  52785. * Returns the data related to the vortex event (cylinder).
  52786. * @returns The physics vortex event data
  52787. */
  52788. getData(): PhysicsVortexEventData;
  52789. /**
  52790. * Enables the vortex.
  52791. */
  52792. enable(): void;
  52793. /**
  52794. * Disables the cortex.
  52795. */
  52796. disable(): void;
  52797. /**
  52798. * Disposes the sphere.
  52799. * @param force
  52800. */
  52801. dispose(force?: boolean): void;
  52802. private getImpostorForceAndContactPoint;
  52803. private _tick;
  52804. /*** Helpers ***/
  52805. private _prepareCylinder;
  52806. private _intersectsWithCylinder;
  52807. }
  52808. /**
  52809. * Options fot the radial explosion event
  52810. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  52811. */
  52812. export class PhysicsRadialExplosionEventOptions {
  52813. /**
  52814. * The radius of the sphere for the radial explosion.
  52815. */
  52816. radius: number;
  52817. /**
  52818. * The strenth of the explosion.
  52819. */
  52820. strength: number;
  52821. /**
  52822. * The strenght of the force in correspondence to the distance of the affected object
  52823. */
  52824. falloff: PhysicsRadialImpulseFalloff;
  52825. /**
  52826. * Sphere options for the radial explosion.
  52827. */
  52828. sphere: {
  52829. segments: number;
  52830. diameter: number;
  52831. };
  52832. }
  52833. /**
  52834. * Options fot the updraft event
  52835. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  52836. */
  52837. export class PhysicsUpdraftEventOptions {
  52838. /**
  52839. * The radius of the cylinder for the vortex
  52840. */
  52841. radius: number;
  52842. /**
  52843. * The strenth of the updraft.
  52844. */
  52845. strength: number;
  52846. /**
  52847. * The height of the cylinder for the updraft.
  52848. */
  52849. height: number;
  52850. /**
  52851. * The mode for the the updraft.
  52852. */
  52853. updraftMode: PhysicsUpdraftMode;
  52854. }
  52855. /**
  52856. * Options fot the vortex event
  52857. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  52858. */
  52859. export class PhysicsVortexEventOptions {
  52860. /**
  52861. * The radius of the cylinder for the vortex
  52862. */
  52863. radius: number;
  52864. /**
  52865. * The strenth of the vortex.
  52866. */
  52867. strength: number;
  52868. /**
  52869. * The height of the cylinder for the vortex.
  52870. */
  52871. height: number;
  52872. /**
  52873. * At which distance, relative to the radius the centripetal forces should kick in? Range: 0-1
  52874. */
  52875. centripetalForceThreshold: number;
  52876. /**
  52877. * This multiplier determines with how much force the objects will be pushed sideways/around the vortex, when below the treshold.
  52878. */
  52879. centripetalForceMultiplier: number;
  52880. /**
  52881. * This multiplier determines with how much force the objects will be pushed sideways/around the vortex, when above the treshold.
  52882. */
  52883. centrifugalForceMultiplier: number;
  52884. /**
  52885. * This multiplier determines with how much force the objects will be pushed upwards, when in the vortex.
  52886. */
  52887. updraftForceMultiplier: number;
  52888. }
  52889. /**
  52890. * The strenght of the force in correspondence to the distance of the affected object
  52891. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  52892. */
  52893. export enum PhysicsRadialImpulseFalloff {
  52894. /** Defines that impulse is constant in strength across it's whole radius */
  52895. Constant = 0,
  52896. /** Defines that impulse gets weaker if it's further from the origin */
  52897. Linear = 1
  52898. }
  52899. /**
  52900. * The strength of the force in correspondence to the distance of the affected object
  52901. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  52902. */
  52903. export enum PhysicsUpdraftMode {
  52904. /** Defines that the upstream forces will pull towards the top center of the cylinder */
  52905. Center = 0,
  52906. /** Defines that once a impostor is inside the cylinder, it will shoot out perpendicular from the ground of the cylinder */
  52907. Perpendicular = 1
  52908. }
  52909. /**
  52910. * Interface for a physics force and contact point
  52911. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  52912. */
  52913. export interface PhysicsForceAndContactPoint {
  52914. /**
  52915. * The force applied at the contact point
  52916. */
  52917. force: Vector3;
  52918. /**
  52919. * The contact point
  52920. */
  52921. contactPoint: Vector3;
  52922. }
  52923. /**
  52924. * Interface for radial explosion event data
  52925. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  52926. */
  52927. export interface PhysicsRadialExplosionEventData {
  52928. /**
  52929. * A sphere used for the radial explosion event
  52930. */
  52931. sphere: Mesh;
  52932. }
  52933. /**
  52934. * Interface for gravitational field event data
  52935. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  52936. */
  52937. export interface PhysicsGravitationalFieldEventData {
  52938. /**
  52939. * A sphere mesh used for the gravitational field event
  52940. */
  52941. sphere: Mesh;
  52942. }
  52943. /**
  52944. * Interface for updraft event data
  52945. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  52946. */
  52947. export interface PhysicsUpdraftEventData {
  52948. /**
  52949. * A cylinder used for the updraft event
  52950. */
  52951. cylinder: Mesh;
  52952. }
  52953. /**
  52954. * Interface for vortex event data
  52955. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  52956. */
  52957. export interface PhysicsVortexEventData {
  52958. /**
  52959. * A cylinder used for the vortex event
  52960. */
  52961. cylinder: Mesh;
  52962. }
  52963. }
  52964. declare module "babylonjs/Physics/Plugins/ammoJSPlugin" {
  52965. import { Quaternion, Vector3 } from "babylonjs/Maths/math";
  52966. import { IPhysicsEnginePlugin, PhysicsImpostorJoint } from "babylonjs/Physics/IPhysicsEngine";
  52967. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  52968. import { PhysicsJoint, IMotorEnabledJoint } from "babylonjs/Physics/physicsJoint";
  52969. import { Nullable } from "babylonjs/types";
  52970. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  52971. import { PhysicsRaycastResult } from "babylonjs/Physics/physicsRaycastResult";
  52972. /**
  52973. * AmmoJS Physics plugin
  52974. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  52975. * @see https://github.com/kripken/ammo.js/
  52976. */
  52977. export class AmmoJSPlugin implements IPhysicsEnginePlugin {
  52978. private _useDeltaForWorldStep;
  52979. /**
  52980. * Reference to the Ammo library
  52981. */
  52982. bjsAMMO: any;
  52983. /**
  52984. * Created ammoJS world which physics bodies are added to
  52985. */
  52986. world: any;
  52987. /**
  52988. * Name of the plugin
  52989. */
  52990. name: string;
  52991. private _timeStep;
  52992. private _fixedTimeStep;
  52993. private _maxSteps;
  52994. private _tmpQuaternion;
  52995. private _tmpAmmoTransform;
  52996. private _tmpAmmoQuaternion;
  52997. private _tmpAmmoConcreteContactResultCallback;
  52998. private _collisionConfiguration;
  52999. private _dispatcher;
  53000. private _overlappingPairCache;
  53001. private _solver;
  53002. private _softBodySolver;
  53003. private _tmpAmmoVectorA;
  53004. private _tmpAmmoVectorB;
  53005. private _tmpAmmoVectorC;
  53006. private _tmpAmmoVectorD;
  53007. private _tmpContactCallbackResult;
  53008. private _tmpAmmoVectorRCA;
  53009. private _tmpAmmoVectorRCB;
  53010. private _raycastResult;
  53011. private static readonly DISABLE_COLLISION_FLAG;
  53012. private static readonly KINEMATIC_FLAG;
  53013. private static readonly DISABLE_DEACTIVATION_FLAG;
  53014. /**
  53015. * Initializes the ammoJS plugin
  53016. * @param _useDeltaForWorldStep if the time between frames should be used when calculating physics steps (Default: true)
  53017. * @param ammoInjection can be used to inject your own ammo reference
  53018. */
  53019. constructor(_useDeltaForWorldStep?: boolean, ammoInjection?: any);
  53020. /**
  53021. * Sets the gravity of the physics world (m/(s^2))
  53022. * @param gravity Gravity to set
  53023. */
  53024. setGravity(gravity: Vector3): void;
  53025. /**
  53026. * Amount of time to step forward on each frame (only used if useDeltaForWorldStep is false in the constructor)
  53027. * @param timeStep timestep to use in seconds
  53028. */
  53029. setTimeStep(timeStep: number): void;
  53030. /**
  53031. * 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)
  53032. * @param fixedTimeStep fixedTimeStep to use in seconds
  53033. */
  53034. setFixedTimeStep(fixedTimeStep: number): void;
  53035. /**
  53036. * Sets the maximum number of steps by the physics engine per frame (Default: 5)
  53037. * @param maxSteps the maximum number of steps by the physics engine per frame
  53038. */
  53039. setMaxSteps(maxSteps: number): void;
  53040. /**
  53041. * Gets the current timestep (only used if useDeltaForWorldStep is false in the constructor)
  53042. * @returns the current timestep in seconds
  53043. */
  53044. getTimeStep(): number;
  53045. private _isImpostorInContact;
  53046. private _isImpostorPairInContact;
  53047. private _stepSimulation;
  53048. /**
  53049. * Moves the physics simulation forward delta seconds and updates the given physics imposters
  53050. * Prior to the step the imposters physics location is set to the position of the babylon meshes
  53051. * After the step the babylon meshes are set to the position of the physics imposters
  53052. * @param delta amount of time to step forward
  53053. * @param impostors array of imposters to update before/after the step
  53054. */
  53055. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  53056. /**
  53057. * Update babylon mesh to match physics world object
  53058. * @param impostor imposter to match
  53059. */
  53060. private _afterSoftStep;
  53061. /**
  53062. * Update babylon mesh vertices vertices to match physics world softbody or cloth
  53063. * @param impostor imposter to match
  53064. */
  53065. private _ropeStep;
  53066. /**
  53067. * Update babylon mesh vertices vertices to match physics world softbody or cloth
  53068. * @param impostor imposter to match
  53069. */
  53070. private _softbodyOrClothStep;
  53071. private _tmpVector;
  53072. private _tmpMatrix;
  53073. /**
  53074. * Applies an impulse on the imposter
  53075. * @param impostor imposter to apply impulse to
  53076. * @param force amount of force to be applied to the imposter
  53077. * @param contactPoint the location to apply the impulse on the imposter
  53078. */
  53079. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  53080. /**
  53081. * Applies a force on the imposter
  53082. * @param impostor imposter to apply force
  53083. * @param force amount of force to be applied to the imposter
  53084. * @param contactPoint the location to apply the force on the imposter
  53085. */
  53086. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  53087. /**
  53088. * Creates a physics body using the plugin
  53089. * @param impostor the imposter to create the physics body on
  53090. */
  53091. generatePhysicsBody(impostor: PhysicsImpostor): void;
  53092. /**
  53093. * Removes the physics body from the imposter and disposes of the body's memory
  53094. * @param impostor imposter to remove the physics body from
  53095. */
  53096. removePhysicsBody(impostor: PhysicsImpostor): void;
  53097. /**
  53098. * Generates a joint
  53099. * @param impostorJoint the imposter joint to create the joint with
  53100. */
  53101. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  53102. /**
  53103. * Removes a joint
  53104. * @param impostorJoint the imposter joint to remove the joint from
  53105. */
  53106. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  53107. private _addMeshVerts;
  53108. /**
  53109. * Initialise the soft body vertices to match its object's (mesh) vertices
  53110. * Softbody vertices (nodes) are in world space and to match this
  53111. * The object's position and rotation is set to zero and so its vertices are also then set in world space
  53112. * @param impostor to create the softbody for
  53113. */
  53114. private _softVertexData;
  53115. /**
  53116. * Create an impostor's soft body
  53117. * @param impostor to create the softbody for
  53118. */
  53119. private _createSoftbody;
  53120. /**
  53121. * Create cloth for an impostor
  53122. * @param impostor to create the softbody for
  53123. */
  53124. private _createCloth;
  53125. /**
  53126. * Create rope for an impostor
  53127. * @param impostor to create the softbody for
  53128. */
  53129. private _createRope;
  53130. private _addHullVerts;
  53131. private _createShape;
  53132. /**
  53133. * Sets the physics body position/rotation from the babylon mesh's position/rotation
  53134. * @param impostor imposter containing the physics body and babylon object
  53135. */
  53136. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  53137. /**
  53138. * Sets the babylon object's position/rotation from the physics body's position/rotation
  53139. * @param impostor imposter containing the physics body and babylon object
  53140. * @param newPosition new position
  53141. * @param newRotation new rotation
  53142. */
  53143. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  53144. /**
  53145. * If this plugin is supported
  53146. * @returns true if its supported
  53147. */
  53148. isSupported(): boolean;
  53149. /**
  53150. * Sets the linear velocity of the physics body
  53151. * @param impostor imposter to set the velocity on
  53152. * @param velocity velocity to set
  53153. */
  53154. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  53155. /**
  53156. * Sets the angular velocity of the physics body
  53157. * @param impostor imposter to set the velocity on
  53158. * @param velocity velocity to set
  53159. */
  53160. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  53161. /**
  53162. * gets the linear velocity
  53163. * @param impostor imposter to get linear velocity from
  53164. * @returns linear velocity
  53165. */
  53166. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  53167. /**
  53168. * gets the angular velocity
  53169. * @param impostor imposter to get angular velocity from
  53170. * @returns angular velocity
  53171. */
  53172. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  53173. /**
  53174. * Sets the mass of physics body
  53175. * @param impostor imposter to set the mass on
  53176. * @param mass mass to set
  53177. */
  53178. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  53179. /**
  53180. * Gets the mass of the physics body
  53181. * @param impostor imposter to get the mass from
  53182. * @returns mass
  53183. */
  53184. getBodyMass(impostor: PhysicsImpostor): number;
  53185. /**
  53186. * Gets friction of the impostor
  53187. * @param impostor impostor to get friction from
  53188. * @returns friction value
  53189. */
  53190. getBodyFriction(impostor: PhysicsImpostor): number;
  53191. /**
  53192. * Sets friction of the impostor
  53193. * @param impostor impostor to set friction on
  53194. * @param friction friction value
  53195. */
  53196. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  53197. /**
  53198. * Gets restitution of the impostor
  53199. * @param impostor impostor to get restitution from
  53200. * @returns restitution value
  53201. */
  53202. getBodyRestitution(impostor: PhysicsImpostor): number;
  53203. /**
  53204. * Sets resitution of the impostor
  53205. * @param impostor impostor to set resitution on
  53206. * @param restitution resitution value
  53207. */
  53208. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  53209. /**
  53210. * Gets pressure inside the impostor
  53211. * @param impostor impostor to get pressure from
  53212. * @returns pressure value
  53213. */
  53214. getBodyPressure(impostor: PhysicsImpostor): number;
  53215. /**
  53216. * Sets pressure inside a soft body impostor
  53217. * Cloth and rope must remain 0 pressure
  53218. * @param impostor impostor to set pressure on
  53219. * @param pressure pressure value
  53220. */
  53221. setBodyPressure(impostor: PhysicsImpostor, pressure: number): void;
  53222. /**
  53223. * Gets stiffness of the impostor
  53224. * @param impostor impostor to get stiffness from
  53225. * @returns pressure value
  53226. */
  53227. getBodyStiffness(impostor: PhysicsImpostor): number;
  53228. /**
  53229. * Sets stiffness of the impostor
  53230. * @param impostor impostor to set stiffness on
  53231. * @param stiffness stiffness value from 0 to 1
  53232. */
  53233. setBodyStiffness(impostor: PhysicsImpostor, stiffness: number): void;
  53234. /**
  53235. * Gets velocityIterations of the impostor
  53236. * @param impostor impostor to get velocity iterations from
  53237. * @returns velocityIterations value
  53238. */
  53239. getBodyVelocityIterations(impostor: PhysicsImpostor): number;
  53240. /**
  53241. * Sets velocityIterations of the impostor
  53242. * @param impostor impostor to set velocity iterations on
  53243. * @param velocityIterations velocityIterations value
  53244. */
  53245. setBodyVelocityIterations(impostor: PhysicsImpostor, velocityIterations: number): void;
  53246. /**
  53247. * Gets positionIterations of the impostor
  53248. * @param impostor impostor to get position iterations from
  53249. * @returns positionIterations value
  53250. */
  53251. getBodyPositionIterations(impostor: PhysicsImpostor): number;
  53252. /**
  53253. * Sets positionIterations of the impostor
  53254. * @param impostor impostor to set position on
  53255. * @param positionIterations positionIterations value
  53256. */
  53257. setBodyPositionIterations(impostor: PhysicsImpostor, positionIterations: number): void;
  53258. /**
  53259. * Append an anchor to a cloth object
  53260. * @param impostor is the cloth impostor to add anchor to
  53261. * @param otherImpostor is the rigid impostor to anchor to
  53262. * @param width ratio across width from 0 to 1
  53263. * @param height ratio up height from 0 to 1
  53264. * @param influence the elasticity between cloth impostor and anchor from 0, very stretchy to 1, little strech
  53265. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  53266. */
  53267. appendAnchor(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, width: number, height: number, influence?: number, noCollisionBetweenLinkedBodies?: boolean): void;
  53268. /**
  53269. * Append an hook to a rope object
  53270. * @param impostor is the rope impostor to add hook to
  53271. * @param otherImpostor is the rigid impostor to hook to
  53272. * @param length ratio along the rope from 0 to 1
  53273. * @param influence the elasticity between soft impostor and anchor from 0, very stretchy to 1, little strech
  53274. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  53275. */
  53276. appendHook(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, length: number, influence?: number, noCollisionBetweenLinkedBodies?: boolean): void;
  53277. /**
  53278. * Sleeps the physics body and stops it from being active
  53279. * @param impostor impostor to sleep
  53280. */
  53281. sleepBody(impostor: PhysicsImpostor): void;
  53282. /**
  53283. * Activates the physics body
  53284. * @param impostor impostor to activate
  53285. */
  53286. wakeUpBody(impostor: PhysicsImpostor): void;
  53287. /**
  53288. * Updates the distance parameters of the joint
  53289. * @param joint joint to update
  53290. * @param maxDistance maximum distance of the joint
  53291. * @param minDistance minimum distance of the joint
  53292. */
  53293. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  53294. /**
  53295. * Sets a motor on the joint
  53296. * @param joint joint to set motor on
  53297. * @param speed speed of the motor
  53298. * @param maxForce maximum force of the motor
  53299. * @param motorIndex index of the motor
  53300. */
  53301. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  53302. /**
  53303. * Sets the motors limit
  53304. * @param joint joint to set limit on
  53305. * @param upperLimit upper limit
  53306. * @param lowerLimit lower limit
  53307. */
  53308. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  53309. /**
  53310. * Syncs the position and rotation of a mesh with the impostor
  53311. * @param mesh mesh to sync
  53312. * @param impostor impostor to update the mesh with
  53313. */
  53314. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  53315. /**
  53316. * Gets the radius of the impostor
  53317. * @param impostor impostor to get radius from
  53318. * @returns the radius
  53319. */
  53320. getRadius(impostor: PhysicsImpostor): number;
  53321. /**
  53322. * Gets the box size of the impostor
  53323. * @param impostor impostor to get box size from
  53324. * @param result the resulting box size
  53325. */
  53326. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  53327. /**
  53328. * Disposes of the impostor
  53329. */
  53330. dispose(): void;
  53331. /**
  53332. * Does a raycast in the physics world
  53333. * @param from when should the ray start?
  53334. * @param to when should the ray end?
  53335. * @returns PhysicsRaycastResult
  53336. */
  53337. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  53338. }
  53339. }
  53340. declare module "babylonjs/Physics/Plugins/index" {
  53341. export * from "babylonjs/Physics/Plugins/cannonJSPlugin";
  53342. export * from "babylonjs/Physics/Plugins/ammoJSPlugin";
  53343. export * from "babylonjs/Physics/Plugins/oimoJSPlugin";
  53344. }
  53345. declare module "babylonjs/Physics/index" {
  53346. export * from "babylonjs/Physics/IPhysicsEngine";
  53347. export * from "babylonjs/Physics/physicsEngine";
  53348. export * from "babylonjs/Physics/physicsEngineComponent";
  53349. export * from "babylonjs/Physics/physicsHelper";
  53350. export * from "babylonjs/Physics/physicsImpostor";
  53351. export * from "babylonjs/Physics/physicsJoint";
  53352. export * from "babylonjs/Physics/Plugins/index";
  53353. }
  53354. declare module "babylonjs/Shaders/blackAndWhite.fragment" {
  53355. /** @hidden */
  53356. export var blackAndWhitePixelShader: {
  53357. name: string;
  53358. shader: string;
  53359. };
  53360. }
  53361. declare module "babylonjs/PostProcesses/blackAndWhitePostProcess" {
  53362. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  53363. import { Camera } from "babylonjs/Cameras/camera";
  53364. import { Engine } from "babylonjs/Engines/engine";
  53365. import "babylonjs/Shaders/blackAndWhite.fragment";
  53366. /**
  53367. * Post process used to render in black and white
  53368. */
  53369. export class BlackAndWhitePostProcess extends PostProcess {
  53370. /**
  53371. * Linear about to convert he result to black and white (default: 1)
  53372. */
  53373. degree: number;
  53374. /**
  53375. * Creates a black and white post process
  53376. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#black-and-white
  53377. * @param name The name of the effect.
  53378. * @param options The required width/height ratio to downsize to before computing the render pass.
  53379. * @param camera The camera to apply the render pass to.
  53380. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  53381. * @param engine The engine which the post process will be applied. (default: current engine)
  53382. * @param reusable If the post process can be reused on the same frame. (default: false)
  53383. */
  53384. constructor(name: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  53385. }
  53386. }
  53387. declare module "babylonjs/PostProcesses/RenderPipeline/postProcessRenderEffect" {
  53388. import { Nullable } from "babylonjs/types";
  53389. import { Camera } from "babylonjs/Cameras/camera";
  53390. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  53391. import { Engine } from "babylonjs/Engines/engine";
  53392. /**
  53393. * This represents a set of one or more post processes in Babylon.
  53394. * A post process can be used to apply a shader to a texture after it is rendered.
  53395. * @example https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  53396. */
  53397. export class PostProcessRenderEffect {
  53398. private _postProcesses;
  53399. private _getPostProcesses;
  53400. private _singleInstance;
  53401. private _cameras;
  53402. private _indicesForCamera;
  53403. /**
  53404. * Name of the effect
  53405. * @hidden
  53406. */
  53407. _name: string;
  53408. /**
  53409. * Instantiates a post process render effect.
  53410. * A post process can be used to apply a shader to a texture after it is rendered.
  53411. * @param engine The engine the effect is tied to
  53412. * @param name The name of the effect
  53413. * @param getPostProcesses A function that returns a set of post processes which the effect will run in order to be run.
  53414. * @param singleInstance False if this post process can be run on multiple cameras. (default: true)
  53415. */
  53416. constructor(engine: Engine, name: string, getPostProcesses: () => Nullable<PostProcess | Array<PostProcess>>, singleInstance?: boolean);
  53417. /**
  53418. * Checks if all the post processes in the effect are supported.
  53419. */
  53420. readonly isSupported: boolean;
  53421. /**
  53422. * Updates the current state of the effect
  53423. * @hidden
  53424. */
  53425. _update(): void;
  53426. /**
  53427. * Attaches the effect on cameras
  53428. * @param cameras The camera to attach to.
  53429. * @hidden
  53430. */
  53431. _attachCameras(cameras: Camera): void;
  53432. /**
  53433. * Attaches the effect on cameras
  53434. * @param cameras The camera to attach to.
  53435. * @hidden
  53436. */
  53437. _attachCameras(cameras: Camera[]): void;
  53438. /**
  53439. * Detatches the effect on cameras
  53440. * @param cameras The camera to detatch from.
  53441. * @hidden
  53442. */
  53443. _detachCameras(cameras: Camera): void;
  53444. /**
  53445. * Detatches the effect on cameras
  53446. * @param cameras The camera to detatch from.
  53447. * @hidden
  53448. */
  53449. _detachCameras(cameras: Camera[]): void;
  53450. /**
  53451. * Enables the effect on given cameras
  53452. * @param cameras The camera to enable.
  53453. * @hidden
  53454. */
  53455. _enable(cameras: Camera): void;
  53456. /**
  53457. * Enables the effect on given cameras
  53458. * @param cameras The camera to enable.
  53459. * @hidden
  53460. */
  53461. _enable(cameras: Nullable<Camera[]>): void;
  53462. /**
  53463. * Disables the effect on the given cameras
  53464. * @param cameras The camera to disable.
  53465. * @hidden
  53466. */
  53467. _disable(cameras: Camera): void;
  53468. /**
  53469. * Disables the effect on the given cameras
  53470. * @param cameras The camera to disable.
  53471. * @hidden
  53472. */
  53473. _disable(cameras: Nullable<Camera[]>): void;
  53474. /**
  53475. * Gets a list of the post processes contained in the effect.
  53476. * @param camera The camera to get the post processes on.
  53477. * @returns The list of the post processes in the effect.
  53478. */
  53479. getPostProcesses(camera?: Camera): Nullable<Array<PostProcess>>;
  53480. }
  53481. }
  53482. declare module "babylonjs/Shaders/extractHighlights.fragment" {
  53483. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  53484. /** @hidden */
  53485. export var extractHighlightsPixelShader: {
  53486. name: string;
  53487. shader: string;
  53488. };
  53489. }
  53490. declare module "babylonjs/PostProcesses/extractHighlightsPostProcess" {
  53491. import { Nullable } from "babylonjs/types";
  53492. import { Camera } from "babylonjs/Cameras/camera";
  53493. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  53494. import { Engine } from "babylonjs/Engines/engine";
  53495. import "babylonjs/Shaders/extractHighlights.fragment";
  53496. /**
  53497. * 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.
  53498. */
  53499. export class ExtractHighlightsPostProcess extends PostProcess {
  53500. /**
  53501. * The luminance threshold, pixels below this value will be set to black.
  53502. */
  53503. threshold: number;
  53504. /** @hidden */
  53505. _exposure: number;
  53506. /**
  53507. * Post process which has the input texture to be used when performing highlight extraction
  53508. * @hidden
  53509. */
  53510. _inputPostProcess: Nullable<PostProcess>;
  53511. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  53512. }
  53513. }
  53514. declare module "babylonjs/Shaders/bloomMerge.fragment" {
  53515. /** @hidden */
  53516. export var bloomMergePixelShader: {
  53517. name: string;
  53518. shader: string;
  53519. };
  53520. }
  53521. declare module "babylonjs/PostProcesses/bloomMergePostProcess" {
  53522. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  53523. import { Nullable } from "babylonjs/types";
  53524. import { Engine } from "babylonjs/Engines/engine";
  53525. import { Camera } from "babylonjs/Cameras/camera";
  53526. import "babylonjs/Shaders/bloomMerge.fragment";
  53527. /**
  53528. * The BloomMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  53529. */
  53530. export class BloomMergePostProcess extends PostProcess {
  53531. /** Weight of the bloom to be added to the original input. */
  53532. weight: number;
  53533. /**
  53534. * Creates a new instance of @see BloomMergePostProcess
  53535. * @param name The name of the effect.
  53536. * @param originalFromInput Post process which's input will be used for the merge.
  53537. * @param blurred Blurred highlights post process which's output will be used.
  53538. * @param weight Weight of the bloom to be added to the original input.
  53539. * @param options The required width/height ratio to downsize to before computing the render pass.
  53540. * @param camera The camera to apply the render pass to.
  53541. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  53542. * @param engine The engine which the post process will be applied. (default: current engine)
  53543. * @param reusable If the post process can be reused on the same frame. (default: false)
  53544. * @param textureType Type of textures used when performing the post process. (default: 0)
  53545. * @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)
  53546. */
  53547. constructor(name: string, originalFromInput: PostProcess, blurred: PostProcess,
  53548. /** Weight of the bloom to be added to the original input. */
  53549. weight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  53550. }
  53551. }
  53552. declare module "babylonjs/PostProcesses/bloomEffect" {
  53553. import { PostProcessRenderEffect } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderEffect";
  53554. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  53555. import { ExtractHighlightsPostProcess } from "babylonjs/PostProcesses/extractHighlightsPostProcess";
  53556. import { Camera } from "babylonjs/Cameras/camera";
  53557. import { Scene } from "babylonjs/scene";
  53558. /**
  53559. * The bloom effect spreads bright areas of an image to simulate artifacts seen in cameras
  53560. */
  53561. export class BloomEffect extends PostProcessRenderEffect {
  53562. private bloomScale;
  53563. /**
  53564. * @hidden Internal
  53565. */
  53566. _effects: Array<PostProcess>;
  53567. /**
  53568. * @hidden Internal
  53569. */
  53570. _downscale: ExtractHighlightsPostProcess;
  53571. private _blurX;
  53572. private _blurY;
  53573. private _merge;
  53574. /**
  53575. * The luminance threshold to find bright areas of the image to bloom.
  53576. */
  53577. threshold: number;
  53578. /**
  53579. * The strength of the bloom.
  53580. */
  53581. weight: number;
  53582. /**
  53583. * Specifies the size of the bloom blur kernel, relative to the final output size
  53584. */
  53585. kernel: number;
  53586. /**
  53587. * Creates a new instance of @see BloomEffect
  53588. * @param scene The scene the effect belongs to.
  53589. * @param bloomScale The ratio of the blur texture to the input texture that should be used to compute the bloom.
  53590. * @param bloomKernel The size of the kernel to be used when applying the blur.
  53591. * @param bloomWeight The the strength of bloom.
  53592. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  53593. * @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)
  53594. */
  53595. constructor(scene: Scene, bloomScale: number, bloomWeight: number, bloomKernel: number, pipelineTextureType?: number, blockCompilation?: boolean);
  53596. /**
  53597. * Disposes each of the internal effects for a given camera.
  53598. * @param camera The camera to dispose the effect on.
  53599. */
  53600. disposeEffects(camera: Camera): void;
  53601. /**
  53602. * @hidden Internal
  53603. */
  53604. _updateEffects(): void;
  53605. /**
  53606. * Internal
  53607. * @returns if all the contained post processes are ready.
  53608. * @hidden
  53609. */
  53610. _isReady(): boolean;
  53611. }
  53612. }
  53613. declare module "babylonjs/Shaders/chromaticAberration.fragment" {
  53614. /** @hidden */
  53615. export var chromaticAberrationPixelShader: {
  53616. name: string;
  53617. shader: string;
  53618. };
  53619. }
  53620. declare module "babylonjs/PostProcesses/chromaticAberrationPostProcess" {
  53621. import { Vector2 } from "babylonjs/Maths/math";
  53622. import { Nullable } from "babylonjs/types";
  53623. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  53624. import { Camera } from "babylonjs/Cameras/camera";
  53625. import { Engine } from "babylonjs/Engines/engine";
  53626. import "babylonjs/Shaders/chromaticAberration.fragment";
  53627. /**
  53628. * The ChromaticAberrationPostProcess separates the rgb channels in an image to produce chromatic distortion around the edges of the screen
  53629. */
  53630. export class ChromaticAberrationPostProcess extends PostProcess {
  53631. /**
  53632. * The amount of seperation of rgb channels (default: 30)
  53633. */
  53634. aberrationAmount: number;
  53635. /**
  53636. * The amount the effect will increase for pixels closer to the edge of the screen. (default: 0)
  53637. */
  53638. radialIntensity: number;
  53639. /**
  53640. * 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))
  53641. */
  53642. direction: Vector2;
  53643. /**
  53644. * 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))
  53645. */
  53646. centerPosition: Vector2;
  53647. /**
  53648. * Creates a new instance ChromaticAberrationPostProcess
  53649. * @param name The name of the effect.
  53650. * @param screenWidth The width of the screen to apply the effect on.
  53651. * @param screenHeight The height of the screen to apply the effect on.
  53652. * @param options The required width/height ratio to downsize to before computing the render pass.
  53653. * @param camera The camera to apply the render pass to.
  53654. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  53655. * @param engine The engine which the post process will be applied. (default: current engine)
  53656. * @param reusable If the post process can be reused on the same frame. (default: false)
  53657. * @param textureType Type of textures used when performing the post process. (default: 0)
  53658. * @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)
  53659. */
  53660. constructor(name: string, screenWidth: number, screenHeight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  53661. }
  53662. }
  53663. declare module "babylonjs/Shaders/circleOfConfusion.fragment" {
  53664. /** @hidden */
  53665. export var circleOfConfusionPixelShader: {
  53666. name: string;
  53667. shader: string;
  53668. };
  53669. }
  53670. declare module "babylonjs/PostProcesses/circleOfConfusionPostProcess" {
  53671. import { Nullable } from "babylonjs/types";
  53672. import { Engine } from "babylonjs/Engines/engine";
  53673. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  53674. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  53675. import { Camera } from "babylonjs/Cameras/camera";
  53676. import "babylonjs/Shaders/circleOfConfusion.fragment";
  53677. /**
  53678. * The CircleOfConfusionPostProcess computes the circle of confusion value for each pixel given required lens parameters. See https://en.wikipedia.org/wiki/Circle_of_confusion
  53679. */
  53680. export class CircleOfConfusionPostProcess extends PostProcess {
  53681. /**
  53682. * 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.
  53683. */
  53684. lensSize: number;
  53685. /**
  53686. * F-Stop of the effect's camera. The diamater of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  53687. */
  53688. fStop: number;
  53689. /**
  53690. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  53691. */
  53692. focusDistance: number;
  53693. /**
  53694. * Focal length of the effect's camera in scene units/1000 (eg. millimeter). (default: 50)
  53695. */
  53696. focalLength: number;
  53697. private _depthTexture;
  53698. /**
  53699. * Creates a new instance CircleOfConfusionPostProcess
  53700. * @param name The name of the effect.
  53701. * @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.
  53702. * @param options The required width/height ratio to downsize to before computing the render pass.
  53703. * @param camera The camera to apply the render pass to.
  53704. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  53705. * @param engine The engine which the post process will be applied. (default: current engine)
  53706. * @param reusable If the post process can be reused on the same frame. (default: false)
  53707. * @param textureType Type of textures used when performing the post process. (default: 0)
  53708. * @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)
  53709. */
  53710. constructor(name: string, depthTexture: Nullable<RenderTargetTexture>, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  53711. /**
  53712. * 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.
  53713. */
  53714. depthTexture: RenderTargetTexture;
  53715. }
  53716. }
  53717. declare module "babylonjs/Shaders/colorCorrection.fragment" {
  53718. /** @hidden */
  53719. export var colorCorrectionPixelShader: {
  53720. name: string;
  53721. shader: string;
  53722. };
  53723. }
  53724. declare module "babylonjs/PostProcesses/colorCorrectionPostProcess" {
  53725. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  53726. import { Engine } from "babylonjs/Engines/engine";
  53727. import { Camera } from "babylonjs/Cameras/camera";
  53728. import "babylonjs/Shaders/colorCorrection.fragment";
  53729. /**
  53730. *
  53731. * This post-process allows the modification of rendered colors by using
  53732. * a 'look-up table' (LUT). This effect is also called Color Grading.
  53733. *
  53734. * The object needs to be provided an url to a texture containing the color
  53735. * look-up table: the texture must be 256 pixels wide and 16 pixels high.
  53736. * Use an image editing software to tweak the LUT to match your needs.
  53737. *
  53738. * For an example of a color LUT, see here:
  53739. * @see http://udn.epicgames.com/Three/rsrc/Three/ColorGrading/RGBTable16x1.png
  53740. * For explanations on color grading, see here:
  53741. * @see http://udn.epicgames.com/Three/ColorGrading.html
  53742. *
  53743. */
  53744. export class ColorCorrectionPostProcess extends PostProcess {
  53745. private _colorTableTexture;
  53746. constructor(name: string, colorTableUrl: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  53747. }
  53748. }
  53749. declare module "babylonjs/Shaders/convolution.fragment" {
  53750. /** @hidden */
  53751. export var convolutionPixelShader: {
  53752. name: string;
  53753. shader: string;
  53754. };
  53755. }
  53756. declare module "babylonjs/PostProcesses/convolutionPostProcess" {
  53757. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  53758. import { Nullable } from "babylonjs/types";
  53759. import { Camera } from "babylonjs/Cameras/camera";
  53760. import { Engine } from "babylonjs/Engines/engine";
  53761. import "babylonjs/Shaders/convolution.fragment";
  53762. /**
  53763. * The ConvolutionPostProcess applies a 3x3 kernel to every pixel of the
  53764. * input texture to perform effects such as edge detection or sharpening
  53765. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  53766. */
  53767. export class ConvolutionPostProcess extends PostProcess {
  53768. /** Array of 9 values corrisponding to the 3x3 kernel to be applied */
  53769. kernel: number[];
  53770. /**
  53771. * Creates a new instance ConvolutionPostProcess
  53772. * @param name The name of the effect.
  53773. * @param kernel Array of 9 values corrisponding to the 3x3 kernel to be applied
  53774. * @param options The required width/height ratio to downsize to before computing the render pass.
  53775. * @param camera The camera to apply the render pass to.
  53776. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  53777. * @param engine The engine which the post process will be applied. (default: current engine)
  53778. * @param reusable If the post process can be reused on the same frame. (default: false)
  53779. * @param textureType Type of textures used when performing the post process. (default: 0)
  53780. */
  53781. constructor(name: string,
  53782. /** Array of 9 values corrisponding to the 3x3 kernel to be applied */
  53783. kernel: number[], options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  53784. /**
  53785. * Edge detection 0 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  53786. */
  53787. static EdgeDetect0Kernel: number[];
  53788. /**
  53789. * Edge detection 1 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  53790. */
  53791. static EdgeDetect1Kernel: number[];
  53792. /**
  53793. * Edge detection 2 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  53794. */
  53795. static EdgeDetect2Kernel: number[];
  53796. /**
  53797. * Kernel to sharpen an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  53798. */
  53799. static SharpenKernel: number[];
  53800. /**
  53801. * Kernel to emboss an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  53802. */
  53803. static EmbossKernel: number[];
  53804. /**
  53805. * Kernel to blur an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  53806. */
  53807. static GaussianKernel: number[];
  53808. }
  53809. }
  53810. declare module "babylonjs/PostProcesses/depthOfFieldBlurPostProcess" {
  53811. import { Nullable } from "babylonjs/types";
  53812. import { Vector2 } from "babylonjs/Maths/math";
  53813. import { Camera } from "babylonjs/Cameras/camera";
  53814. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  53815. import { BlurPostProcess } from "babylonjs/PostProcesses/blurPostProcess";
  53816. import { Engine } from "babylonjs/Engines/engine";
  53817. import { Scene } from "babylonjs/scene";
  53818. /**
  53819. * The DepthOfFieldBlurPostProcess applied a blur in a give direction.
  53820. * This blur differs from the standard BlurPostProcess as it attempts to avoid blurring pixels
  53821. * based on samples that have a large difference in distance than the center pixel.
  53822. * See section 2.6.2 http://fileadmin.cs.lth.se/cs/education/edan35/lectures/12dof.pdf
  53823. */
  53824. export class DepthOfFieldBlurPostProcess extends BlurPostProcess {
  53825. direction: Vector2;
  53826. /**
  53827. * Creates a new instance CircleOfConfusionPostProcess
  53828. * @param name The name of the effect.
  53829. * @param scene The scene the effect belongs to.
  53830. * @param direction The direction the blur should be applied.
  53831. * @param kernel The size of the kernel used to blur.
  53832. * @param options The required width/height ratio to downsize to before computing the render pass.
  53833. * @param camera The camera to apply the render pass to.
  53834. * @param circleOfConfusion The circle of confusion + depth map to be used to avoid blurring accross edges
  53835. * @param imageToBlur The image to apply the blur to (default: Current rendered frame)
  53836. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  53837. * @param engine The engine which the post process will be applied. (default: current engine)
  53838. * @param reusable If the post process can be reused on the same frame. (default: false)
  53839. * @param textureType Type of textures used when performing the post process. (default: 0)
  53840. * @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)
  53841. */
  53842. 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);
  53843. }
  53844. }
  53845. declare module "babylonjs/Shaders/depthOfFieldMerge.fragment" {
  53846. /** @hidden */
  53847. export var depthOfFieldMergePixelShader: {
  53848. name: string;
  53849. shader: string;
  53850. };
  53851. }
  53852. declare module "babylonjs/PostProcesses/depthOfFieldMergePostProcess" {
  53853. import { Nullable } from "babylonjs/types";
  53854. import { Camera } from "babylonjs/Cameras/camera";
  53855. import { Effect } from "babylonjs/Materials/effect";
  53856. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  53857. import { Engine } from "babylonjs/Engines/engine";
  53858. import "babylonjs/Shaders/depthOfFieldMerge.fragment";
  53859. /**
  53860. * Options to be set when merging outputs from the default pipeline.
  53861. */
  53862. export class DepthOfFieldMergePostProcessOptions {
  53863. /**
  53864. * The original image to merge on top of
  53865. */
  53866. originalFromInput: PostProcess;
  53867. /**
  53868. * Parameters to perform the merge of the depth of field effect
  53869. */
  53870. depthOfField?: {
  53871. circleOfConfusion: PostProcess;
  53872. blurSteps: Array<PostProcess>;
  53873. };
  53874. /**
  53875. * Parameters to perform the merge of bloom effect
  53876. */
  53877. bloom?: {
  53878. blurred: PostProcess;
  53879. weight: number;
  53880. };
  53881. }
  53882. /**
  53883. * The DepthOfFieldMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  53884. */
  53885. export class DepthOfFieldMergePostProcess extends PostProcess {
  53886. private blurSteps;
  53887. /**
  53888. * Creates a new instance of DepthOfFieldMergePostProcess
  53889. * @param name The name of the effect.
  53890. * @param originalFromInput Post process which's input will be used for the merge.
  53891. * @param circleOfConfusion Circle of confusion post process which's output will be used to blur each pixel.
  53892. * @param blurSteps Blur post processes from low to high which will be mixed with the original image.
  53893. * @param options The required width/height ratio to downsize to before computing the render pass.
  53894. * @param camera The camera to apply the render pass to.
  53895. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  53896. * @param engine The engine which the post process will be applied. (default: current engine)
  53897. * @param reusable If the post process can be reused on the same frame. (default: false)
  53898. * @param textureType Type of textures used when performing the post process. (default: 0)
  53899. * @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)
  53900. */
  53901. 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);
  53902. /**
  53903. * Updates the effect with the current post process compile time values and recompiles the shader.
  53904. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  53905. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  53906. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  53907. * @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
  53908. * @param onCompiled Called when the shader has been compiled.
  53909. * @param onError Called if there is an error when compiling a shader.
  53910. */
  53911. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  53912. }
  53913. }
  53914. declare module "babylonjs/PostProcesses/depthOfFieldEffect" {
  53915. import { Nullable } from "babylonjs/types";
  53916. import { Camera } from "babylonjs/Cameras/camera";
  53917. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  53918. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  53919. import { PostProcessRenderEffect } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderEffect";
  53920. import { DepthOfFieldBlurPostProcess } from "babylonjs/PostProcesses/depthOfFieldBlurPostProcess";
  53921. import { Scene } from "babylonjs/scene";
  53922. /**
  53923. * Specifies the level of max blur that should be applied when using the depth of field effect
  53924. */
  53925. export enum DepthOfFieldEffectBlurLevel {
  53926. /**
  53927. * Subtle blur
  53928. */
  53929. Low = 0,
  53930. /**
  53931. * Medium blur
  53932. */
  53933. Medium = 1,
  53934. /**
  53935. * Large blur
  53936. */
  53937. High = 2
  53938. }
  53939. /**
  53940. * The depth of field effect applies a blur to objects that are closer or further from where the camera is focusing.
  53941. */
  53942. export class DepthOfFieldEffect extends PostProcessRenderEffect {
  53943. private _circleOfConfusion;
  53944. /**
  53945. * @hidden Internal, blurs from high to low
  53946. */
  53947. _depthOfFieldBlurX: Array<DepthOfFieldBlurPostProcess>;
  53948. private _depthOfFieldBlurY;
  53949. private _dofMerge;
  53950. /**
  53951. * @hidden Internal post processes in depth of field effect
  53952. */
  53953. _effects: Array<PostProcess>;
  53954. /**
  53955. * The focal the length of the camera used in the effect in scene units/1000 (eg. millimeter)
  53956. */
  53957. focalLength: number;
  53958. /**
  53959. * F-Stop of the effect's camera. The diameter of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  53960. */
  53961. fStop: number;
  53962. /**
  53963. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  53964. */
  53965. focusDistance: number;
  53966. /**
  53967. * 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.
  53968. */
  53969. lensSize: number;
  53970. /**
  53971. * Creates a new instance DepthOfFieldEffect
  53972. * @param scene The scene the effect belongs to.
  53973. * @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.
  53974. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  53975. * @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)
  53976. */
  53977. constructor(scene: Scene, depthTexture: Nullable<RenderTargetTexture>, blurLevel?: DepthOfFieldEffectBlurLevel, pipelineTextureType?: number, blockCompilation?: boolean);
  53978. /**
  53979. * 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.
  53980. */
  53981. depthTexture: RenderTargetTexture;
  53982. /**
  53983. * Disposes each of the internal effects for a given camera.
  53984. * @param camera The camera to dispose the effect on.
  53985. */
  53986. disposeEffects(camera: Camera): void;
  53987. /**
  53988. * @hidden Internal
  53989. */
  53990. _updateEffects(): void;
  53991. /**
  53992. * Internal
  53993. * @returns if all the contained post processes are ready.
  53994. * @hidden
  53995. */
  53996. _isReady(): boolean;
  53997. }
  53998. }
  53999. declare module "babylonjs/Shaders/displayPass.fragment" {
  54000. /** @hidden */
  54001. export var displayPassPixelShader: {
  54002. name: string;
  54003. shader: string;
  54004. };
  54005. }
  54006. declare module "babylonjs/PostProcesses/displayPassPostProcess" {
  54007. import { Nullable } from "babylonjs/types";
  54008. import { Camera } from "babylonjs/Cameras/camera";
  54009. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  54010. import { Engine } from "babylonjs/Engines/engine";
  54011. import "babylonjs/Shaders/displayPass.fragment";
  54012. /**
  54013. * DisplayPassPostProcess which produces an output the same as it's input
  54014. */
  54015. export class DisplayPassPostProcess extends PostProcess {
  54016. /**
  54017. * Creates the DisplayPassPostProcess
  54018. * @param name The name of the effect.
  54019. * @param options The required width/height ratio to downsize to before computing the render pass.
  54020. * @param camera The camera to apply the render pass to.
  54021. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  54022. * @param engine The engine which the post process will be applied. (default: current engine)
  54023. * @param reusable If the post process can be reused on the same frame. (default: false)
  54024. */
  54025. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  54026. }
  54027. }
  54028. declare module "babylonjs/Shaders/filter.fragment" {
  54029. /** @hidden */
  54030. export var filterPixelShader: {
  54031. name: string;
  54032. shader: string;
  54033. };
  54034. }
  54035. declare module "babylonjs/PostProcesses/filterPostProcess" {
  54036. import { Nullable } from "babylonjs/types";
  54037. import { Matrix } from "babylonjs/Maths/math";
  54038. import { Camera } from "babylonjs/Cameras/camera";
  54039. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  54040. import { Engine } from "babylonjs/Engines/engine";
  54041. import "babylonjs/Shaders/filter.fragment";
  54042. /**
  54043. * Applies a kernel filter to the image
  54044. */
  54045. export class FilterPostProcess extends PostProcess {
  54046. /** The matrix to be applied to the image */
  54047. kernelMatrix: Matrix;
  54048. /**
  54049. *
  54050. * @param name The name of the effect.
  54051. * @param kernelMatrix The matrix to be applied to the image
  54052. * @param options The required width/height ratio to downsize to before computing the render pass.
  54053. * @param camera The camera to apply the render pass to.
  54054. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  54055. * @param engine The engine which the post process will be applied. (default: current engine)
  54056. * @param reusable If the post process can be reused on the same frame. (default: false)
  54057. */
  54058. constructor(name: string,
  54059. /** The matrix to be applied to the image */
  54060. kernelMatrix: Matrix, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  54061. }
  54062. }
  54063. declare module "babylonjs/Shaders/fxaa.fragment" {
  54064. /** @hidden */
  54065. export var fxaaPixelShader: {
  54066. name: string;
  54067. shader: string;
  54068. };
  54069. }
  54070. declare module "babylonjs/Shaders/fxaa.vertex" {
  54071. /** @hidden */
  54072. export var fxaaVertexShader: {
  54073. name: string;
  54074. shader: string;
  54075. };
  54076. }
  54077. declare module "babylonjs/PostProcesses/fxaaPostProcess" {
  54078. import { Nullable } from "babylonjs/types";
  54079. import { Camera } from "babylonjs/Cameras/camera";
  54080. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  54081. import { Engine } from "babylonjs/Engines/engine";
  54082. import "babylonjs/Shaders/fxaa.fragment";
  54083. import "babylonjs/Shaders/fxaa.vertex";
  54084. /**
  54085. * Fxaa post process
  54086. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#fxaa
  54087. */
  54088. export class FxaaPostProcess extends PostProcess {
  54089. /** @hidden */
  54090. texelWidth: number;
  54091. /** @hidden */
  54092. texelHeight: number;
  54093. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  54094. private _getDefines;
  54095. }
  54096. }
  54097. declare module "babylonjs/Shaders/grain.fragment" {
  54098. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  54099. /** @hidden */
  54100. export var grainPixelShader: {
  54101. name: string;
  54102. shader: string;
  54103. };
  54104. }
  54105. declare module "babylonjs/PostProcesses/grainPostProcess" {
  54106. import { Nullable } from "babylonjs/types";
  54107. import { Camera } from "babylonjs/Cameras/camera";
  54108. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  54109. import { Engine } from "babylonjs/Engines/engine";
  54110. import "babylonjs/Shaders/grain.fragment";
  54111. /**
  54112. * The GrainPostProcess adds noise to the image at mid luminance levels
  54113. */
  54114. export class GrainPostProcess extends PostProcess {
  54115. /**
  54116. * The intensity of the grain added (default: 30)
  54117. */
  54118. intensity: number;
  54119. /**
  54120. * If the grain should be randomized on every frame
  54121. */
  54122. animated: boolean;
  54123. /**
  54124. * Creates a new instance of @see GrainPostProcess
  54125. * @param name The name of the effect.
  54126. * @param options The required width/height ratio to downsize to before computing the render pass.
  54127. * @param camera The camera to apply the render pass to.
  54128. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  54129. * @param engine The engine which the post process will be applied. (default: current engine)
  54130. * @param reusable If the post process can be reused on the same frame. (default: false)
  54131. * @param textureType Type of textures used when performing the post process. (default: 0)
  54132. * @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)
  54133. */
  54134. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  54135. }
  54136. }
  54137. declare module "babylonjs/Shaders/highlights.fragment" {
  54138. /** @hidden */
  54139. export var highlightsPixelShader: {
  54140. name: string;
  54141. shader: string;
  54142. };
  54143. }
  54144. declare module "babylonjs/PostProcesses/highlightsPostProcess" {
  54145. import { Nullable } from "babylonjs/types";
  54146. import { Camera } from "babylonjs/Cameras/camera";
  54147. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  54148. import { Engine } from "babylonjs/Engines/engine";
  54149. import "babylonjs/Shaders/highlights.fragment";
  54150. /**
  54151. * Extracts highlights from the image
  54152. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  54153. */
  54154. export class HighlightsPostProcess extends PostProcess {
  54155. /**
  54156. * Extracts highlights from the image
  54157. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  54158. * @param name The name of the effect.
  54159. * @param options The required width/height ratio to downsize to before computing the render pass.
  54160. * @param camera The camera to apply the render pass to.
  54161. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  54162. * @param engine The engine which the post process will be applied. (default: current engine)
  54163. * @param reusable If the post process can be reused on the same frame. (default: false)
  54164. * @param textureType Type of texture for the post process (default: Engine.TEXTURETYPE_UNSIGNED_INT)
  54165. */
  54166. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  54167. }
  54168. }
  54169. declare module "babylonjs/Shaders/ShadersInclude/mrtFragmentDeclaration" {
  54170. /** @hidden */
  54171. export var mrtFragmentDeclaration: {
  54172. name: string;
  54173. shader: string;
  54174. };
  54175. }
  54176. declare module "babylonjs/Shaders/geometry.fragment" {
  54177. import "babylonjs/Shaders/ShadersInclude/mrtFragmentDeclaration";
  54178. /** @hidden */
  54179. export var geometryPixelShader: {
  54180. name: string;
  54181. shader: string;
  54182. };
  54183. }
  54184. declare module "babylonjs/Shaders/geometry.vertex" {
  54185. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  54186. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  54187. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  54188. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  54189. /** @hidden */
  54190. export var geometryVertexShader: {
  54191. name: string;
  54192. shader: string;
  54193. };
  54194. }
  54195. declare module "babylonjs/Rendering/geometryBufferRenderer" {
  54196. import { Matrix } from "babylonjs/Maths/math";
  54197. import { SubMesh } from "babylonjs/Meshes/subMesh";
  54198. import { Mesh } from "babylonjs/Meshes/mesh";
  54199. import { MultiRenderTarget } from "babylonjs/Materials/Textures/multiRenderTarget";
  54200. import { Effect } from "babylonjs/Materials/effect";
  54201. import { Scene } from "babylonjs/scene";
  54202. import "babylonjs/Shaders/geometry.fragment";
  54203. import "babylonjs/Shaders/geometry.vertex";
  54204. /**
  54205. * This renderer is helpfull to fill one of the render target with a geometry buffer.
  54206. */
  54207. export class GeometryBufferRenderer {
  54208. /**
  54209. * Constant used to retrieve the position texture index in the G-Buffer textures array
  54210. * using getIndex(GeometryBufferRenderer.POSITION_TEXTURE_INDEX)
  54211. */
  54212. static readonly POSITION_TEXTURE_TYPE: number;
  54213. /**
  54214. * Constant used to retrieve the velocity texture index in the G-Buffer textures array
  54215. * using getIndex(GeometryBufferRenderer.VELOCITY_TEXTURE_INDEX)
  54216. */
  54217. static readonly VELOCITY_TEXTURE_TYPE: number;
  54218. /**
  54219. * Dictionary used to store the previous transformation matrices of each rendered mesh
  54220. * in order to compute objects velocities when enableVelocity is set to "true"
  54221. * @hidden
  54222. */
  54223. _previousTransformationMatrices: {
  54224. [index: number]: Matrix;
  54225. };
  54226. private _scene;
  54227. private _multiRenderTarget;
  54228. private _ratio;
  54229. private _enablePosition;
  54230. private _enableVelocity;
  54231. private _positionIndex;
  54232. private _velocityIndex;
  54233. protected _effect: Effect;
  54234. protected _cachedDefines: string;
  54235. /**
  54236. * Set the render list (meshes to be rendered) used in the G buffer.
  54237. */
  54238. renderList: Mesh[];
  54239. /**
  54240. * Gets wether or not G buffer are supported by the running hardware.
  54241. * This requires draw buffer supports
  54242. */
  54243. readonly isSupported: boolean;
  54244. /**
  54245. * Returns the index of the given texture type in the G-Buffer textures array
  54246. * @param textureType The texture type constant. For example GeometryBufferRenderer.POSITION_TEXTURE_INDEX
  54247. * @returns the index of the given texture type in the G-Buffer textures array
  54248. */
  54249. getTextureIndex(textureType: number): number;
  54250. /**
  54251. * Gets a boolean indicating if objects positions are enabled for the G buffer.
  54252. */
  54253. /**
  54254. * Sets whether or not objects positions are enabled for the G buffer.
  54255. */
  54256. enablePosition: boolean;
  54257. /**
  54258. * Gets a boolean indicating if objects velocities are enabled for the G buffer.
  54259. */
  54260. /**
  54261. * Sets wether or not objects velocities are enabled for the G buffer.
  54262. */
  54263. enableVelocity: boolean;
  54264. /**
  54265. * Gets the scene associated with the buffer.
  54266. */
  54267. readonly scene: Scene;
  54268. /**
  54269. * Gets the ratio used by the buffer during its creation.
  54270. * How big is the buffer related to the main canvas.
  54271. */
  54272. readonly ratio: number;
  54273. /** @hidden */
  54274. static _SceneComponentInitialization: (scene: Scene) => void;
  54275. /**
  54276. * Creates a new G Buffer for the scene
  54277. * @param scene The scene the buffer belongs to
  54278. * @param ratio How big is the buffer related to the main canvas.
  54279. */
  54280. constructor(scene: Scene, ratio?: number);
  54281. /**
  54282. * Checks wether everything is ready to render a submesh to the G buffer.
  54283. * @param subMesh the submesh to check readiness for
  54284. * @param useInstances is the mesh drawn using instance or not
  54285. * @returns true if ready otherwise false
  54286. */
  54287. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  54288. /**
  54289. * Gets the current underlying G Buffer.
  54290. * @returns the buffer
  54291. */
  54292. getGBuffer(): MultiRenderTarget;
  54293. /**
  54294. * Gets the number of samples used to render the buffer (anti aliasing).
  54295. */
  54296. /**
  54297. * Sets the number of samples used to render the buffer (anti aliasing).
  54298. */
  54299. samples: number;
  54300. /**
  54301. * Disposes the renderer and frees up associated resources.
  54302. */
  54303. dispose(): void;
  54304. protected _createRenderTargets(): void;
  54305. }
  54306. }
  54307. declare module "babylonjs/Rendering/geometryBufferRendererSceneComponent" {
  54308. import { Nullable } from "babylonjs/types";
  54309. import { Scene } from "babylonjs/scene";
  54310. import { ISceneComponent } from "babylonjs/sceneComponent";
  54311. import { GeometryBufferRenderer } from "babylonjs/Rendering/geometryBufferRenderer";
  54312. module "babylonjs/scene" {
  54313. interface Scene {
  54314. /** @hidden (Backing field) */
  54315. _geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  54316. /**
  54317. * Gets or Sets the current geometry buffer associated to the scene.
  54318. */
  54319. geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  54320. /**
  54321. * Enables a GeometryBufferRender and associates it with the scene
  54322. * @param ratio defines the scaling ratio to apply to the renderer (1 by default which means same resolution)
  54323. * @returns the GeometryBufferRenderer
  54324. */
  54325. enableGeometryBufferRenderer(ratio?: number): Nullable<GeometryBufferRenderer>;
  54326. /**
  54327. * Disables the GeometryBufferRender associated with the scene
  54328. */
  54329. disableGeometryBufferRenderer(): void;
  54330. }
  54331. }
  54332. /**
  54333. * Defines the Geometry Buffer scene component responsible to manage a G-Buffer useful
  54334. * in several rendering techniques.
  54335. */
  54336. export class GeometryBufferRendererSceneComponent implements ISceneComponent {
  54337. /**
  54338. * The component name helpful to identify the component in the list of scene components.
  54339. */
  54340. readonly name: string;
  54341. /**
  54342. * The scene the component belongs to.
  54343. */
  54344. scene: Scene;
  54345. /**
  54346. * Creates a new instance of the component for the given scene
  54347. * @param scene Defines the scene to register the component in
  54348. */
  54349. constructor(scene: Scene);
  54350. /**
  54351. * Registers the component in a given scene
  54352. */
  54353. register(): void;
  54354. /**
  54355. * Rebuilds the elements related to this component in case of
  54356. * context lost for instance.
  54357. */
  54358. rebuild(): void;
  54359. /**
  54360. * Disposes the component and the associated ressources
  54361. */
  54362. dispose(): void;
  54363. private _gatherRenderTargets;
  54364. }
  54365. }
  54366. declare module "babylonjs/Shaders/motionBlur.fragment" {
  54367. /** @hidden */
  54368. export var motionBlurPixelShader: {
  54369. name: string;
  54370. shader: string;
  54371. };
  54372. }
  54373. declare module "babylonjs/PostProcesses/motionBlurPostProcess" {
  54374. import { Nullable } from "babylonjs/types";
  54375. import { Camera } from "babylonjs/Cameras/camera";
  54376. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  54377. import { Scene } from "babylonjs/scene";
  54378. import "babylonjs/Animations/animatable";
  54379. import "babylonjs/Rendering/geometryBufferRendererSceneComponent";
  54380. import "babylonjs/Shaders/motionBlur.fragment";
  54381. import { Engine } from "babylonjs/Engines/engine";
  54382. /**
  54383. * The Motion Blur Post Process which blurs an image based on the objects velocity in scene.
  54384. * Velocity can be affected by each object's rotation, position and scale depending on the transformation speed.
  54385. * As an example, all you have to do is to create the post-process:
  54386. * var mb = new BABYLON.MotionBlurPostProcess(
  54387. * 'mb', // The name of the effect.
  54388. * scene, // The scene containing the objects to blur according to their velocity.
  54389. * 1.0, // The required width/height ratio to downsize to before computing the render pass.
  54390. * camera // The camera to apply the render pass to.
  54391. * );
  54392. * Then, all objects moving, rotating and/or scaling will be blurred depending on the transformation speed.
  54393. */
  54394. export class MotionBlurPostProcess extends PostProcess {
  54395. /**
  54396. * Defines how much the image is blurred by the movement. Default value is equal to 1
  54397. */
  54398. motionStrength: number;
  54399. /**
  54400. * Gets the number of iterations are used for motion blur quality. Default value is equal to 32
  54401. */
  54402. /**
  54403. * Sets the number of iterations to be used for motion blur quality
  54404. */
  54405. motionBlurSamples: number;
  54406. private _motionBlurSamples;
  54407. private _geometryBufferRenderer;
  54408. /**
  54409. * Creates a new instance MotionBlurPostProcess
  54410. * @param name The name of the effect.
  54411. * @param scene The scene containing the objects to blur according to their velocity.
  54412. * @param options The required width/height ratio to downsize to before computing the render pass.
  54413. * @param camera The camera to apply the render pass to.
  54414. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  54415. * @param engine The engine which the post process will be applied. (default: current engine)
  54416. * @param reusable If the post process can be reused on the same frame. (default: false)
  54417. * @param textureType Type of textures used when performing the post process. (default: 0)
  54418. * @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)
  54419. */
  54420. constructor(name: string, scene: Scene, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  54421. /**
  54422. * Disposes the post process.
  54423. * @param camera The camera to dispose the post process on.
  54424. */
  54425. dispose(camera?: Camera): void;
  54426. }
  54427. }
  54428. declare module "babylonjs/Shaders/refraction.fragment" {
  54429. /** @hidden */
  54430. export var refractionPixelShader: {
  54431. name: string;
  54432. shader: string;
  54433. };
  54434. }
  54435. declare module "babylonjs/PostProcesses/refractionPostProcess" {
  54436. import { Color3 } from "babylonjs/Maths/math";
  54437. import { Camera } from "babylonjs/Cameras/camera";
  54438. import { Texture } from "babylonjs/Materials/Textures/texture";
  54439. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  54440. import { Engine } from "babylonjs/Engines/engine";
  54441. import "babylonjs/Shaders/refraction.fragment";
  54442. /**
  54443. * Post process which applies a refractin texture
  54444. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  54445. */
  54446. export class RefractionPostProcess extends PostProcess {
  54447. /** the base color of the refraction (used to taint the rendering) */
  54448. color: Color3;
  54449. /** simulated refraction depth */
  54450. depth: number;
  54451. /** the coefficient of the base color (0 to remove base color tainting) */
  54452. colorLevel: number;
  54453. private _refTexture;
  54454. private _ownRefractionTexture;
  54455. /**
  54456. * Gets or sets the refraction texture
  54457. * Please note that you are responsible for disposing the texture if you set it manually
  54458. */
  54459. refractionTexture: Texture;
  54460. /**
  54461. * Initializes the RefractionPostProcess
  54462. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  54463. * @param name The name of the effect.
  54464. * @param refractionTextureUrl Url of the refraction texture to use
  54465. * @param color the base color of the refraction (used to taint the rendering)
  54466. * @param depth simulated refraction depth
  54467. * @param colorLevel the coefficient of the base color (0 to remove base color tainting)
  54468. * @param camera The camera to apply the render pass to.
  54469. * @param options The required width/height ratio to downsize to before computing the render pass.
  54470. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  54471. * @param engine The engine which the post process will be applied. (default: current engine)
  54472. * @param reusable If the post process can be reused on the same frame. (default: false)
  54473. */
  54474. constructor(name: string, refractionTextureUrl: string,
  54475. /** the base color of the refraction (used to taint the rendering) */
  54476. color: Color3,
  54477. /** simulated refraction depth */
  54478. depth: number,
  54479. /** the coefficient of the base color (0 to remove base color tainting) */
  54480. colorLevel: number, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  54481. /**
  54482. * Disposes of the post process
  54483. * @param camera Camera to dispose post process on
  54484. */
  54485. dispose(camera: Camera): void;
  54486. }
  54487. }
  54488. declare module "babylonjs/Shaders/sharpen.fragment" {
  54489. /** @hidden */
  54490. export var sharpenPixelShader: {
  54491. name: string;
  54492. shader: string;
  54493. };
  54494. }
  54495. declare module "babylonjs/PostProcesses/sharpenPostProcess" {
  54496. import { Nullable } from "babylonjs/types";
  54497. import { Camera } from "babylonjs/Cameras/camera";
  54498. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  54499. import "babylonjs/Shaders/sharpen.fragment";
  54500. import { Engine } from "babylonjs/Engines/engine";
  54501. /**
  54502. * The SharpenPostProcess applies a sharpen kernel to every pixel
  54503. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  54504. */
  54505. export class SharpenPostProcess extends PostProcess {
  54506. /**
  54507. * How much of the original color should be applied. Setting this to 0 will display edge detection. (default: 1)
  54508. */
  54509. colorAmount: number;
  54510. /**
  54511. * How much sharpness should be applied (default: 0.3)
  54512. */
  54513. edgeAmount: number;
  54514. /**
  54515. * Creates a new instance ConvolutionPostProcess
  54516. * @param name The name of the effect.
  54517. * @param options The required width/height ratio to downsize to before computing the render pass.
  54518. * @param camera The camera to apply the render pass to.
  54519. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  54520. * @param engine The engine which the post process will be applied. (default: current engine)
  54521. * @param reusable If the post process can be reused on the same frame. (default: false)
  54522. * @param textureType Type of textures used when performing the post process. (default: 0)
  54523. * @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)
  54524. */
  54525. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  54526. }
  54527. }
  54528. declare module "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline" {
  54529. import { Nullable } from "babylonjs/types";
  54530. import { Camera } from "babylonjs/Cameras/camera";
  54531. import { Engine } from "babylonjs/Engines/engine";
  54532. import { PostProcessRenderEffect } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderEffect";
  54533. import { IInspectable } from "babylonjs/Misc/iInspectable";
  54534. /**
  54535. * PostProcessRenderPipeline
  54536. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  54537. */
  54538. export class PostProcessRenderPipeline {
  54539. private engine;
  54540. private _renderEffects;
  54541. private _renderEffectsForIsolatedPass;
  54542. /**
  54543. * List of inspectable custom properties (used by the Inspector)
  54544. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  54545. */
  54546. inspectableCustomProperties: IInspectable[];
  54547. /**
  54548. * @hidden
  54549. */
  54550. protected _cameras: Camera[];
  54551. /** @hidden */
  54552. _name: string;
  54553. /**
  54554. * Gets pipeline name
  54555. */
  54556. readonly name: string;
  54557. /**
  54558. * Initializes a PostProcessRenderPipeline
  54559. * @param engine engine to add the pipeline to
  54560. * @param name name of the pipeline
  54561. */
  54562. constructor(engine: Engine, name: string);
  54563. /**
  54564. * Gets the class name
  54565. * @returns "PostProcessRenderPipeline"
  54566. */
  54567. getClassName(): string;
  54568. /**
  54569. * If all the render effects in the pipeline are supported
  54570. */
  54571. readonly isSupported: boolean;
  54572. /**
  54573. * Adds an effect to the pipeline
  54574. * @param renderEffect the effect to add
  54575. */
  54576. addEffect(renderEffect: PostProcessRenderEffect): void;
  54577. /** @hidden */
  54578. _rebuild(): void;
  54579. /** @hidden */
  54580. _enableEffect(renderEffectName: string, cameras: Camera): void;
  54581. /** @hidden */
  54582. _enableEffect(renderEffectName: string, cameras: Camera[]): void;
  54583. /** @hidden */
  54584. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  54585. /** @hidden */
  54586. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  54587. /** @hidden */
  54588. _attachCameras(cameras: Camera, unique: boolean): void;
  54589. /** @hidden */
  54590. _attachCameras(cameras: Camera[], unique: boolean): void;
  54591. /** @hidden */
  54592. _detachCameras(cameras: Camera): void;
  54593. /** @hidden */
  54594. _detachCameras(cameras: Nullable<Camera[]>): void;
  54595. /** @hidden */
  54596. _update(): void;
  54597. /** @hidden */
  54598. _reset(): void;
  54599. protected _enableMSAAOnFirstPostProcess(sampleCount: number): boolean;
  54600. /**
  54601. * Disposes of the pipeline
  54602. */
  54603. dispose(): void;
  54604. }
  54605. }
  54606. declare module "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManager" {
  54607. import { Camera } from "babylonjs/Cameras/camera";
  54608. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  54609. /**
  54610. * PostProcessRenderPipelineManager class
  54611. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  54612. */
  54613. export class PostProcessRenderPipelineManager {
  54614. private _renderPipelines;
  54615. /**
  54616. * Initializes a PostProcessRenderPipelineManager
  54617. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  54618. */
  54619. constructor();
  54620. /**
  54621. * Gets the list of supported render pipelines
  54622. */
  54623. readonly supportedPipelines: PostProcessRenderPipeline[];
  54624. /**
  54625. * Adds a pipeline to the manager
  54626. * @param renderPipeline The pipeline to add
  54627. */
  54628. addPipeline(renderPipeline: PostProcessRenderPipeline): void;
  54629. /**
  54630. * Attaches a camera to the pipeline
  54631. * @param renderPipelineName The name of the pipeline to attach to
  54632. * @param cameras the camera to attach
  54633. * @param unique if the camera can be attached multiple times to the pipeline
  54634. */
  54635. attachCamerasToRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera, unique?: boolean): void;
  54636. /**
  54637. * Detaches a camera from the pipeline
  54638. * @param renderPipelineName The name of the pipeline to detach from
  54639. * @param cameras the camera to detach
  54640. */
  54641. detachCamerasFromRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera): void;
  54642. /**
  54643. * Enables an effect by name on a pipeline
  54644. * @param renderPipelineName the name of the pipeline to enable the effect in
  54645. * @param renderEffectName the name of the effect to enable
  54646. * @param cameras the cameras that the effect should be enabled on
  54647. */
  54648. enableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  54649. /**
  54650. * Disables an effect by name on a pipeline
  54651. * @param renderPipelineName the name of the pipeline to disable the effect in
  54652. * @param renderEffectName the name of the effect to disable
  54653. * @param cameras the cameras that the effect should be disabled on
  54654. */
  54655. disableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  54656. /**
  54657. * Updates the state of all contained render pipelines and disposes of any non supported pipelines
  54658. */
  54659. update(): void;
  54660. /** @hidden */
  54661. _rebuild(): void;
  54662. /**
  54663. * Disposes of the manager and pipelines
  54664. */
  54665. dispose(): void;
  54666. }
  54667. }
  54668. declare module "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent" {
  54669. import { ISceneComponent } from "babylonjs/sceneComponent";
  54670. import { PostProcessRenderPipelineManager } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManager";
  54671. import { Scene } from "babylonjs/scene";
  54672. module "babylonjs/scene" {
  54673. interface Scene {
  54674. /** @hidden (Backing field) */
  54675. _postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  54676. /**
  54677. * Gets the postprocess render pipeline manager
  54678. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  54679. * @see http://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  54680. */
  54681. readonly postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  54682. }
  54683. }
  54684. /**
  54685. * Defines the Render Pipeline scene component responsible to rendering pipelines
  54686. */
  54687. export class PostProcessRenderPipelineManagerSceneComponent implements ISceneComponent {
  54688. /**
  54689. * The component name helpfull to identify the component in the list of scene components.
  54690. */
  54691. readonly name: string;
  54692. /**
  54693. * The scene the component belongs to.
  54694. */
  54695. scene: Scene;
  54696. /**
  54697. * Creates a new instance of the component for the given scene
  54698. * @param scene Defines the scene to register the component in
  54699. */
  54700. constructor(scene: Scene);
  54701. /**
  54702. * Registers the component in a given scene
  54703. */
  54704. register(): void;
  54705. /**
  54706. * Rebuilds the elements related to this component in case of
  54707. * context lost for instance.
  54708. */
  54709. rebuild(): void;
  54710. /**
  54711. * Disposes the component and the associated ressources
  54712. */
  54713. dispose(): void;
  54714. private _gatherRenderTargets;
  54715. }
  54716. }
  54717. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/defaultRenderingPipeline" {
  54718. import { IAnimatable } from "babylonjs/Misc/tools";
  54719. import { Camera } from "babylonjs/Cameras/camera";
  54720. import { IDisposable } from "babylonjs/scene";
  54721. import { Scene } from "babylonjs/scene";
  54722. import { SharpenPostProcess } from "babylonjs/PostProcesses/sharpenPostProcess";
  54723. import { ImageProcessingPostProcess } from "babylonjs/PostProcesses/imageProcessingPostProcess";
  54724. import { ChromaticAberrationPostProcess } from "babylonjs/PostProcesses/chromaticAberrationPostProcess";
  54725. import { GrainPostProcess } from "babylonjs/PostProcesses/grainPostProcess";
  54726. import { FxaaPostProcess } from "babylonjs/PostProcesses/fxaaPostProcess";
  54727. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  54728. import { DepthOfFieldEffect, DepthOfFieldEffectBlurLevel } from "babylonjs/PostProcesses/depthOfFieldEffect";
  54729. import "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent";
  54730. import { Animation } from "babylonjs/Animations/animation";
  54731. /**
  54732. * The default rendering pipeline can be added to a scene to apply common post processing effects such as anti-aliasing or depth of field.
  54733. * See https://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  54734. */
  54735. export class DefaultRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  54736. private _scene;
  54737. private _camerasToBeAttached;
  54738. /**
  54739. * ID of the sharpen post process,
  54740. */
  54741. private readonly SharpenPostProcessId;
  54742. /**
  54743. * @ignore
  54744. * ID of the image processing post process;
  54745. */
  54746. readonly ImageProcessingPostProcessId: string;
  54747. /**
  54748. * @ignore
  54749. * ID of the Fast Approximate Anti-Aliasing post process;
  54750. */
  54751. readonly FxaaPostProcessId: string;
  54752. /**
  54753. * ID of the chromatic aberration post process,
  54754. */
  54755. private readonly ChromaticAberrationPostProcessId;
  54756. /**
  54757. * ID of the grain post process
  54758. */
  54759. private readonly GrainPostProcessId;
  54760. /**
  54761. * Sharpen post process which will apply a sharpen convolution to enhance edges
  54762. */
  54763. sharpen: SharpenPostProcess;
  54764. private _sharpenEffect;
  54765. private bloom;
  54766. /**
  54767. * Depth of field effect, applies a blur based on how far away objects are from the focus distance.
  54768. */
  54769. depthOfField: DepthOfFieldEffect;
  54770. /**
  54771. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  54772. */
  54773. fxaa: FxaaPostProcess;
  54774. /**
  54775. * Image post processing pass used to perform operations such as tone mapping or color grading.
  54776. */
  54777. imageProcessing: ImageProcessingPostProcess;
  54778. /**
  54779. * Chromatic aberration post process which will shift rgb colors in the image
  54780. */
  54781. chromaticAberration: ChromaticAberrationPostProcess;
  54782. private _chromaticAberrationEffect;
  54783. /**
  54784. * Grain post process which add noise to the image
  54785. */
  54786. grain: GrainPostProcess;
  54787. private _grainEffect;
  54788. /**
  54789. * Glow post process which adds a glow to emissive areas of the image
  54790. */
  54791. private _glowLayer;
  54792. /**
  54793. * Animations which can be used to tweak settings over a period of time
  54794. */
  54795. animations: Animation[];
  54796. private _imageProcessingConfigurationObserver;
  54797. private _sharpenEnabled;
  54798. private _bloomEnabled;
  54799. private _depthOfFieldEnabled;
  54800. private _depthOfFieldBlurLevel;
  54801. private _fxaaEnabled;
  54802. private _imageProcessingEnabled;
  54803. private _defaultPipelineTextureType;
  54804. private _bloomScale;
  54805. private _chromaticAberrationEnabled;
  54806. private _grainEnabled;
  54807. private _buildAllowed;
  54808. /**
  54809. * Gets active scene
  54810. */
  54811. readonly scene: Scene;
  54812. /**
  54813. * Enable or disable the sharpen process from the pipeline
  54814. */
  54815. sharpenEnabled: boolean;
  54816. private _resizeObserver;
  54817. private _hardwareScaleLevel;
  54818. private _bloomKernel;
  54819. /**
  54820. * Specifies the size of the bloom blur kernel, relative to the final output size
  54821. */
  54822. bloomKernel: number;
  54823. /**
  54824. * Specifies the weight of the bloom in the final rendering
  54825. */
  54826. private _bloomWeight;
  54827. /**
  54828. * Specifies the luma threshold for the area that will be blurred by the bloom
  54829. */
  54830. private _bloomThreshold;
  54831. private _hdr;
  54832. /**
  54833. * The strength of the bloom.
  54834. */
  54835. bloomWeight: number;
  54836. /**
  54837. * The strength of the bloom.
  54838. */
  54839. bloomThreshold: number;
  54840. /**
  54841. * The scale of the bloom, lower value will provide better performance.
  54842. */
  54843. bloomScale: number;
  54844. /**
  54845. * Enable or disable the bloom from the pipeline
  54846. */
  54847. bloomEnabled: boolean;
  54848. private _rebuildBloom;
  54849. /**
  54850. * If the depth of field is enabled.
  54851. */
  54852. depthOfFieldEnabled: boolean;
  54853. /**
  54854. * Blur level of the depth of field effect. (Higher blur will effect performance)
  54855. */
  54856. depthOfFieldBlurLevel: DepthOfFieldEffectBlurLevel;
  54857. /**
  54858. * If the anti aliasing is enabled.
  54859. */
  54860. fxaaEnabled: boolean;
  54861. private _samples;
  54862. /**
  54863. * MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  54864. */
  54865. samples: number;
  54866. /**
  54867. * If image processing is enabled.
  54868. */
  54869. imageProcessingEnabled: boolean;
  54870. /**
  54871. * If glow layer is enabled. (Adds a glow effect to emmissive materials)
  54872. */
  54873. glowLayerEnabled: boolean;
  54874. /**
  54875. * Enable or disable the chromaticAberration process from the pipeline
  54876. */
  54877. chromaticAberrationEnabled: boolean;
  54878. /**
  54879. * Enable or disable the grain process from the pipeline
  54880. */
  54881. grainEnabled: boolean;
  54882. /**
  54883. * @constructor
  54884. * @param name - The rendering pipeline name (default: "")
  54885. * @param hdr - If high dynamic range textures should be used (default: true)
  54886. * @param scene - The scene linked to this pipeline (default: the last created scene)
  54887. * @param cameras - The array of cameras that the rendering pipeline will be attached to (default: scene.cameras)
  54888. * @param automaticBuild - if false, you will have to manually call prepare() to update the pipeline (default: true)
  54889. */
  54890. constructor(name?: string, hdr?: boolean, scene?: Scene, cameras?: Camera[], automaticBuild?: boolean);
  54891. /**
  54892. * Get the class name
  54893. * @returns "DefaultRenderingPipeline"
  54894. */
  54895. getClassName(): string;
  54896. /**
  54897. * Force the compilation of the entire pipeline.
  54898. */
  54899. prepare(): void;
  54900. private _hasCleared;
  54901. private _prevPostProcess;
  54902. private _prevPrevPostProcess;
  54903. private _setAutoClearAndTextureSharing;
  54904. private _depthOfFieldSceneObserver;
  54905. private _buildPipeline;
  54906. private _disposePostProcesses;
  54907. /**
  54908. * Adds a camera to the pipeline
  54909. * @param camera the camera to be added
  54910. */
  54911. addCamera(camera: Camera): void;
  54912. /**
  54913. * Removes a camera from the pipeline
  54914. * @param camera the camera to remove
  54915. */
  54916. removeCamera(camera: Camera): void;
  54917. /**
  54918. * Dispose of the pipeline and stop all post processes
  54919. */
  54920. dispose(): void;
  54921. /**
  54922. * Serialize the rendering pipeline (Used when exporting)
  54923. * @returns the serialized object
  54924. */
  54925. serialize(): any;
  54926. /**
  54927. * Parse the serialized pipeline
  54928. * @param source Source pipeline.
  54929. * @param scene The scene to load the pipeline to.
  54930. * @param rootUrl The URL of the serialized pipeline.
  54931. * @returns An instantiated pipeline from the serialized object.
  54932. */
  54933. static Parse(source: any, scene: Scene, rootUrl: string): DefaultRenderingPipeline;
  54934. }
  54935. }
  54936. declare module "babylonjs/Shaders/lensHighlights.fragment" {
  54937. /** @hidden */
  54938. export var lensHighlightsPixelShader: {
  54939. name: string;
  54940. shader: string;
  54941. };
  54942. }
  54943. declare module "babylonjs/Shaders/depthOfField.fragment" {
  54944. /** @hidden */
  54945. export var depthOfFieldPixelShader: {
  54946. name: string;
  54947. shader: string;
  54948. };
  54949. }
  54950. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/lensRenderingPipeline" {
  54951. import { Camera } from "babylonjs/Cameras/camera";
  54952. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  54953. import { Scene } from "babylonjs/scene";
  54954. import "babylonjs/Shaders/chromaticAberration.fragment";
  54955. import "babylonjs/Shaders/lensHighlights.fragment";
  54956. import "babylonjs/Shaders/depthOfField.fragment";
  54957. /**
  54958. * BABYLON.JS Chromatic Aberration GLSL Shader
  54959. * Author: Olivier Guyot
  54960. * Separates very slightly R, G and B colors on the edges of the screen
  54961. * Inspired by Francois Tarlier & Martins Upitis
  54962. */
  54963. export class LensRenderingPipeline extends PostProcessRenderPipeline {
  54964. /**
  54965. * @ignore
  54966. * The chromatic aberration PostProcess id in the pipeline
  54967. */
  54968. LensChromaticAberrationEffect: string;
  54969. /**
  54970. * @ignore
  54971. * The highlights enhancing PostProcess id in the pipeline
  54972. */
  54973. HighlightsEnhancingEffect: string;
  54974. /**
  54975. * @ignore
  54976. * The depth-of-field PostProcess id in the pipeline
  54977. */
  54978. LensDepthOfFieldEffect: string;
  54979. private _scene;
  54980. private _depthTexture;
  54981. private _grainTexture;
  54982. private _chromaticAberrationPostProcess;
  54983. private _highlightsPostProcess;
  54984. private _depthOfFieldPostProcess;
  54985. private _edgeBlur;
  54986. private _grainAmount;
  54987. private _chromaticAberration;
  54988. private _distortion;
  54989. private _highlightsGain;
  54990. private _highlightsThreshold;
  54991. private _dofDistance;
  54992. private _dofAperture;
  54993. private _dofDarken;
  54994. private _dofPentagon;
  54995. private _blurNoise;
  54996. /**
  54997. * @constructor
  54998. *
  54999. * Effect parameters are as follow:
  55000. * {
  55001. * chromatic_aberration: number; // from 0 to x (1 for realism)
  55002. * edge_blur: number; // from 0 to x (1 for realism)
  55003. * distortion: number; // from 0 to x (1 for realism)
  55004. * grain_amount: number; // from 0 to 1
  55005. * grain_texture: BABYLON.Texture; // texture to use for grain effect; if unset, use random B&W noise
  55006. * dof_focus_distance: number; // depth-of-field: focus distance; unset to disable (disabled by default)
  55007. * dof_aperture: number; // depth-of-field: focus blur bias (default: 1)
  55008. * dof_darken: number; // depth-of-field: darken that which is out of focus (from 0 to 1, disabled by default)
  55009. * dof_pentagon: boolean; // depth-of-field: makes a pentagon-like "bokeh" effect
  55010. * dof_gain: number; // depth-of-field: highlights gain; unset to disable (disabled by default)
  55011. * dof_threshold: number; // depth-of-field: highlights threshold (default: 1)
  55012. * blur_noise: boolean; // add a little bit of noise to the blur (default: true)
  55013. * }
  55014. * Note: if an effect parameter is unset, effect is disabled
  55015. *
  55016. * @param name The rendering pipeline name
  55017. * @param parameters - An object containing all parameters (see above)
  55018. * @param scene The scene linked to this pipeline
  55019. * @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)
  55020. * @param cameras The array of cameras that the rendering pipeline will be attached to
  55021. */
  55022. constructor(name: string, parameters: any, scene: Scene, ratio?: number, cameras?: Camera[]);
  55023. /**
  55024. * Get the class name
  55025. * @returns "LensRenderingPipeline"
  55026. */
  55027. getClassName(): string;
  55028. /**
  55029. * Gets associated scene
  55030. */
  55031. readonly scene: Scene;
  55032. /**
  55033. * Gets or sets the edge blur
  55034. */
  55035. edgeBlur: number;
  55036. /**
  55037. * Gets or sets the grain amount
  55038. */
  55039. grainAmount: number;
  55040. /**
  55041. * Gets or sets the chromatic aberration amount
  55042. */
  55043. chromaticAberration: number;
  55044. /**
  55045. * Gets or sets the depth of field aperture
  55046. */
  55047. dofAperture: number;
  55048. /**
  55049. * Gets or sets the edge distortion
  55050. */
  55051. edgeDistortion: number;
  55052. /**
  55053. * Gets or sets the depth of field distortion
  55054. */
  55055. dofDistortion: number;
  55056. /**
  55057. * Gets or sets the darken out of focus amount
  55058. */
  55059. darkenOutOfFocus: number;
  55060. /**
  55061. * Gets or sets a boolean indicating if blur noise is enabled
  55062. */
  55063. blurNoise: boolean;
  55064. /**
  55065. * Gets or sets a boolean indicating if pentagon bokeh is enabled
  55066. */
  55067. pentagonBokeh: boolean;
  55068. /**
  55069. * Gets or sets the highlight grain amount
  55070. */
  55071. highlightsGain: number;
  55072. /**
  55073. * Gets or sets the highlight threshold
  55074. */
  55075. highlightsThreshold: number;
  55076. /**
  55077. * Sets the amount of blur at the edges
  55078. * @param amount blur amount
  55079. */
  55080. setEdgeBlur(amount: number): void;
  55081. /**
  55082. * Sets edge blur to 0
  55083. */
  55084. disableEdgeBlur(): void;
  55085. /**
  55086. * Sets the amout of grain
  55087. * @param amount Amount of grain
  55088. */
  55089. setGrainAmount(amount: number): void;
  55090. /**
  55091. * Set grain amount to 0
  55092. */
  55093. disableGrain(): void;
  55094. /**
  55095. * Sets the chromatic aberration amount
  55096. * @param amount amount of chromatic aberration
  55097. */
  55098. setChromaticAberration(amount: number): void;
  55099. /**
  55100. * Sets chromatic aberration amount to 0
  55101. */
  55102. disableChromaticAberration(): void;
  55103. /**
  55104. * Sets the EdgeDistortion amount
  55105. * @param amount amount of EdgeDistortion
  55106. */
  55107. setEdgeDistortion(amount: number): void;
  55108. /**
  55109. * Sets edge distortion to 0
  55110. */
  55111. disableEdgeDistortion(): void;
  55112. /**
  55113. * Sets the FocusDistance amount
  55114. * @param amount amount of FocusDistance
  55115. */
  55116. setFocusDistance(amount: number): void;
  55117. /**
  55118. * Disables depth of field
  55119. */
  55120. disableDepthOfField(): void;
  55121. /**
  55122. * Sets the Aperture amount
  55123. * @param amount amount of Aperture
  55124. */
  55125. setAperture(amount: number): void;
  55126. /**
  55127. * Sets the DarkenOutOfFocus amount
  55128. * @param amount amount of DarkenOutOfFocus
  55129. */
  55130. setDarkenOutOfFocus(amount: number): void;
  55131. private _pentagonBokehIsEnabled;
  55132. /**
  55133. * Creates a pentagon bokeh effect
  55134. */
  55135. enablePentagonBokeh(): void;
  55136. /**
  55137. * Disables the pentagon bokeh effect
  55138. */
  55139. disablePentagonBokeh(): void;
  55140. /**
  55141. * Enables noise blur
  55142. */
  55143. enableNoiseBlur(): void;
  55144. /**
  55145. * Disables noise blur
  55146. */
  55147. disableNoiseBlur(): void;
  55148. /**
  55149. * Sets the HighlightsGain amount
  55150. * @param amount amount of HighlightsGain
  55151. */
  55152. setHighlightsGain(amount: number): void;
  55153. /**
  55154. * Sets the HighlightsThreshold amount
  55155. * @param amount amount of HighlightsThreshold
  55156. */
  55157. setHighlightsThreshold(amount: number): void;
  55158. /**
  55159. * Disables highlights
  55160. */
  55161. disableHighlights(): void;
  55162. /**
  55163. * Removes the internal pipeline assets and detaches the pipeline from the scene cameras
  55164. * @param disableDepthRender If the scens depth rendering should be disabled (default: false)
  55165. */
  55166. dispose(disableDepthRender?: boolean): void;
  55167. private _createChromaticAberrationPostProcess;
  55168. private _createHighlightsPostProcess;
  55169. private _createDepthOfFieldPostProcess;
  55170. private _createGrainTexture;
  55171. }
  55172. }
  55173. declare module "babylonjs/Shaders/ssao2.fragment" {
  55174. /** @hidden */
  55175. export var ssao2PixelShader: {
  55176. name: string;
  55177. shader: string;
  55178. };
  55179. }
  55180. declare module "babylonjs/Shaders/ssaoCombine.fragment" {
  55181. /** @hidden */
  55182. export var ssaoCombinePixelShader: {
  55183. name: string;
  55184. shader: string;
  55185. };
  55186. }
  55187. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/ssao2RenderingPipeline" {
  55188. import { Camera } from "babylonjs/Cameras/camera";
  55189. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  55190. import { Scene } from "babylonjs/scene";
  55191. import "babylonjs/Shaders/ssao2.fragment";
  55192. import "babylonjs/Shaders/ssaoCombine.fragment";
  55193. /**
  55194. * Render pipeline to produce ssao effect
  55195. */
  55196. export class SSAO2RenderingPipeline extends PostProcessRenderPipeline {
  55197. /**
  55198. * @ignore
  55199. * The PassPostProcess id in the pipeline that contains the original scene color
  55200. */
  55201. SSAOOriginalSceneColorEffect: string;
  55202. /**
  55203. * @ignore
  55204. * The SSAO PostProcess id in the pipeline
  55205. */
  55206. SSAORenderEffect: string;
  55207. /**
  55208. * @ignore
  55209. * The horizontal blur PostProcess id in the pipeline
  55210. */
  55211. SSAOBlurHRenderEffect: string;
  55212. /**
  55213. * @ignore
  55214. * The vertical blur PostProcess id in the pipeline
  55215. */
  55216. SSAOBlurVRenderEffect: string;
  55217. /**
  55218. * @ignore
  55219. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  55220. */
  55221. SSAOCombineRenderEffect: string;
  55222. /**
  55223. * The output strength of the SSAO post-process. Default value is 1.0.
  55224. */
  55225. totalStrength: number;
  55226. /**
  55227. * Maximum depth value to still render AO. A smooth falloff makes the dimming more natural, so there will be no abrupt shading change.
  55228. */
  55229. maxZ: number;
  55230. /**
  55231. * In order to save performances, SSAO radius is clamped on close geometry. This ratio changes by how much
  55232. */
  55233. minZAspect: number;
  55234. private _samples;
  55235. /**
  55236. * Number of samples used for the SSAO calculations. Default value is 8
  55237. */
  55238. samples: number;
  55239. private _textureSamples;
  55240. /**
  55241. * Number of samples to use for antialiasing
  55242. */
  55243. textureSamples: number;
  55244. /**
  55245. * Ratio object used for SSAO ratio and blur ratio
  55246. */
  55247. private _ratio;
  55248. /**
  55249. * Dynamically generated sphere sampler.
  55250. */
  55251. private _sampleSphere;
  55252. /**
  55253. * Blur filter offsets
  55254. */
  55255. private _samplerOffsets;
  55256. private _expensiveBlur;
  55257. /**
  55258. * If bilateral blur should be used
  55259. */
  55260. expensiveBlur: boolean;
  55261. /**
  55262. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 2.0
  55263. */
  55264. radius: number;
  55265. /**
  55266. * The base color of the SSAO post-process
  55267. * The final result is "base + ssao" between [0, 1]
  55268. */
  55269. base: number;
  55270. /**
  55271. * Support test.
  55272. */
  55273. static readonly IsSupported: boolean;
  55274. private _scene;
  55275. private _depthTexture;
  55276. private _normalTexture;
  55277. private _randomTexture;
  55278. private _originalColorPostProcess;
  55279. private _ssaoPostProcess;
  55280. private _blurHPostProcess;
  55281. private _blurVPostProcess;
  55282. private _ssaoCombinePostProcess;
  55283. private _firstUpdate;
  55284. /**
  55285. * Gets active scene
  55286. */
  55287. readonly scene: Scene;
  55288. /**
  55289. * @constructor
  55290. * @param name The rendering pipeline name
  55291. * @param scene The scene linked to this pipeline
  55292. * @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 }
  55293. * @param cameras The array of cameras that the rendering pipeline will be attached to
  55294. */
  55295. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[]);
  55296. /**
  55297. * Get the class name
  55298. * @returns "SSAO2RenderingPipeline"
  55299. */
  55300. getClassName(): string;
  55301. /**
  55302. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  55303. */
  55304. dispose(disableGeometryBufferRenderer?: boolean): void;
  55305. private _createBlurPostProcess;
  55306. /** @hidden */
  55307. _rebuild(): void;
  55308. private _bits;
  55309. private _radicalInverse_VdC;
  55310. private _hammersley;
  55311. private _hemisphereSample_uniform;
  55312. private _generateHemisphere;
  55313. private _createSSAOPostProcess;
  55314. private _createSSAOCombinePostProcess;
  55315. private _createRandomTexture;
  55316. /**
  55317. * Serialize the rendering pipeline (Used when exporting)
  55318. * @returns the serialized object
  55319. */
  55320. serialize(): any;
  55321. /**
  55322. * Parse the serialized pipeline
  55323. * @param source Source pipeline.
  55324. * @param scene The scene to load the pipeline to.
  55325. * @param rootUrl The URL of the serialized pipeline.
  55326. * @returns An instantiated pipeline from the serialized object.
  55327. */
  55328. static Parse(source: any, scene: Scene, rootUrl: string): SSAO2RenderingPipeline;
  55329. }
  55330. }
  55331. declare module "babylonjs/Shaders/ssao.fragment" {
  55332. /** @hidden */
  55333. export var ssaoPixelShader: {
  55334. name: string;
  55335. shader: string;
  55336. };
  55337. }
  55338. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/ssaoRenderingPipeline" {
  55339. import { Camera } from "babylonjs/Cameras/camera";
  55340. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  55341. import { Scene } from "babylonjs/scene";
  55342. import "babylonjs/Shaders/ssao.fragment";
  55343. import "babylonjs/Shaders/ssaoCombine.fragment";
  55344. /**
  55345. * Render pipeline to produce ssao effect
  55346. */
  55347. export class SSAORenderingPipeline extends PostProcessRenderPipeline {
  55348. /**
  55349. * @ignore
  55350. * The PassPostProcess id in the pipeline that contains the original scene color
  55351. */
  55352. SSAOOriginalSceneColorEffect: string;
  55353. /**
  55354. * @ignore
  55355. * The SSAO PostProcess id in the pipeline
  55356. */
  55357. SSAORenderEffect: string;
  55358. /**
  55359. * @ignore
  55360. * The horizontal blur PostProcess id in the pipeline
  55361. */
  55362. SSAOBlurHRenderEffect: string;
  55363. /**
  55364. * @ignore
  55365. * The vertical blur PostProcess id in the pipeline
  55366. */
  55367. SSAOBlurVRenderEffect: string;
  55368. /**
  55369. * @ignore
  55370. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  55371. */
  55372. SSAOCombineRenderEffect: string;
  55373. /**
  55374. * The output strength of the SSAO post-process. Default value is 1.0.
  55375. */
  55376. totalStrength: number;
  55377. /**
  55378. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 0.0006
  55379. */
  55380. radius: number;
  55381. /**
  55382. * Related to fallOff, used to interpolate SSAO samples (first interpolate function input) based on the occlusion difference of each pixel
  55383. * Must not be equal to fallOff and superior to fallOff.
  55384. * Default value is 0.0075
  55385. */
  55386. area: number;
  55387. /**
  55388. * Related to area, used to interpolate SSAO samples (second interpolate function input) based on the occlusion difference of each pixel
  55389. * Must not be equal to area and inferior to area.
  55390. * Default value is 0.000001
  55391. */
  55392. fallOff: number;
  55393. /**
  55394. * The base color of the SSAO post-process
  55395. * The final result is "base + ssao" between [0, 1]
  55396. */
  55397. base: number;
  55398. private _scene;
  55399. private _depthTexture;
  55400. private _randomTexture;
  55401. private _originalColorPostProcess;
  55402. private _ssaoPostProcess;
  55403. private _blurHPostProcess;
  55404. private _blurVPostProcess;
  55405. private _ssaoCombinePostProcess;
  55406. private _firstUpdate;
  55407. /**
  55408. * Gets active scene
  55409. */
  55410. readonly scene: Scene;
  55411. /**
  55412. * @constructor
  55413. * @param name - The rendering pipeline name
  55414. * @param scene - The scene linked to this pipeline
  55415. * @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 }
  55416. * @param cameras - The array of cameras that the rendering pipeline will be attached to
  55417. */
  55418. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[]);
  55419. /**
  55420. * Get the class name
  55421. * @returns "SSAORenderingPipeline"
  55422. */
  55423. getClassName(): string;
  55424. /**
  55425. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  55426. */
  55427. dispose(disableDepthRender?: boolean): void;
  55428. private _createBlurPostProcess;
  55429. /** @hidden */
  55430. _rebuild(): void;
  55431. private _createSSAOPostProcess;
  55432. private _createSSAOCombinePostProcess;
  55433. private _createRandomTexture;
  55434. }
  55435. }
  55436. declare module "babylonjs/Shaders/standard.fragment" {
  55437. /** @hidden */
  55438. export var standardPixelShader: {
  55439. name: string;
  55440. shader: string;
  55441. };
  55442. }
  55443. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/standardRenderingPipeline" {
  55444. import { Nullable } from "babylonjs/types";
  55445. import { IAnimatable } from "babylonjs/Misc/tools";
  55446. import { Camera } from "babylonjs/Cameras/camera";
  55447. import { Texture } from "babylonjs/Materials/Textures/texture";
  55448. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  55449. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  55450. import { BlurPostProcess } from "babylonjs/PostProcesses/blurPostProcess";
  55451. import { FxaaPostProcess } from "babylonjs/PostProcesses/fxaaPostProcess";
  55452. import { IDisposable } from "babylonjs/scene";
  55453. import { SpotLight } from "babylonjs/Lights/spotLight";
  55454. import { DirectionalLight } from "babylonjs/Lights/directionalLight";
  55455. import { Scene } from "babylonjs/scene";
  55456. import { Animation } from "babylonjs/Animations/animation";
  55457. import "babylonjs/Shaders/standard.fragment";
  55458. /**
  55459. * Standard rendering pipeline
  55460. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  55461. * @see https://doc.babylonjs.com/how_to/using_standard_rendering_pipeline
  55462. */
  55463. export class StandardRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  55464. /**
  55465. * Public members
  55466. */
  55467. /**
  55468. * Post-process which contains the original scene color before the pipeline applies all the effects
  55469. */
  55470. originalPostProcess: Nullable<PostProcess>;
  55471. /**
  55472. * Post-process used to down scale an image x4
  55473. */
  55474. downSampleX4PostProcess: Nullable<PostProcess>;
  55475. /**
  55476. * Post-process used to calculate the illuminated surfaces controlled by a threshold
  55477. */
  55478. brightPassPostProcess: Nullable<PostProcess>;
  55479. /**
  55480. * Post-process array storing all the horizontal blur post-processes used by the pipeline
  55481. */
  55482. blurHPostProcesses: PostProcess[];
  55483. /**
  55484. * Post-process array storing all the vertical blur post-processes used by the pipeline
  55485. */
  55486. blurVPostProcesses: PostProcess[];
  55487. /**
  55488. * Post-process used to add colors of 2 textures (typically brightness + real scene color)
  55489. */
  55490. textureAdderPostProcess: Nullable<PostProcess>;
  55491. /**
  55492. * Post-process used to create volumetric lighting effect
  55493. */
  55494. volumetricLightPostProcess: Nullable<PostProcess>;
  55495. /**
  55496. * Post-process used to smooth the previous volumetric light post-process on the X axis
  55497. */
  55498. volumetricLightSmoothXPostProcess: Nullable<BlurPostProcess>;
  55499. /**
  55500. * Post-process used to smooth the previous volumetric light post-process on the Y axis
  55501. */
  55502. volumetricLightSmoothYPostProcess: Nullable<BlurPostProcess>;
  55503. /**
  55504. * Post-process used to merge the volumetric light effect and the real scene color
  55505. */
  55506. volumetricLightMergePostProces: Nullable<PostProcess>;
  55507. /**
  55508. * Post-process used to store the final volumetric light post-process (attach/detach for debug purpose)
  55509. */
  55510. volumetricLightFinalPostProcess: Nullable<PostProcess>;
  55511. /**
  55512. * Base post-process used to calculate the average luminance of the final image for HDR
  55513. */
  55514. luminancePostProcess: Nullable<PostProcess>;
  55515. /**
  55516. * Post-processes used to create down sample post-processes in order to get
  55517. * the average luminance of the final image for HDR
  55518. * Array of length "StandardRenderingPipeline.LuminanceSteps"
  55519. */
  55520. luminanceDownSamplePostProcesses: PostProcess[];
  55521. /**
  55522. * Post-process used to create a HDR effect (light adaptation)
  55523. */
  55524. hdrPostProcess: Nullable<PostProcess>;
  55525. /**
  55526. * Post-process used to store the final texture adder post-process (attach/detach for debug purpose)
  55527. */
  55528. textureAdderFinalPostProcess: Nullable<PostProcess>;
  55529. /**
  55530. * Post-process used to store the final lens flare post-process (attach/detach for debug purpose)
  55531. */
  55532. lensFlareFinalPostProcess: Nullable<PostProcess>;
  55533. /**
  55534. * Post-process used to merge the final HDR post-process and the real scene color
  55535. */
  55536. hdrFinalPostProcess: Nullable<PostProcess>;
  55537. /**
  55538. * Post-process used to create a lens flare effect
  55539. */
  55540. lensFlarePostProcess: Nullable<PostProcess>;
  55541. /**
  55542. * Post-process that merges the result of the lens flare post-process and the real scene color
  55543. */
  55544. lensFlareComposePostProcess: Nullable<PostProcess>;
  55545. /**
  55546. * Post-process used to create a motion blur effect
  55547. */
  55548. motionBlurPostProcess: Nullable<PostProcess>;
  55549. /**
  55550. * Post-process used to create a depth of field effect
  55551. */
  55552. depthOfFieldPostProcess: Nullable<PostProcess>;
  55553. /**
  55554. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  55555. */
  55556. fxaaPostProcess: Nullable<FxaaPostProcess>;
  55557. /**
  55558. * Represents the brightness threshold in order to configure the illuminated surfaces
  55559. */
  55560. brightThreshold: number;
  55561. /**
  55562. * Configures the blur intensity used for surexposed surfaces are highlighted surfaces (light halo)
  55563. */
  55564. blurWidth: number;
  55565. /**
  55566. * Sets if the blur for highlighted surfaces must be only horizontal
  55567. */
  55568. horizontalBlur: boolean;
  55569. /**
  55570. * Sets the overall exposure used by the pipeline
  55571. */
  55572. exposure: number;
  55573. /**
  55574. * Texture used typically to simulate "dirty" on camera lens
  55575. */
  55576. lensTexture: Nullable<Texture>;
  55577. /**
  55578. * Represents the offset coefficient based on Rayleigh principle. Typically in interval [-0.2, 0.2]
  55579. */
  55580. volumetricLightCoefficient: number;
  55581. /**
  55582. * The overall power of volumetric lights, typically in interval [0, 10] maximum
  55583. */
  55584. volumetricLightPower: number;
  55585. /**
  55586. * Used the set the blur intensity to smooth the volumetric lights
  55587. */
  55588. volumetricLightBlurScale: number;
  55589. /**
  55590. * Light (spot or directional) used to generate the volumetric lights rays
  55591. * The source light must have a shadow generate so the pipeline can get its
  55592. * depth map
  55593. */
  55594. sourceLight: Nullable<SpotLight | DirectionalLight>;
  55595. /**
  55596. * For eye adaptation, represents the minimum luminance the eye can see
  55597. */
  55598. hdrMinimumLuminance: number;
  55599. /**
  55600. * For eye adaptation, represents the decrease luminance speed
  55601. */
  55602. hdrDecreaseRate: number;
  55603. /**
  55604. * For eye adaptation, represents the increase luminance speed
  55605. */
  55606. hdrIncreaseRate: number;
  55607. /**
  55608. * Lens color texture used by the lens flare effect. Mandatory if lens flare effect enabled
  55609. */
  55610. lensColorTexture: Nullable<Texture>;
  55611. /**
  55612. * The overall strengh for the lens flare effect
  55613. */
  55614. lensFlareStrength: number;
  55615. /**
  55616. * Dispersion coefficient for lens flare ghosts
  55617. */
  55618. lensFlareGhostDispersal: number;
  55619. /**
  55620. * Main lens flare halo width
  55621. */
  55622. lensFlareHaloWidth: number;
  55623. /**
  55624. * Based on the lens distortion effect, defines how much the lens flare result
  55625. * is distorted
  55626. */
  55627. lensFlareDistortionStrength: number;
  55628. /**
  55629. * Lens star texture must be used to simulate rays on the flares and is available
  55630. * in the documentation
  55631. */
  55632. lensStarTexture: Nullable<Texture>;
  55633. /**
  55634. * As the "lensTexture" (can be the same texture or different), it is used to apply the lens
  55635. * flare effect by taking account of the dirt texture
  55636. */
  55637. lensFlareDirtTexture: Nullable<Texture>;
  55638. /**
  55639. * Represents the focal length for the depth of field effect
  55640. */
  55641. depthOfFieldDistance: number;
  55642. /**
  55643. * Represents the blur intensity for the blurred part of the depth of field effect
  55644. */
  55645. depthOfFieldBlurWidth: number;
  55646. /**
  55647. * For motion blur, defines how much the image is blurred by the movement
  55648. */
  55649. motionStrength: number;
  55650. /**
  55651. * List of animations for the pipeline (IAnimatable implementation)
  55652. */
  55653. animations: Animation[];
  55654. /**
  55655. * Private members
  55656. */
  55657. private _scene;
  55658. private _currentDepthOfFieldSource;
  55659. private _basePostProcess;
  55660. private _hdrCurrentLuminance;
  55661. private _floatTextureType;
  55662. private _ratio;
  55663. private _bloomEnabled;
  55664. private _depthOfFieldEnabled;
  55665. private _vlsEnabled;
  55666. private _lensFlareEnabled;
  55667. private _hdrEnabled;
  55668. private _motionBlurEnabled;
  55669. private _fxaaEnabled;
  55670. private _motionBlurSamples;
  55671. private _volumetricLightStepsCount;
  55672. private _samples;
  55673. /**
  55674. * @ignore
  55675. * Specifies if the bloom pipeline is enabled
  55676. */
  55677. BloomEnabled: boolean;
  55678. /**
  55679. * @ignore
  55680. * Specifies if the depth of field pipeline is enabed
  55681. */
  55682. DepthOfFieldEnabled: boolean;
  55683. /**
  55684. * @ignore
  55685. * Specifies if the lens flare pipeline is enabed
  55686. */
  55687. LensFlareEnabled: boolean;
  55688. /**
  55689. * @ignore
  55690. * Specifies if the HDR pipeline is enabled
  55691. */
  55692. HDREnabled: boolean;
  55693. /**
  55694. * @ignore
  55695. * Specifies if the volumetric lights scattering effect is enabled
  55696. */
  55697. VLSEnabled: boolean;
  55698. /**
  55699. * @ignore
  55700. * Specifies if the motion blur effect is enabled
  55701. */
  55702. MotionBlurEnabled: boolean;
  55703. /**
  55704. * Specifies if anti-aliasing is enabled
  55705. */
  55706. fxaaEnabled: boolean;
  55707. /**
  55708. * Specifies the number of steps used to calculate the volumetric lights
  55709. * Typically in interval [50, 200]
  55710. */
  55711. volumetricLightStepsCount: number;
  55712. /**
  55713. * Specifies the number of samples used for the motion blur effect
  55714. * Typically in interval [16, 64]
  55715. */
  55716. motionBlurSamples: number;
  55717. /**
  55718. * Specifies MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  55719. */
  55720. samples: number;
  55721. /**
  55722. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  55723. * @constructor
  55724. * @param name The rendering pipeline name
  55725. * @param scene The scene linked to this pipeline
  55726. * @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)
  55727. * @param originalPostProcess the custom original color post-process. Must be "reusable". Can be null.
  55728. * @param cameras The array of cameras that the rendering pipeline will be attached to
  55729. */
  55730. constructor(name: string, scene: Scene, ratio: number, originalPostProcess?: Nullable<PostProcess>, cameras?: Camera[]);
  55731. private _buildPipeline;
  55732. private _createDownSampleX4PostProcess;
  55733. private _createBrightPassPostProcess;
  55734. private _createBlurPostProcesses;
  55735. private _createTextureAdderPostProcess;
  55736. private _createVolumetricLightPostProcess;
  55737. private _createLuminancePostProcesses;
  55738. private _createHdrPostProcess;
  55739. private _createLensFlarePostProcess;
  55740. private _createDepthOfFieldPostProcess;
  55741. private _createMotionBlurPostProcess;
  55742. private _getDepthTexture;
  55743. private _disposePostProcesses;
  55744. /**
  55745. * Dispose of the pipeline and stop all post processes
  55746. */
  55747. dispose(): void;
  55748. /**
  55749. * Serialize the rendering pipeline (Used when exporting)
  55750. * @returns the serialized object
  55751. */
  55752. serialize(): any;
  55753. /**
  55754. * Parse the serialized pipeline
  55755. * @param source Source pipeline.
  55756. * @param scene The scene to load the pipeline to.
  55757. * @param rootUrl The URL of the serialized pipeline.
  55758. * @returns An instantiated pipeline from the serialized object.
  55759. */
  55760. static Parse(source: any, scene: Scene, rootUrl: string): StandardRenderingPipeline;
  55761. /**
  55762. * Luminance steps
  55763. */
  55764. static LuminanceSteps: number;
  55765. }
  55766. }
  55767. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/index" {
  55768. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/defaultRenderingPipeline";
  55769. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/lensRenderingPipeline";
  55770. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/ssao2RenderingPipeline";
  55771. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/ssaoRenderingPipeline";
  55772. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/standardRenderingPipeline";
  55773. }
  55774. declare module "babylonjs/PostProcesses/RenderPipeline/index" {
  55775. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/index";
  55776. export * from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderEffect";
  55777. export * from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  55778. export * from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManager";
  55779. export * from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent";
  55780. }
  55781. declare module "babylonjs/Shaders/tonemap.fragment" {
  55782. /** @hidden */
  55783. export var tonemapPixelShader: {
  55784. name: string;
  55785. shader: string;
  55786. };
  55787. }
  55788. declare module "babylonjs/PostProcesses/tonemapPostProcess" {
  55789. import { Camera } from "babylonjs/Cameras/camera";
  55790. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  55791. import "babylonjs/Shaders/tonemap.fragment";
  55792. import { Engine } from "babylonjs/Engines/engine";
  55793. /** Defines operator used for tonemapping */
  55794. export enum TonemappingOperator {
  55795. /** Hable */
  55796. Hable = 0,
  55797. /** Reinhard */
  55798. Reinhard = 1,
  55799. /** HejiDawson */
  55800. HejiDawson = 2,
  55801. /** Photographic */
  55802. Photographic = 3
  55803. }
  55804. /**
  55805. * Defines a post process to apply tone mapping
  55806. */
  55807. export class TonemapPostProcess extends PostProcess {
  55808. private _operator;
  55809. /** Defines the required exposure adjustement */
  55810. exposureAdjustment: number;
  55811. /**
  55812. * Creates a new TonemapPostProcess
  55813. * @param name defines the name of the postprocess
  55814. * @param _operator defines the operator to use
  55815. * @param exposureAdjustment defines the required exposure adjustement
  55816. * @param camera defines the camera to use (can be null)
  55817. * @param samplingMode defines the required sampling mode (BABYLON.Texture.BILINEAR_SAMPLINGMODE by default)
  55818. * @param engine defines the hosting engine (can be ignore if camera is set)
  55819. * @param textureFormat defines the texture format to use (BABYLON.Engine.TEXTURETYPE_UNSIGNED_INT by default)
  55820. */
  55821. constructor(name: string, _operator: TonemappingOperator,
  55822. /** Defines the required exposure adjustement */
  55823. exposureAdjustment: number, camera: Camera, samplingMode?: number, engine?: Engine, textureFormat?: number);
  55824. }
  55825. }
  55826. declare module "babylonjs/Shaders/depth.vertex" {
  55827. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  55828. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  55829. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  55830. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  55831. /** @hidden */
  55832. export var depthVertexShader: {
  55833. name: string;
  55834. shader: string;
  55835. };
  55836. }
  55837. declare module "babylonjs/Shaders/volumetricLightScattering.fragment" {
  55838. /** @hidden */
  55839. export var volumetricLightScatteringPixelShader: {
  55840. name: string;
  55841. shader: string;
  55842. };
  55843. }
  55844. declare module "babylonjs/Shaders/volumetricLightScatteringPass.fragment" {
  55845. /** @hidden */
  55846. export var volumetricLightScatteringPassPixelShader: {
  55847. name: string;
  55848. shader: string;
  55849. };
  55850. }
  55851. declare module "babylonjs/PostProcesses/volumetricLightScatteringPostProcess" {
  55852. import { Vector3 } from "babylonjs/Maths/math";
  55853. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  55854. import { Mesh } from "babylonjs/Meshes/mesh";
  55855. import { Camera } from "babylonjs/Cameras/camera";
  55856. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  55857. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  55858. import { Scene } from "babylonjs/scene";
  55859. import "babylonjs/Meshes/Builders/planeBuilder";
  55860. import "babylonjs/Shaders/depth.vertex";
  55861. import "babylonjs/Shaders/volumetricLightScattering.fragment";
  55862. import "babylonjs/Shaders/volumetricLightScatteringPass.fragment";
  55863. import { Engine } from "babylonjs/Engines/engine";
  55864. /**
  55865. * Inspired by http://http.developer.nvidia.com/GPUGems3/gpugems3_ch13.html
  55866. */
  55867. export class VolumetricLightScatteringPostProcess extends PostProcess {
  55868. private _volumetricLightScatteringPass;
  55869. private _volumetricLightScatteringRTT;
  55870. private _viewPort;
  55871. private _screenCoordinates;
  55872. private _cachedDefines;
  55873. /**
  55874. * If not undefined, the mesh position is computed from the attached node position
  55875. */
  55876. attachedNode: {
  55877. position: Vector3;
  55878. };
  55879. /**
  55880. * Custom position of the mesh. Used if "useCustomMeshPosition" is set to "true"
  55881. */
  55882. customMeshPosition: Vector3;
  55883. /**
  55884. * Set if the post-process should use a custom position for the light source (true) or the internal mesh position (false)
  55885. */
  55886. useCustomMeshPosition: boolean;
  55887. /**
  55888. * If the post-process should inverse the light scattering direction
  55889. */
  55890. invert: boolean;
  55891. /**
  55892. * The internal mesh used by the post-process
  55893. */
  55894. mesh: Mesh;
  55895. /**
  55896. * @hidden
  55897. * VolumetricLightScatteringPostProcess.useDiffuseColor is no longer used, use the mesh material directly instead
  55898. */
  55899. useDiffuseColor: boolean;
  55900. /**
  55901. * Array containing the excluded meshes not rendered in the internal pass
  55902. */
  55903. excludedMeshes: AbstractMesh[];
  55904. /**
  55905. * Controls the overall intensity of the post-process
  55906. */
  55907. exposure: number;
  55908. /**
  55909. * Dissipates each sample's contribution in range [0, 1]
  55910. */
  55911. decay: number;
  55912. /**
  55913. * Controls the overall intensity of each sample
  55914. */
  55915. weight: number;
  55916. /**
  55917. * Controls the density of each sample
  55918. */
  55919. density: number;
  55920. /**
  55921. * @constructor
  55922. * @param name The post-process name
  55923. * @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)
  55924. * @param camera The camera that the post-process will be attached to
  55925. * @param mesh The mesh used to create the light scattering
  55926. * @param samples The post-process quality, default 100
  55927. * @param samplingModeThe post-process filtering mode
  55928. * @param engine The babylon engine
  55929. * @param reusable If the post-process is reusable
  55930. * @param scene The constructor needs a scene reference to initialize internal components. If "camera" is null a "scene" must be provided
  55931. */
  55932. constructor(name: string, ratio: any, camera: Camera, mesh?: Mesh, samples?: number, samplingMode?: number, engine?: Engine, reusable?: boolean, scene?: Scene);
  55933. /**
  55934. * Returns the string "VolumetricLightScatteringPostProcess"
  55935. * @returns "VolumetricLightScatteringPostProcess"
  55936. */
  55937. getClassName(): string;
  55938. private _isReady;
  55939. /**
  55940. * Sets the new light position for light scattering effect
  55941. * @param position The new custom light position
  55942. */
  55943. setCustomMeshPosition(position: Vector3): void;
  55944. /**
  55945. * Returns the light position for light scattering effect
  55946. * @return Vector3 The custom light position
  55947. */
  55948. getCustomMeshPosition(): Vector3;
  55949. /**
  55950. * Disposes the internal assets and detaches the post-process from the camera
  55951. */
  55952. dispose(camera: Camera): void;
  55953. /**
  55954. * Returns the render target texture used by the post-process
  55955. * @return the render target texture used by the post-process
  55956. */
  55957. getPass(): RenderTargetTexture;
  55958. private _meshExcluded;
  55959. private _createPass;
  55960. private _updateMeshScreenCoordinates;
  55961. /**
  55962. * Creates a default mesh for the Volumeric Light Scattering post-process
  55963. * @param name The mesh name
  55964. * @param scene The scene where to create the mesh
  55965. * @return the default mesh
  55966. */
  55967. static CreateDefaultMesh(name: string, scene: Scene): Mesh;
  55968. }
  55969. }
  55970. declare module "babylonjs/PostProcesses/index" {
  55971. export * from "babylonjs/PostProcesses/anaglyphPostProcess";
  55972. export * from "babylonjs/PostProcesses/blackAndWhitePostProcess";
  55973. export * from "babylonjs/PostProcesses/bloomEffect";
  55974. export * from "babylonjs/PostProcesses/bloomMergePostProcess";
  55975. export * from "babylonjs/PostProcesses/blurPostProcess";
  55976. export * from "babylonjs/PostProcesses/chromaticAberrationPostProcess";
  55977. export * from "babylonjs/PostProcesses/circleOfConfusionPostProcess";
  55978. export * from "babylonjs/PostProcesses/colorCorrectionPostProcess";
  55979. export * from "babylonjs/PostProcesses/convolutionPostProcess";
  55980. export * from "babylonjs/PostProcesses/depthOfFieldBlurPostProcess";
  55981. export * from "babylonjs/PostProcesses/depthOfFieldEffect";
  55982. export * from "babylonjs/PostProcesses/depthOfFieldMergePostProcess";
  55983. export * from "babylonjs/PostProcesses/displayPassPostProcess";
  55984. export * from "babylonjs/PostProcesses/extractHighlightsPostProcess";
  55985. export * from "babylonjs/PostProcesses/filterPostProcess";
  55986. export * from "babylonjs/PostProcesses/fxaaPostProcess";
  55987. export * from "babylonjs/PostProcesses/grainPostProcess";
  55988. export * from "babylonjs/PostProcesses/highlightsPostProcess";
  55989. export * from "babylonjs/PostProcesses/imageProcessingPostProcess";
  55990. export * from "babylonjs/PostProcesses/motionBlurPostProcess";
  55991. export * from "babylonjs/PostProcesses/passPostProcess";
  55992. export * from "babylonjs/PostProcesses/postProcess";
  55993. export * from "babylonjs/PostProcesses/postProcessManager";
  55994. export * from "babylonjs/PostProcesses/refractionPostProcess";
  55995. export * from "babylonjs/PostProcesses/RenderPipeline/index";
  55996. export * from "babylonjs/PostProcesses/sharpenPostProcess";
  55997. export * from "babylonjs/PostProcesses/stereoscopicInterlacePostProcess";
  55998. export * from "babylonjs/PostProcesses/tonemapPostProcess";
  55999. export * from "babylonjs/PostProcesses/volumetricLightScatteringPostProcess";
  56000. export * from "babylonjs/PostProcesses/vrDistortionCorrectionPostProcess";
  56001. }
  56002. declare module "babylonjs/Probes/index" {
  56003. export * from "babylonjs/Probes/reflectionProbe";
  56004. }
  56005. declare module "babylonjs/Rendering/boundingBoxRenderer" {
  56006. import { Scene } from "babylonjs/scene";
  56007. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  56008. import { Color3 } from "babylonjs/Maths/math";
  56009. import { SmartArray } from "babylonjs/Misc/smartArray";
  56010. import { ISceneComponent } from "babylonjs/sceneComponent";
  56011. import { BoundingBox } from "babylonjs/Culling/boundingBox";
  56012. import "babylonjs/Meshes/Builders/boxBuilder";
  56013. import "babylonjs/Shaders/color.fragment";
  56014. import "babylonjs/Shaders/color.vertex";
  56015. module "babylonjs/scene" {
  56016. interface Scene {
  56017. /** @hidden (Backing field) */
  56018. _boundingBoxRenderer: BoundingBoxRenderer;
  56019. /** @hidden (Backing field) */
  56020. _forceShowBoundingBoxes: boolean;
  56021. /**
  56022. * Gets or sets a boolean indicating if all bounding boxes must be rendered
  56023. */
  56024. forceShowBoundingBoxes: boolean;
  56025. /**
  56026. * Gets the bounding box renderer associated with the scene
  56027. * @returns a BoundingBoxRenderer
  56028. */
  56029. getBoundingBoxRenderer(): BoundingBoxRenderer;
  56030. }
  56031. }
  56032. module "babylonjs/Meshes/abstractMesh" {
  56033. interface AbstractMesh {
  56034. /** @hidden (Backing field) */
  56035. _showBoundingBox: boolean;
  56036. /**
  56037. * Gets or sets a boolean indicating if the bounding box must be rendered as well (false by default)
  56038. */
  56039. showBoundingBox: boolean;
  56040. }
  56041. }
  56042. /**
  56043. * Component responsible of rendering the bounding box of the meshes in a scene.
  56044. * This is usually used through the mesh.showBoundingBox or the scene.forceShowBoundingBoxes properties
  56045. */
  56046. export class BoundingBoxRenderer implements ISceneComponent {
  56047. /**
  56048. * The component name helpfull to identify the component in the list of scene components.
  56049. */
  56050. readonly name: string;
  56051. /**
  56052. * The scene the component belongs to.
  56053. */
  56054. scene: Scene;
  56055. /**
  56056. * Color of the bounding box lines placed in front of an object
  56057. */
  56058. frontColor: Color3;
  56059. /**
  56060. * Color of the bounding box lines placed behind an object
  56061. */
  56062. backColor: Color3;
  56063. /**
  56064. * Defines if the renderer should show the back lines or not
  56065. */
  56066. showBackLines: boolean;
  56067. /**
  56068. * @hidden
  56069. */
  56070. renderList: SmartArray<BoundingBox>;
  56071. private _colorShader;
  56072. private _vertexBuffers;
  56073. private _indexBuffer;
  56074. /**
  56075. * Instantiates a new bounding box renderer in a scene.
  56076. * @param scene the scene the renderer renders in
  56077. */
  56078. constructor(scene: Scene);
  56079. /**
  56080. * Registers the component in a given scene
  56081. */
  56082. register(): void;
  56083. private _evaluateSubMesh;
  56084. private _activeMesh;
  56085. private _prepareRessources;
  56086. private _createIndexBuffer;
  56087. /**
  56088. * Rebuilds the elements related to this component in case of
  56089. * context lost for instance.
  56090. */
  56091. rebuild(): void;
  56092. /**
  56093. * @hidden
  56094. */
  56095. reset(): void;
  56096. /**
  56097. * Render the bounding boxes of a specific rendering group
  56098. * @param renderingGroupId defines the rendering group to render
  56099. */
  56100. render(renderingGroupId: number): void;
  56101. /**
  56102. * In case of occlusion queries, we can render the occlusion bounding box through this method
  56103. * @param mesh Define the mesh to render the occlusion bounding box for
  56104. */
  56105. renderOcclusionBoundingBox(mesh: AbstractMesh): void;
  56106. /**
  56107. * Dispose and release the resources attached to this renderer.
  56108. */
  56109. dispose(): void;
  56110. }
  56111. }
  56112. declare module "babylonjs/Shaders/depth.fragment" {
  56113. /** @hidden */
  56114. export var depthPixelShader: {
  56115. name: string;
  56116. shader: string;
  56117. };
  56118. }
  56119. declare module "babylonjs/Rendering/depthRenderer" {
  56120. import { Nullable } from "babylonjs/types";
  56121. import { SubMesh } from "babylonjs/Meshes/subMesh";
  56122. import { Scene } from "babylonjs/scene";
  56123. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  56124. import { Camera } from "babylonjs/Cameras/camera";
  56125. import "babylonjs/Shaders/depth.fragment";
  56126. import "babylonjs/Shaders/depth.vertex";
  56127. /**
  56128. * This represents a depth renderer in Babylon.
  56129. * A depth renderer will render to it's depth map every frame which can be displayed or used in post processing
  56130. */
  56131. export class DepthRenderer {
  56132. private _scene;
  56133. private _depthMap;
  56134. private _effect;
  56135. private _cachedDefines;
  56136. private _camera;
  56137. /**
  56138. * Specifiess that the depth renderer will only be used within
  56139. * the camera it is created for.
  56140. * This can help forcing its rendering during the camera processing.
  56141. */
  56142. useOnlyInActiveCamera: boolean;
  56143. /** @hidden */
  56144. static _SceneComponentInitialization: (scene: Scene) => void;
  56145. /**
  56146. * Instantiates a depth renderer
  56147. * @param scene The scene the renderer belongs to
  56148. * @param type The texture type of the depth map (default: Engine.TEXTURETYPE_FLOAT)
  56149. * @param camera The camera to be used to render the depth map (default: scene's active camera)
  56150. */
  56151. constructor(scene: Scene, type?: number, camera?: Nullable<Camera>);
  56152. /**
  56153. * Creates the depth rendering effect and checks if the effect is ready.
  56154. * @param subMesh The submesh to be used to render the depth map of
  56155. * @param useInstances If multiple world instances should be used
  56156. * @returns if the depth renderer is ready to render the depth map
  56157. */
  56158. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  56159. /**
  56160. * Gets the texture which the depth map will be written to.
  56161. * @returns The depth map texture
  56162. */
  56163. getDepthMap(): RenderTargetTexture;
  56164. /**
  56165. * Disposes of the depth renderer.
  56166. */
  56167. dispose(): void;
  56168. }
  56169. }
  56170. declare module "babylonjs/Rendering/depthRendererSceneComponent" {
  56171. import { Nullable } from "babylonjs/types";
  56172. import { Scene } from "babylonjs/scene";
  56173. import { DepthRenderer } from "babylonjs/Rendering/depthRenderer";
  56174. import { Camera } from "babylonjs/Cameras/camera";
  56175. import { ISceneComponent } from "babylonjs/sceneComponent";
  56176. module "babylonjs/scene" {
  56177. interface Scene {
  56178. /** @hidden (Backing field) */
  56179. _depthRenderer: {
  56180. [id: string]: DepthRenderer;
  56181. };
  56182. /**
  56183. * Creates a depth renderer a given camera which contains a depth map which can be used for post processing.
  56184. * @param camera The camera to create the depth renderer on (default: scene's active camera)
  56185. * @returns the created depth renderer
  56186. */
  56187. enableDepthRenderer(camera?: Nullable<Camera>): DepthRenderer;
  56188. /**
  56189. * Disables a depth renderer for a given camera
  56190. * @param camera The camera to disable the depth renderer on (default: scene's active camera)
  56191. */
  56192. disableDepthRenderer(camera?: Nullable<Camera>): void;
  56193. }
  56194. }
  56195. /**
  56196. * Defines the Depth Renderer scene component responsible to manage a depth buffer useful
  56197. * in several rendering techniques.
  56198. */
  56199. export class DepthRendererSceneComponent implements ISceneComponent {
  56200. /**
  56201. * The component name helpfull to identify the component in the list of scene components.
  56202. */
  56203. readonly name: string;
  56204. /**
  56205. * The scene the component belongs to.
  56206. */
  56207. scene: Scene;
  56208. /**
  56209. * Creates a new instance of the component for the given scene
  56210. * @param scene Defines the scene to register the component in
  56211. */
  56212. constructor(scene: Scene);
  56213. /**
  56214. * Registers the component in a given scene
  56215. */
  56216. register(): void;
  56217. /**
  56218. * Rebuilds the elements related to this component in case of
  56219. * context lost for instance.
  56220. */
  56221. rebuild(): void;
  56222. /**
  56223. * Disposes the component and the associated ressources
  56224. */
  56225. dispose(): void;
  56226. private _gatherRenderTargets;
  56227. private _gatherActiveCameraRenderTargets;
  56228. }
  56229. }
  56230. declare module "babylonjs/Shaders/outline.fragment" {
  56231. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  56232. import "babylonjs/Shaders/ShadersInclude/logDepthFragment";
  56233. /** @hidden */
  56234. export var outlinePixelShader: {
  56235. name: string;
  56236. shader: string;
  56237. };
  56238. }
  56239. declare module "babylonjs/Shaders/outline.vertex" {
  56240. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  56241. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  56242. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  56243. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  56244. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  56245. import "babylonjs/Shaders/ShadersInclude/logDepthVertex";
  56246. /** @hidden */
  56247. export var outlineVertexShader: {
  56248. name: string;
  56249. shader: string;
  56250. };
  56251. }
  56252. declare module "babylonjs/Rendering/outlineRenderer" {
  56253. import { SubMesh } from "babylonjs/Meshes/subMesh";
  56254. import { _InstancesBatch } from "babylonjs/Meshes/mesh";
  56255. import { Scene } from "babylonjs/scene";
  56256. import { ISceneComponent } from "babylonjs/sceneComponent";
  56257. import "babylonjs/Shaders/outline.fragment";
  56258. import "babylonjs/Shaders/outline.vertex";
  56259. module "babylonjs/scene" {
  56260. interface Scene {
  56261. /** @hidden */
  56262. _outlineRenderer: OutlineRenderer;
  56263. /**
  56264. * Gets the outline renderer associated with the scene
  56265. * @returns a OutlineRenderer
  56266. */
  56267. getOutlineRenderer(): OutlineRenderer;
  56268. }
  56269. }
  56270. module "babylonjs/Meshes/abstractMesh" {
  56271. interface AbstractMesh {
  56272. /** @hidden (Backing field) */
  56273. _renderOutline: boolean;
  56274. /**
  56275. * Gets or sets a boolean indicating if the outline must be rendered as well
  56276. * @see https://www.babylonjs-playground.com/#10WJ5S#3
  56277. */
  56278. renderOutline: boolean;
  56279. /** @hidden (Backing field) */
  56280. _renderOverlay: boolean;
  56281. /**
  56282. * Gets or sets a boolean indicating if the overlay must be rendered as well
  56283. * @see https://www.babylonjs-playground.com/#10WJ5S#2
  56284. */
  56285. renderOverlay: boolean;
  56286. }
  56287. }
  56288. /**
  56289. * This class is responsible to draw bothe outline/overlay of meshes.
  56290. * It should not be used directly but through the available method on mesh.
  56291. */
  56292. export class OutlineRenderer implements ISceneComponent {
  56293. /**
  56294. * Stencil value used to avoid outline being seen within the mesh when the mesh is transparent
  56295. */
  56296. private static _StencilReference;
  56297. /**
  56298. * The name of the component. Each component must have a unique name.
  56299. */
  56300. name: string;
  56301. /**
  56302. * The scene the component belongs to.
  56303. */
  56304. scene: Scene;
  56305. /**
  56306. * Defines a zOffset to prevent zFighting between the overlay and the mesh.
  56307. */
  56308. zOffset: number;
  56309. private _engine;
  56310. private _effect;
  56311. private _cachedDefines;
  56312. private _savedDepthWrite;
  56313. /**
  56314. * Instantiates a new outline renderer. (There could be only one per scene).
  56315. * @param scene Defines the scene it belongs to
  56316. */
  56317. constructor(scene: Scene);
  56318. /**
  56319. * Register the component to one instance of a scene.
  56320. */
  56321. register(): void;
  56322. /**
  56323. * Rebuilds the elements related to this component in case of
  56324. * context lost for instance.
  56325. */
  56326. rebuild(): void;
  56327. /**
  56328. * Disposes the component and the associated ressources.
  56329. */
  56330. dispose(): void;
  56331. /**
  56332. * Renders the outline in the canvas.
  56333. * @param subMesh Defines the sumesh to render
  56334. * @param batch Defines the batch of meshes in case of instances
  56335. * @param useOverlay Defines if the rendering is for the overlay or the outline
  56336. */
  56337. render(subMesh: SubMesh, batch: _InstancesBatch, useOverlay?: boolean): void;
  56338. /**
  56339. * Returns whether or not the outline renderer is ready for a given submesh.
  56340. * All the dependencies e.g. submeshes, texture, effect... mus be ready
  56341. * @param subMesh Defines the submesh to check readyness for
  56342. * @param useInstances Defines wheter wee are trying to render instances or not
  56343. * @returns true if ready otherwise false
  56344. */
  56345. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  56346. private _beforeRenderingMesh;
  56347. private _afterRenderingMesh;
  56348. }
  56349. }
  56350. declare module "babylonjs/Rendering/index" {
  56351. export * from "babylonjs/Rendering/boundingBoxRenderer";
  56352. export * from "babylonjs/Rendering/depthRenderer";
  56353. export * from "babylonjs/Rendering/depthRendererSceneComponent";
  56354. export * from "babylonjs/Rendering/edgesRenderer";
  56355. export * from "babylonjs/Rendering/geometryBufferRenderer";
  56356. export * from "babylonjs/Rendering/geometryBufferRendererSceneComponent";
  56357. export * from "babylonjs/Rendering/outlineRenderer";
  56358. export * from "babylonjs/Rendering/renderingGroup";
  56359. export * from "babylonjs/Rendering/renderingManager";
  56360. export * from "babylonjs/Rendering/utilityLayerRenderer";
  56361. }
  56362. declare module "babylonjs/Sprites/index" {
  56363. export * from "babylonjs/Sprites/sprite";
  56364. export * from "babylonjs/Sprites/spriteManager";
  56365. export * from "babylonjs/Sprites/spriteSceneComponent";
  56366. }
  56367. declare module "babylonjs/Misc/assetsManager" {
  56368. import { Scene } from "babylonjs/scene";
  56369. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  56370. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  56371. import { Skeleton } from "babylonjs/Bones/skeleton";
  56372. import { Observable } from "babylonjs/Misc/observable";
  56373. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  56374. import { Texture } from "babylonjs/Materials/Textures/texture";
  56375. import { CubeTexture } from "babylonjs/Materials/Textures/cubeTexture";
  56376. import { HDRCubeTexture } from "babylonjs/Materials/Textures/hdrCubeTexture";
  56377. import { AnimationGroup } from "babylonjs/Animations/animationGroup";
  56378. /**
  56379. * Defines the list of states available for a task inside a AssetsManager
  56380. */
  56381. export enum AssetTaskState {
  56382. /**
  56383. * Initialization
  56384. */
  56385. INIT = 0,
  56386. /**
  56387. * Running
  56388. */
  56389. RUNNING = 1,
  56390. /**
  56391. * Done
  56392. */
  56393. DONE = 2,
  56394. /**
  56395. * Error
  56396. */
  56397. ERROR = 3
  56398. }
  56399. /**
  56400. * Define an abstract asset task used with a AssetsManager class to load assets into a scene
  56401. */
  56402. export abstract class AbstractAssetTask {
  56403. /**
  56404. * Task name
  56405. */ name: string;
  56406. /**
  56407. * Callback called when the task is successful
  56408. */
  56409. onSuccess: (task: any) => void;
  56410. /**
  56411. * Callback called when the task is not successful
  56412. */
  56413. onError: (task: any, message?: string, exception?: any) => void;
  56414. /**
  56415. * Creates a new AssetsManager
  56416. * @param name defines the name of the task
  56417. */
  56418. constructor(
  56419. /**
  56420. * Task name
  56421. */ name: string);
  56422. private _isCompleted;
  56423. private _taskState;
  56424. private _errorObject;
  56425. /**
  56426. * Get if the task is completed
  56427. */
  56428. readonly isCompleted: boolean;
  56429. /**
  56430. * Gets the current state of the task
  56431. */
  56432. readonly taskState: AssetTaskState;
  56433. /**
  56434. * Gets the current error object (if task is in error)
  56435. */
  56436. readonly errorObject: {
  56437. message?: string;
  56438. exception?: any;
  56439. };
  56440. /**
  56441. * Internal only
  56442. * @hidden
  56443. */
  56444. _setErrorObject(message?: string, exception?: any): void;
  56445. /**
  56446. * Execute the current task
  56447. * @param scene defines the scene where you want your assets to be loaded
  56448. * @param onSuccess is a callback called when the task is successfully executed
  56449. * @param onError is a callback called if an error occurs
  56450. */
  56451. run(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  56452. /**
  56453. * Execute the current task
  56454. * @param scene defines the scene where you want your assets to be loaded
  56455. * @param onSuccess is a callback called when the task is successfully executed
  56456. * @param onError is a callback called if an error occurs
  56457. */
  56458. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  56459. /**
  56460. * Reset will set the task state back to INIT, so the next load call of the assets manager will execute this task again.
  56461. * This can be used with failed tasks that have the reason for failure fixed.
  56462. */
  56463. reset(): void;
  56464. private onErrorCallback;
  56465. private onDoneCallback;
  56466. }
  56467. /**
  56468. * Define the interface used by progress events raised during assets loading
  56469. */
  56470. export interface IAssetsProgressEvent {
  56471. /**
  56472. * Defines the number of remaining tasks to process
  56473. */
  56474. remainingCount: number;
  56475. /**
  56476. * Defines the total number of tasks
  56477. */
  56478. totalCount: number;
  56479. /**
  56480. * Defines the task that was just processed
  56481. */
  56482. task: AbstractAssetTask;
  56483. }
  56484. /**
  56485. * Class used to share progress information about assets loading
  56486. */
  56487. export class AssetsProgressEvent implements IAssetsProgressEvent {
  56488. /**
  56489. * Defines the number of remaining tasks to process
  56490. */
  56491. remainingCount: number;
  56492. /**
  56493. * Defines the total number of tasks
  56494. */
  56495. totalCount: number;
  56496. /**
  56497. * Defines the task that was just processed
  56498. */
  56499. task: AbstractAssetTask;
  56500. /**
  56501. * Creates a AssetsProgressEvent
  56502. * @param remainingCount defines the number of remaining tasks to process
  56503. * @param totalCount defines the total number of tasks
  56504. * @param task defines the task that was just processed
  56505. */
  56506. constructor(remainingCount: number, totalCount: number, task: AbstractAssetTask);
  56507. }
  56508. /**
  56509. * Define a task used by AssetsManager to load meshes
  56510. */
  56511. export class MeshAssetTask extends AbstractAssetTask {
  56512. /**
  56513. * Defines the name of the task
  56514. */
  56515. name: string;
  56516. /**
  56517. * Defines the list of mesh's names you want to load
  56518. */
  56519. meshesNames: any;
  56520. /**
  56521. * Defines the root url to use as a base to load your meshes and associated resources
  56522. */
  56523. rootUrl: string;
  56524. /**
  56525. * Defines the filename of the scene to load from
  56526. */
  56527. sceneFilename: string;
  56528. /**
  56529. * Gets the list of loaded meshes
  56530. */
  56531. loadedMeshes: Array<AbstractMesh>;
  56532. /**
  56533. * Gets the list of loaded particle systems
  56534. */
  56535. loadedParticleSystems: Array<IParticleSystem>;
  56536. /**
  56537. * Gets the list of loaded skeletons
  56538. */
  56539. loadedSkeletons: Array<Skeleton>;
  56540. /**
  56541. * Gets the list of loaded animation groups
  56542. */
  56543. loadedAnimationGroups: Array<AnimationGroup>;
  56544. /**
  56545. * Callback called when the task is successful
  56546. */
  56547. onSuccess: (task: MeshAssetTask) => void;
  56548. /**
  56549. * Callback called when the task is successful
  56550. */
  56551. onError: (task: MeshAssetTask, message?: string, exception?: any) => void;
  56552. /**
  56553. * Creates a new MeshAssetTask
  56554. * @param name defines the name of the task
  56555. * @param meshesNames defines the list of mesh's names you want to load
  56556. * @param rootUrl defines the root url to use as a base to load your meshes and associated resources
  56557. * @param sceneFilename defines the filename of the scene to load from
  56558. */
  56559. constructor(
  56560. /**
  56561. * Defines the name of the task
  56562. */
  56563. name: string,
  56564. /**
  56565. * Defines the list of mesh's names you want to load
  56566. */
  56567. meshesNames: any,
  56568. /**
  56569. * Defines the root url to use as a base to load your meshes and associated resources
  56570. */
  56571. rootUrl: string,
  56572. /**
  56573. * Defines the filename of the scene to load from
  56574. */
  56575. sceneFilename: string);
  56576. /**
  56577. * Execute the current task
  56578. * @param scene defines the scene where you want your assets to be loaded
  56579. * @param onSuccess is a callback called when the task is successfully executed
  56580. * @param onError is a callback called if an error occurs
  56581. */
  56582. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  56583. }
  56584. /**
  56585. * Define a task used by AssetsManager to load text content
  56586. */
  56587. export class TextFileAssetTask extends AbstractAssetTask {
  56588. /**
  56589. * Defines the name of the task
  56590. */
  56591. name: string;
  56592. /**
  56593. * Defines the location of the file to load
  56594. */
  56595. url: string;
  56596. /**
  56597. * Gets the loaded text string
  56598. */
  56599. text: string;
  56600. /**
  56601. * Callback called when the task is successful
  56602. */
  56603. onSuccess: (task: TextFileAssetTask) => void;
  56604. /**
  56605. * Callback called when the task is successful
  56606. */
  56607. onError: (task: TextFileAssetTask, message?: string, exception?: any) => void;
  56608. /**
  56609. * Creates a new TextFileAssetTask object
  56610. * @param name defines the name of the task
  56611. * @param url defines the location of the file to load
  56612. */
  56613. constructor(
  56614. /**
  56615. * Defines the name of the task
  56616. */
  56617. name: string,
  56618. /**
  56619. * Defines the location of the file to load
  56620. */
  56621. url: string);
  56622. /**
  56623. * Execute the current task
  56624. * @param scene defines the scene where you want your assets to be loaded
  56625. * @param onSuccess is a callback called when the task is successfully executed
  56626. * @param onError is a callback called if an error occurs
  56627. */
  56628. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  56629. }
  56630. /**
  56631. * Define a task used by AssetsManager to load binary data
  56632. */
  56633. export class BinaryFileAssetTask extends AbstractAssetTask {
  56634. /**
  56635. * Defines the name of the task
  56636. */
  56637. name: string;
  56638. /**
  56639. * Defines the location of the file to load
  56640. */
  56641. url: string;
  56642. /**
  56643. * Gets the lodaded data (as an array buffer)
  56644. */
  56645. data: ArrayBuffer;
  56646. /**
  56647. * Callback called when the task is successful
  56648. */
  56649. onSuccess: (task: BinaryFileAssetTask) => void;
  56650. /**
  56651. * Callback called when the task is successful
  56652. */
  56653. onError: (task: BinaryFileAssetTask, message?: string, exception?: any) => void;
  56654. /**
  56655. * Creates a new BinaryFileAssetTask object
  56656. * @param name defines the name of the new task
  56657. * @param url defines the location of the file to load
  56658. */
  56659. constructor(
  56660. /**
  56661. * Defines the name of the task
  56662. */
  56663. name: string,
  56664. /**
  56665. * Defines the location of the file to load
  56666. */
  56667. url: string);
  56668. /**
  56669. * Execute the current task
  56670. * @param scene defines the scene where you want your assets to be loaded
  56671. * @param onSuccess is a callback called when the task is successfully executed
  56672. * @param onError is a callback called if an error occurs
  56673. */
  56674. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  56675. }
  56676. /**
  56677. * Define a task used by AssetsManager to load images
  56678. */
  56679. export class ImageAssetTask extends AbstractAssetTask {
  56680. /**
  56681. * Defines the name of the task
  56682. */
  56683. name: string;
  56684. /**
  56685. * Defines the location of the image to load
  56686. */
  56687. url: string;
  56688. /**
  56689. * Gets the loaded images
  56690. */
  56691. image: HTMLImageElement;
  56692. /**
  56693. * Callback called when the task is successful
  56694. */
  56695. onSuccess: (task: ImageAssetTask) => void;
  56696. /**
  56697. * Callback called when the task is successful
  56698. */
  56699. onError: (task: ImageAssetTask, message?: string, exception?: any) => void;
  56700. /**
  56701. * Creates a new ImageAssetTask
  56702. * @param name defines the name of the task
  56703. * @param url defines the location of the image to load
  56704. */
  56705. constructor(
  56706. /**
  56707. * Defines the name of the task
  56708. */
  56709. name: string,
  56710. /**
  56711. * Defines the location of the image to load
  56712. */
  56713. url: string);
  56714. /**
  56715. * Execute the current task
  56716. * @param scene defines the scene where you want your assets to be loaded
  56717. * @param onSuccess is a callback called when the task is successfully executed
  56718. * @param onError is a callback called if an error occurs
  56719. */
  56720. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  56721. }
  56722. /**
  56723. * Defines the interface used by texture loading tasks
  56724. */
  56725. export interface ITextureAssetTask<TEX extends BaseTexture> {
  56726. /**
  56727. * Gets the loaded texture
  56728. */
  56729. texture: TEX;
  56730. }
  56731. /**
  56732. * Define a task used by AssetsManager to load 2D textures
  56733. */
  56734. export class TextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<Texture> {
  56735. /**
  56736. * Defines the name of the task
  56737. */
  56738. name: string;
  56739. /**
  56740. * Defines the location of the file to load
  56741. */
  56742. url: string;
  56743. /**
  56744. * Defines if mipmap should not be generated (default is false)
  56745. */
  56746. noMipmap?: boolean | undefined;
  56747. /**
  56748. * Defines if texture must be inverted on Y axis (default is false)
  56749. */
  56750. invertY?: boolean | undefined;
  56751. /**
  56752. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  56753. */
  56754. samplingMode: number;
  56755. /**
  56756. * Gets the loaded texture
  56757. */
  56758. texture: Texture;
  56759. /**
  56760. * Callback called when the task is successful
  56761. */
  56762. onSuccess: (task: TextureAssetTask) => void;
  56763. /**
  56764. * Callback called when the task is successful
  56765. */
  56766. onError: (task: TextureAssetTask, message?: string, exception?: any) => void;
  56767. /**
  56768. * Creates a new TextureAssetTask object
  56769. * @param name defines the name of the task
  56770. * @param url defines the location of the file to load
  56771. * @param noMipmap defines if mipmap should not be generated (default is false)
  56772. * @param invertY defines if texture must be inverted on Y axis (default is false)
  56773. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  56774. */
  56775. constructor(
  56776. /**
  56777. * Defines the name of the task
  56778. */
  56779. name: string,
  56780. /**
  56781. * Defines the location of the file to load
  56782. */
  56783. url: string,
  56784. /**
  56785. * Defines if mipmap should not be generated (default is false)
  56786. */
  56787. noMipmap?: boolean | undefined,
  56788. /**
  56789. * Defines if texture must be inverted on Y axis (default is false)
  56790. */
  56791. invertY?: boolean | undefined,
  56792. /**
  56793. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  56794. */
  56795. samplingMode?: number);
  56796. /**
  56797. * Execute the current task
  56798. * @param scene defines the scene where you want your assets to be loaded
  56799. * @param onSuccess is a callback called when the task is successfully executed
  56800. * @param onError is a callback called if an error occurs
  56801. */
  56802. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  56803. }
  56804. /**
  56805. * Define a task used by AssetsManager to load cube textures
  56806. */
  56807. export class CubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<CubeTexture> {
  56808. /**
  56809. * Defines the name of the task
  56810. */
  56811. name: string;
  56812. /**
  56813. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  56814. */
  56815. url: string;
  56816. /**
  56817. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  56818. */
  56819. extensions?: string[] | undefined;
  56820. /**
  56821. * Defines if mipmaps should not be generated (default is false)
  56822. */
  56823. noMipmap?: boolean | undefined;
  56824. /**
  56825. * Defines the explicit list of files (undefined by default)
  56826. */
  56827. files?: string[] | undefined;
  56828. /**
  56829. * Gets the loaded texture
  56830. */
  56831. texture: CubeTexture;
  56832. /**
  56833. * Callback called when the task is successful
  56834. */
  56835. onSuccess: (task: CubeTextureAssetTask) => void;
  56836. /**
  56837. * Callback called when the task is successful
  56838. */
  56839. onError: (task: CubeTextureAssetTask, message?: string, exception?: any) => void;
  56840. /**
  56841. * Creates a new CubeTextureAssetTask
  56842. * @param name defines the name of the task
  56843. * @param url defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  56844. * @param extensions defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  56845. * @param noMipmap defines if mipmaps should not be generated (default is false)
  56846. * @param files defines the explicit list of files (undefined by default)
  56847. */
  56848. constructor(
  56849. /**
  56850. * Defines the name of the task
  56851. */
  56852. name: string,
  56853. /**
  56854. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  56855. */
  56856. url: string,
  56857. /**
  56858. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  56859. */
  56860. extensions?: string[] | undefined,
  56861. /**
  56862. * Defines if mipmaps should not be generated (default is false)
  56863. */
  56864. noMipmap?: boolean | undefined,
  56865. /**
  56866. * Defines the explicit list of files (undefined by default)
  56867. */
  56868. files?: string[] | undefined);
  56869. /**
  56870. * Execute the current task
  56871. * @param scene defines the scene where you want your assets to be loaded
  56872. * @param onSuccess is a callback called when the task is successfully executed
  56873. * @param onError is a callback called if an error occurs
  56874. */
  56875. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  56876. }
  56877. /**
  56878. * Define a task used by AssetsManager to load HDR cube textures
  56879. */
  56880. export class HDRCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<HDRCubeTexture> {
  56881. /**
  56882. * Defines the name of the task
  56883. */
  56884. name: string;
  56885. /**
  56886. * Defines the location of the file to load
  56887. */
  56888. url: string;
  56889. /**
  56890. * Defines the desired size (the more it increases the longer the generation will be)
  56891. */
  56892. size: number;
  56893. /**
  56894. * Defines if mipmaps should not be generated (default is false)
  56895. */
  56896. noMipmap: boolean;
  56897. /**
  56898. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  56899. */
  56900. generateHarmonics: boolean;
  56901. /**
  56902. * 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)
  56903. */
  56904. gammaSpace: boolean;
  56905. /**
  56906. * Internal Use Only
  56907. */
  56908. reserved: boolean;
  56909. /**
  56910. * Gets the loaded texture
  56911. */
  56912. texture: HDRCubeTexture;
  56913. /**
  56914. * Callback called when the task is successful
  56915. */
  56916. onSuccess: (task: HDRCubeTextureAssetTask) => void;
  56917. /**
  56918. * Callback called when the task is successful
  56919. */
  56920. onError: (task: HDRCubeTextureAssetTask, message?: string, exception?: any) => void;
  56921. /**
  56922. * Creates a new HDRCubeTextureAssetTask object
  56923. * @param name defines the name of the task
  56924. * @param url defines the location of the file to load
  56925. * @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.
  56926. * @param noMipmap defines if mipmaps should not be generated (default is false)
  56927. * @param generateHarmonics specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  56928. * @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)
  56929. * @param reserved Internal use only
  56930. */
  56931. constructor(
  56932. /**
  56933. * Defines the name of the task
  56934. */
  56935. name: string,
  56936. /**
  56937. * Defines the location of the file to load
  56938. */
  56939. url: string,
  56940. /**
  56941. * Defines the desired size (the more it increases the longer the generation will be)
  56942. */
  56943. size: number,
  56944. /**
  56945. * Defines if mipmaps should not be generated (default is false)
  56946. */
  56947. noMipmap?: boolean,
  56948. /**
  56949. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  56950. */
  56951. generateHarmonics?: boolean,
  56952. /**
  56953. * 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)
  56954. */
  56955. gammaSpace?: boolean,
  56956. /**
  56957. * Internal Use Only
  56958. */
  56959. reserved?: boolean);
  56960. /**
  56961. * Execute the current task
  56962. * @param scene defines the scene where you want your assets to be loaded
  56963. * @param onSuccess is a callback called when the task is successfully executed
  56964. * @param onError is a callback called if an error occurs
  56965. */
  56966. run(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  56967. }
  56968. /**
  56969. * This class can be used to easily import assets into a scene
  56970. * @see http://doc.babylonjs.com/how_to/how_to_use_assetsmanager
  56971. */
  56972. export class AssetsManager {
  56973. private _scene;
  56974. private _isLoading;
  56975. protected _tasks: AbstractAssetTask[];
  56976. protected _waitingTasksCount: number;
  56977. protected _totalTasksCount: number;
  56978. /**
  56979. * Callback called when all tasks are processed
  56980. */
  56981. onFinish: (tasks: AbstractAssetTask[]) => void;
  56982. /**
  56983. * Callback called when a task is successful
  56984. */
  56985. onTaskSuccess: (task: AbstractAssetTask) => void;
  56986. /**
  56987. * Callback called when a task had an error
  56988. */
  56989. onTaskError: (task: AbstractAssetTask) => void;
  56990. /**
  56991. * Callback called when a task is done (whatever the result is)
  56992. */
  56993. onProgress: (remainingCount: number, totalCount: number, task: AbstractAssetTask) => void;
  56994. /**
  56995. * Observable called when all tasks are processed
  56996. */
  56997. onTaskSuccessObservable: Observable<AbstractAssetTask>;
  56998. /**
  56999. * Observable called when a task had an error
  57000. */
  57001. onTaskErrorObservable: Observable<AbstractAssetTask>;
  57002. /**
  57003. * Observable called when all tasks were executed
  57004. */
  57005. onTasksDoneObservable: Observable<AbstractAssetTask[]>;
  57006. /**
  57007. * Observable called when a task is done (whatever the result is)
  57008. */
  57009. onProgressObservable: Observable<IAssetsProgressEvent>;
  57010. /**
  57011. * Gets or sets a boolean defining if the AssetsManager should use the default loading screen
  57012. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  57013. */
  57014. useDefaultLoadingScreen: boolean;
  57015. /**
  57016. * Creates a new AssetsManager
  57017. * @param scene defines the scene to work on
  57018. */
  57019. constructor(scene: Scene);
  57020. /**
  57021. * Add a MeshAssetTask to the list of active tasks
  57022. * @param taskName defines the name of the new task
  57023. * @param meshesNames defines the name of meshes to load
  57024. * @param rootUrl defines the root url to use to locate files
  57025. * @param sceneFilename defines the filename of the scene file
  57026. * @returns a new MeshAssetTask object
  57027. */
  57028. addMeshTask(taskName: string, meshesNames: any, rootUrl: string, sceneFilename: string): MeshAssetTask;
  57029. /**
  57030. * Add a TextFileAssetTask to the list of active tasks
  57031. * @param taskName defines the name of the new task
  57032. * @param url defines the url of the file to load
  57033. * @returns a new TextFileAssetTask object
  57034. */
  57035. addTextFileTask(taskName: string, url: string): TextFileAssetTask;
  57036. /**
  57037. * Add a BinaryFileAssetTask to the list of active tasks
  57038. * @param taskName defines the name of the new task
  57039. * @param url defines the url of the file to load
  57040. * @returns a new BinaryFileAssetTask object
  57041. */
  57042. addBinaryFileTask(taskName: string, url: string): BinaryFileAssetTask;
  57043. /**
  57044. * Add a ImageAssetTask to the list of active tasks
  57045. * @param taskName defines the name of the new task
  57046. * @param url defines the url of the file to load
  57047. * @returns a new ImageAssetTask object
  57048. */
  57049. addImageTask(taskName: string, url: string): ImageAssetTask;
  57050. /**
  57051. * Add a TextureAssetTask to the list of active tasks
  57052. * @param taskName defines the name of the new task
  57053. * @param url defines the url of the file to load
  57054. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  57055. * @param invertY defines if you want to invert Y axis of the loaded texture (false by default)
  57056. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  57057. * @returns a new TextureAssetTask object
  57058. */
  57059. addTextureTask(taskName: string, url: string, noMipmap?: boolean, invertY?: boolean, samplingMode?: number): TextureAssetTask;
  57060. /**
  57061. * Add a CubeTextureAssetTask to the list of active tasks
  57062. * @param taskName defines the name of the new task
  57063. * @param url defines the url of the file to load
  57064. * @param extensions defines the extension to use to load the cube map (can be null)
  57065. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  57066. * @param files defines the list of files to load (can be null)
  57067. * @returns a new CubeTextureAssetTask object
  57068. */
  57069. addCubeTextureTask(taskName: string, url: string, extensions?: string[], noMipmap?: boolean, files?: string[]): CubeTextureAssetTask;
  57070. /**
  57071. *
  57072. * Add a HDRCubeTextureAssetTask to the list of active tasks
  57073. * @param taskName defines the name of the new task
  57074. * @param url defines the url of the file to load
  57075. * @param size defines the size you want for the cubemap (can be null)
  57076. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  57077. * @param generateHarmonics defines if you want to automatically generate (true by default)
  57078. * @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)
  57079. * @param reserved Internal use only
  57080. * @returns a new HDRCubeTextureAssetTask object
  57081. */
  57082. addHDRCubeTextureTask(taskName: string, url: string, size: number, noMipmap?: boolean, generateHarmonics?: boolean, gammaSpace?: boolean, reserved?: boolean): HDRCubeTextureAssetTask;
  57083. /**
  57084. * Remove a task from the assets manager.
  57085. * @param task the task to remove
  57086. */
  57087. removeTask(task: AbstractAssetTask): void;
  57088. private _decreaseWaitingTasksCount;
  57089. private _runTask;
  57090. /**
  57091. * Reset the AssetsManager and remove all tasks
  57092. * @return the current instance of the AssetsManager
  57093. */
  57094. reset(): AssetsManager;
  57095. /**
  57096. * Start the loading process
  57097. * @return the current instance of the AssetsManager
  57098. */
  57099. load(): AssetsManager;
  57100. /**
  57101. * Start the loading process as an async operation
  57102. * @return a promise returning the list of failed tasks
  57103. */
  57104. loadAsync(): Promise<void>;
  57105. }
  57106. }
  57107. declare module "babylonjs/Misc/deferred" {
  57108. /**
  57109. * Wrapper class for promise with external resolve and reject.
  57110. */
  57111. export class Deferred<T> {
  57112. /**
  57113. * The promise associated with this deferred object.
  57114. */
  57115. readonly promise: Promise<T>;
  57116. private _resolve;
  57117. private _reject;
  57118. /**
  57119. * The resolve method of the promise associated with this deferred object.
  57120. */
  57121. readonly resolve: (value?: T | PromiseLike<T> | undefined) => void;
  57122. /**
  57123. * The reject method of the promise associated with this deferred object.
  57124. */
  57125. readonly reject: (reason?: any) => void;
  57126. /**
  57127. * Constructor for this deferred object.
  57128. */
  57129. constructor();
  57130. }
  57131. }
  57132. declare module "babylonjs/Misc/meshExploder" {
  57133. import { Mesh } from "babylonjs/Meshes/mesh";
  57134. /**
  57135. * Class used to explode meshes (ie. to have a center and move them away from that center to better see the overall organization)
  57136. */
  57137. export class MeshExploder {
  57138. private _centerMesh;
  57139. private _meshes;
  57140. private _meshesOrigins;
  57141. private _toCenterVectors;
  57142. private _scaledDirection;
  57143. private _newPosition;
  57144. private _centerPosition;
  57145. /**
  57146. * Explodes meshes from a center mesh.
  57147. * @param meshes The meshes to explode.
  57148. * @param centerMesh The mesh to be center of explosion.
  57149. */
  57150. constructor(meshes: Array<Mesh>, centerMesh?: Mesh);
  57151. private _setCenterMesh;
  57152. /**
  57153. * Get class name
  57154. * @returns "MeshExploder"
  57155. */
  57156. getClassName(): string;
  57157. /**
  57158. * "Exploded meshes"
  57159. * @returns Array of meshes with the centerMesh at index 0.
  57160. */
  57161. getMeshes(): Array<Mesh>;
  57162. /**
  57163. * Explodes meshes giving a specific direction
  57164. * @param direction Number to multiply distance of each mesh's origin from center. Use a negative number to implode, or zero to reset.
  57165. */
  57166. explode(direction?: number): void;
  57167. }
  57168. }
  57169. declare module "babylonjs/Misc/filesInput" {
  57170. import { Engine } from "babylonjs/Engines/engine";
  57171. import { Scene } from "babylonjs/scene";
  57172. import { SceneLoaderProgressEvent } from "babylonjs/Loading/sceneLoader";
  57173. /**
  57174. * Class used to help managing file picking and drag'n'drop
  57175. */
  57176. export class FilesInput {
  57177. /**
  57178. * List of files ready to be loaded
  57179. */
  57180. static readonly FilesToLoad: {
  57181. [key: string]: File;
  57182. };
  57183. /**
  57184. * Callback called when a file is processed
  57185. */
  57186. onProcessFileCallback: (file: File, name: string, extension: string) => true;
  57187. private _engine;
  57188. private _currentScene;
  57189. private _sceneLoadedCallback;
  57190. private _progressCallback;
  57191. private _additionalRenderLoopLogicCallback;
  57192. private _textureLoadingCallback;
  57193. private _startingProcessingFilesCallback;
  57194. private _onReloadCallback;
  57195. private _errorCallback;
  57196. private _elementToMonitor;
  57197. private _sceneFileToLoad;
  57198. private _filesToLoad;
  57199. /**
  57200. * Creates a new FilesInput
  57201. * @param engine defines the rendering engine
  57202. * @param scene defines the hosting scene
  57203. * @param sceneLoadedCallback callback called when scene is loaded
  57204. * @param progressCallback callback called to track progress
  57205. * @param additionalRenderLoopLogicCallback callback called to add user logic to the rendering loop
  57206. * @param textureLoadingCallback callback called when a texture is loading
  57207. * @param startingProcessingFilesCallback callback called when the system is about to process all files
  57208. * @param onReloadCallback callback called when a reload is requested
  57209. * @param errorCallback callback call if an error occurs
  57210. */
  57211. 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);
  57212. private _dragEnterHandler;
  57213. private _dragOverHandler;
  57214. private _dropHandler;
  57215. /**
  57216. * Calls this function to listen to drag'n'drop events on a specific DOM element
  57217. * @param elementToMonitor defines the DOM element to track
  57218. */
  57219. monitorElementForDragNDrop(elementToMonitor: HTMLElement): void;
  57220. /**
  57221. * Release all associated resources
  57222. */
  57223. dispose(): void;
  57224. private renderFunction;
  57225. private drag;
  57226. private drop;
  57227. private _traverseFolder;
  57228. private _processFiles;
  57229. /**
  57230. * Load files from a drop event
  57231. * @param event defines the drop event to use as source
  57232. */
  57233. loadFiles(event: any): void;
  57234. private _processReload;
  57235. /**
  57236. * Reload the current scene from the loaded files
  57237. */
  57238. reload(): void;
  57239. }
  57240. }
  57241. declare module "babylonjs/Misc/HighDynamicRange/index" {
  57242. export * from "babylonjs/Misc/HighDynamicRange/cubemapToSphericalPolynomial";
  57243. export * from "babylonjs/Misc/HighDynamicRange/hdr";
  57244. export * from "babylonjs/Misc/HighDynamicRange/panoramaToCubemap";
  57245. }
  57246. declare module "babylonjs/Misc/sceneOptimizer" {
  57247. import { Scene, IDisposable } from "babylonjs/scene";
  57248. import { Observable } from "babylonjs/Misc/observable";
  57249. /**
  57250. * Defines the root class used to create scene optimization to use with SceneOptimizer
  57251. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  57252. */
  57253. export class SceneOptimization {
  57254. /**
  57255. * Defines the priority of this optimization (0 by default which means first in the list)
  57256. */
  57257. priority: number;
  57258. /**
  57259. * Gets a string describing the action executed by the current optimization
  57260. * @returns description string
  57261. */
  57262. getDescription(): string;
  57263. /**
  57264. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  57265. * @param scene defines the current scene where to apply this optimization
  57266. * @param optimizer defines the current optimizer
  57267. * @returns true if everything that can be done was applied
  57268. */
  57269. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  57270. /**
  57271. * Creates the SceneOptimization object
  57272. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  57273. * @param desc defines the description associated with the optimization
  57274. */
  57275. constructor(
  57276. /**
  57277. * Defines the priority of this optimization (0 by default which means first in the list)
  57278. */
  57279. priority?: number);
  57280. }
  57281. /**
  57282. * Defines an optimization used to reduce the size of render target textures
  57283. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  57284. */
  57285. export class TextureOptimization extends SceneOptimization {
  57286. /**
  57287. * Defines the priority of this optimization (0 by default which means first in the list)
  57288. */
  57289. priority: number;
  57290. /**
  57291. * 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
  57292. */
  57293. maximumSize: number;
  57294. /**
  57295. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  57296. */
  57297. step: number;
  57298. /**
  57299. * Gets a string describing the action executed by the current optimization
  57300. * @returns description string
  57301. */
  57302. getDescription(): string;
  57303. /**
  57304. * Creates the TextureOptimization object
  57305. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  57306. * @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
  57307. * @param step defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  57308. */
  57309. constructor(
  57310. /**
  57311. * Defines the priority of this optimization (0 by default which means first in the list)
  57312. */
  57313. priority?: number,
  57314. /**
  57315. * 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
  57316. */
  57317. maximumSize?: number,
  57318. /**
  57319. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  57320. */
  57321. step?: number);
  57322. /**
  57323. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  57324. * @param scene defines the current scene where to apply this optimization
  57325. * @param optimizer defines the current optimizer
  57326. * @returns true if everything that can be done was applied
  57327. */
  57328. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  57329. }
  57330. /**
  57331. * Defines an optimization used to increase or decrease the rendering resolution
  57332. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  57333. */
  57334. export class HardwareScalingOptimization extends SceneOptimization {
  57335. /**
  57336. * Defines the priority of this optimization (0 by default which means first in the list)
  57337. */
  57338. priority: number;
  57339. /**
  57340. * Defines the maximum scale to use (2 by default)
  57341. */
  57342. maximumScale: number;
  57343. /**
  57344. * Defines the step to use between two passes (0.5 by default)
  57345. */
  57346. step: number;
  57347. private _currentScale;
  57348. private _directionOffset;
  57349. /**
  57350. * Gets a string describing the action executed by the current optimization
  57351. * @return description string
  57352. */
  57353. getDescription(): string;
  57354. /**
  57355. * Creates the HardwareScalingOptimization object
  57356. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  57357. * @param maximumScale defines the maximum scale to use (2 by default)
  57358. * @param step defines the step to use between two passes (0.5 by default)
  57359. */
  57360. constructor(
  57361. /**
  57362. * Defines the priority of this optimization (0 by default which means first in the list)
  57363. */
  57364. priority?: number,
  57365. /**
  57366. * Defines the maximum scale to use (2 by default)
  57367. */
  57368. maximumScale?: number,
  57369. /**
  57370. * Defines the step to use between two passes (0.5 by default)
  57371. */
  57372. step?: number);
  57373. /**
  57374. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  57375. * @param scene defines the current scene where to apply this optimization
  57376. * @param optimizer defines the current optimizer
  57377. * @returns true if everything that can be done was applied
  57378. */
  57379. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  57380. }
  57381. /**
  57382. * Defines an optimization used to remove shadows
  57383. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  57384. */
  57385. export class ShadowsOptimization extends SceneOptimization {
  57386. /**
  57387. * Gets a string describing the action executed by the current optimization
  57388. * @return description string
  57389. */
  57390. getDescription(): string;
  57391. /**
  57392. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  57393. * @param scene defines the current scene where to apply this optimization
  57394. * @param optimizer defines the current optimizer
  57395. * @returns true if everything that can be done was applied
  57396. */
  57397. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  57398. }
  57399. /**
  57400. * Defines an optimization used to turn post-processes off
  57401. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  57402. */
  57403. export class PostProcessesOptimization extends SceneOptimization {
  57404. /**
  57405. * Gets a string describing the action executed by the current optimization
  57406. * @return description string
  57407. */
  57408. getDescription(): string;
  57409. /**
  57410. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  57411. * @param scene defines the current scene where to apply this optimization
  57412. * @param optimizer defines the current optimizer
  57413. * @returns true if everything that can be done was applied
  57414. */
  57415. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  57416. }
  57417. /**
  57418. * Defines an optimization used to turn lens flares off
  57419. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  57420. */
  57421. export class LensFlaresOptimization extends SceneOptimization {
  57422. /**
  57423. * Gets a string describing the action executed by the current optimization
  57424. * @return description string
  57425. */
  57426. getDescription(): string;
  57427. /**
  57428. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  57429. * @param scene defines the current scene where to apply this optimization
  57430. * @param optimizer defines the current optimizer
  57431. * @returns true if everything that can be done was applied
  57432. */
  57433. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  57434. }
  57435. /**
  57436. * Defines an optimization based on user defined callback.
  57437. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  57438. */
  57439. export class CustomOptimization extends SceneOptimization {
  57440. /**
  57441. * Callback called to apply the custom optimization.
  57442. */
  57443. onApply: (scene: Scene, optimizer: SceneOptimizer) => boolean;
  57444. /**
  57445. * Callback called to get custom description
  57446. */
  57447. onGetDescription: () => string;
  57448. /**
  57449. * Gets a string describing the action executed by the current optimization
  57450. * @returns description string
  57451. */
  57452. getDescription(): string;
  57453. /**
  57454. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  57455. * @param scene defines the current scene where to apply this optimization
  57456. * @param optimizer defines the current optimizer
  57457. * @returns true if everything that can be done was applied
  57458. */
  57459. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  57460. }
  57461. /**
  57462. * Defines an optimization used to turn particles off
  57463. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  57464. */
  57465. export class ParticlesOptimization extends SceneOptimization {
  57466. /**
  57467. * Gets a string describing the action executed by the current optimization
  57468. * @return description string
  57469. */
  57470. getDescription(): string;
  57471. /**
  57472. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  57473. * @param scene defines the current scene where to apply this optimization
  57474. * @param optimizer defines the current optimizer
  57475. * @returns true if everything that can be done was applied
  57476. */
  57477. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  57478. }
  57479. /**
  57480. * Defines an optimization used to turn render targets off
  57481. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  57482. */
  57483. export class RenderTargetsOptimization extends SceneOptimization {
  57484. /**
  57485. * Gets a string describing the action executed by the current optimization
  57486. * @return description string
  57487. */
  57488. getDescription(): string;
  57489. /**
  57490. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  57491. * @param scene defines the current scene where to apply this optimization
  57492. * @param optimizer defines the current optimizer
  57493. * @returns true if everything that can be done was applied
  57494. */
  57495. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  57496. }
  57497. /**
  57498. * Defines an optimization used to merge meshes with compatible materials
  57499. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  57500. */
  57501. export class MergeMeshesOptimization extends SceneOptimization {
  57502. private static _UpdateSelectionTree;
  57503. /**
  57504. * Gets or sets a boolean which defines if optimization octree has to be updated
  57505. */
  57506. /**
  57507. * Gets or sets a boolean which defines if optimization octree has to be updated
  57508. */
  57509. static UpdateSelectionTree: boolean;
  57510. /**
  57511. * Gets a string describing the action executed by the current optimization
  57512. * @return description string
  57513. */
  57514. getDescription(): string;
  57515. private _canBeMerged;
  57516. /**
  57517. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  57518. * @param scene defines the current scene where to apply this optimization
  57519. * @param optimizer defines the current optimizer
  57520. * @param updateSelectionTree defines that the selection octree has to be updated (false by default)
  57521. * @returns true if everything that can be done was applied
  57522. */
  57523. apply(scene: Scene, optimizer: SceneOptimizer, updateSelectionTree?: boolean): boolean;
  57524. }
  57525. /**
  57526. * Defines a list of options used by SceneOptimizer
  57527. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  57528. */
  57529. export class SceneOptimizerOptions {
  57530. /**
  57531. * Defines the target frame rate to reach (60 by default)
  57532. */
  57533. targetFrameRate: number;
  57534. /**
  57535. * Defines the interval between two checkes (2000ms by default)
  57536. */
  57537. trackerDuration: number;
  57538. /**
  57539. * Gets the list of optimizations to apply
  57540. */
  57541. optimizations: SceneOptimization[];
  57542. /**
  57543. * Creates a new list of options used by SceneOptimizer
  57544. * @param targetFrameRate defines the target frame rate to reach (60 by default)
  57545. * @param trackerDuration defines the interval between two checkes (2000ms by default)
  57546. */
  57547. constructor(
  57548. /**
  57549. * Defines the target frame rate to reach (60 by default)
  57550. */
  57551. targetFrameRate?: number,
  57552. /**
  57553. * Defines the interval between two checkes (2000ms by default)
  57554. */
  57555. trackerDuration?: number);
  57556. /**
  57557. * Add a new optimization
  57558. * @param optimization defines the SceneOptimization to add to the list of active optimizations
  57559. * @returns the current SceneOptimizerOptions
  57560. */
  57561. addOptimization(optimization: SceneOptimization): SceneOptimizerOptions;
  57562. /**
  57563. * Add a new custom optimization
  57564. * @param onApply defines the callback called to apply the custom optimization (true if everything that can be done was applied)
  57565. * @param onGetDescription defines the callback called to get the description attached with the optimization.
  57566. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  57567. * @returns the current SceneOptimizerOptions
  57568. */
  57569. addCustomOptimization(onApply: (scene: Scene) => boolean, onGetDescription: () => string, priority?: number): SceneOptimizerOptions;
  57570. /**
  57571. * Creates a list of pre-defined optimizations aimed to reduce the visual impact on the scene
  57572. * @param targetFrameRate defines the target frame rate (60 by default)
  57573. * @returns a SceneOptimizerOptions object
  57574. */
  57575. static LowDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  57576. /**
  57577. * Creates a list of pre-defined optimizations aimed to have a moderate impact on the scene visual
  57578. * @param targetFrameRate defines the target frame rate (60 by default)
  57579. * @returns a SceneOptimizerOptions object
  57580. */
  57581. static ModerateDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  57582. /**
  57583. * Creates a list of pre-defined optimizations aimed to have a big impact on the scene visual
  57584. * @param targetFrameRate defines the target frame rate (60 by default)
  57585. * @returns a SceneOptimizerOptions object
  57586. */
  57587. static HighDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  57588. }
  57589. /**
  57590. * Class used to run optimizations in order to reach a target frame rate
  57591. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  57592. */
  57593. export class SceneOptimizer implements IDisposable {
  57594. private _isRunning;
  57595. private _options;
  57596. private _scene;
  57597. private _currentPriorityLevel;
  57598. private _targetFrameRate;
  57599. private _trackerDuration;
  57600. private _currentFrameRate;
  57601. private _sceneDisposeObserver;
  57602. private _improvementMode;
  57603. /**
  57604. * Defines an observable called when the optimizer reaches the target frame rate
  57605. */
  57606. onSuccessObservable: Observable<SceneOptimizer>;
  57607. /**
  57608. * Defines an observable called when the optimizer enables an optimization
  57609. */
  57610. onNewOptimizationAppliedObservable: Observable<SceneOptimization>;
  57611. /**
  57612. * Defines an observable called when the optimizer is not able to reach the target frame rate
  57613. */
  57614. onFailureObservable: Observable<SceneOptimizer>;
  57615. /**
  57616. * Gets a boolean indicating if the optimizer is in improvement mode
  57617. */
  57618. readonly isInImprovementMode: boolean;
  57619. /**
  57620. * Gets the current priority level (0 at start)
  57621. */
  57622. readonly currentPriorityLevel: number;
  57623. /**
  57624. * Gets the current frame rate checked by the SceneOptimizer
  57625. */
  57626. readonly currentFrameRate: number;
  57627. /**
  57628. * Gets or sets the current target frame rate (60 by default)
  57629. */
  57630. /**
  57631. * Gets or sets the current target frame rate (60 by default)
  57632. */
  57633. targetFrameRate: number;
  57634. /**
  57635. * Gets or sets the current interval between two checks (every 2000ms by default)
  57636. */
  57637. /**
  57638. * Gets or sets the current interval between two checks (every 2000ms by default)
  57639. */
  57640. trackerDuration: number;
  57641. /**
  57642. * Gets the list of active optimizations
  57643. */
  57644. readonly optimizations: SceneOptimization[];
  57645. /**
  57646. * Creates a new SceneOptimizer
  57647. * @param scene defines the scene to work on
  57648. * @param options defines the options to use with the SceneOptimizer
  57649. * @param autoGeneratePriorities defines if priorities must be generated and not read from SceneOptimization property (true by default)
  57650. * @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)
  57651. */
  57652. constructor(scene: Scene, options?: SceneOptimizerOptions, autoGeneratePriorities?: boolean, improvementMode?: boolean);
  57653. /**
  57654. * Stops the current optimizer
  57655. */
  57656. stop(): void;
  57657. /**
  57658. * Reset the optimizer to initial step (current priority level = 0)
  57659. */
  57660. reset(): void;
  57661. /**
  57662. * Start the optimizer. By default it will try to reach a specific framerate
  57663. * but if the optimizer is set with improvementMode === true then it will run all optimiatiation while frame rate is above the target frame rate
  57664. */
  57665. start(): void;
  57666. private _checkCurrentState;
  57667. /**
  57668. * Release all resources
  57669. */
  57670. dispose(): void;
  57671. /**
  57672. * Helper function to create a SceneOptimizer with one single line of code
  57673. * @param scene defines the scene to work on
  57674. * @param options defines the options to use with the SceneOptimizer
  57675. * @param onSuccess defines a callback to call on success
  57676. * @param onFailure defines a callback to call on failure
  57677. * @returns the new SceneOptimizer object
  57678. */
  57679. static OptimizeAsync(scene: Scene, options?: SceneOptimizerOptions, onSuccess?: () => void, onFailure?: () => void): SceneOptimizer;
  57680. }
  57681. }
  57682. declare module "babylonjs/Misc/sceneSerializer" {
  57683. import { Scene } from "babylonjs/scene";
  57684. /**
  57685. * Class used to serialize a scene into a string
  57686. */
  57687. export class SceneSerializer {
  57688. /**
  57689. * Clear cache used by a previous serialization
  57690. */
  57691. static ClearCache(): void;
  57692. /**
  57693. * Serialize a scene into a JSON compatible object
  57694. * @param scene defines the scene to serialize
  57695. * @returns a JSON compatible object
  57696. */
  57697. static Serialize(scene: Scene): any;
  57698. /**
  57699. * Serialize a mesh into a JSON compatible object
  57700. * @param toSerialize defines the mesh to serialize
  57701. * @param withParents defines if parents must be serialized as well
  57702. * @param withChildren defines if children must be serialized as well
  57703. * @returns a JSON compatible object
  57704. */
  57705. static SerializeMesh(toSerialize: any, withParents?: boolean, withChildren?: boolean): any;
  57706. }
  57707. }
  57708. declare module "babylonjs/Misc/videoRecorder" {
  57709. import { Nullable } from "babylonjs/types";
  57710. import { Engine } from "babylonjs/Engines/engine";
  57711. /**
  57712. * This represents the different options avilable for the video capture.
  57713. */
  57714. export interface VideoRecorderOptions {
  57715. /** Defines the mime type of the video */
  57716. mimeType: string;
  57717. /** Defines the video the video should be recorded at */
  57718. fps: number;
  57719. /** Defines the chunk size for the recording data */
  57720. recordChunckSize: number;
  57721. /** The audio tracks to attach to the record */
  57722. audioTracks?: MediaStreamTrack[];
  57723. }
  57724. /**
  57725. * This can helps recording videos from BabylonJS.
  57726. * This is based on the available WebRTC functionalities of the browser.
  57727. *
  57728. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_video
  57729. */
  57730. export class VideoRecorder {
  57731. private static readonly _defaultOptions;
  57732. /**
  57733. * Returns wehther or not the VideoRecorder is available in your browser.
  57734. * @param engine Defines the Babylon Engine to check the support for
  57735. * @returns true if supported otherwise false
  57736. */
  57737. static IsSupported(engine: Engine): boolean;
  57738. private readonly _options;
  57739. private _canvas;
  57740. private _mediaRecorder;
  57741. private _recordedChunks;
  57742. private _fileName;
  57743. private _resolve;
  57744. private _reject;
  57745. /**
  57746. * True wether a recording is already in progress.
  57747. */
  57748. readonly isRecording: boolean;
  57749. /**
  57750. * Create a new VideoCapture object which can help converting what you see in Babylon to
  57751. * a video file.
  57752. * @param engine Defines the BabylonJS Engine you wish to record
  57753. * @param options Defines options that can be used to customized the capture
  57754. */
  57755. constructor(engine: Engine, options?: Nullable<VideoRecorderOptions>);
  57756. /**
  57757. * Stops the current recording before the default capture timeout passed in the startRecording
  57758. * functions.
  57759. */
  57760. stopRecording(): void;
  57761. /**
  57762. * Starts recording the canvas for a max duration specified in parameters.
  57763. * @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.
  57764. * @param maxDuration Defines the maximum recording time in seconds.
  57765. * It default to 7 seconds. A value of zero will not stop automatically, you would need to call stopRecording manually.
  57766. * @return a promise callback at the end of the recording with the video data in Blob.
  57767. */
  57768. startRecording(fileName?: Nullable<string>, maxDuration?: number): Promise<Blob>;
  57769. /**
  57770. * Releases internal resources used during the recording.
  57771. */
  57772. dispose(): void;
  57773. private _handleDataAvailable;
  57774. private _handleError;
  57775. private _handleStop;
  57776. }
  57777. }
  57778. declare module "babylonjs/Misc/workerPool" {
  57779. import { IDisposable } from "babylonjs/scene";
  57780. /**
  57781. * Helper class to push actions to a pool of workers.
  57782. */
  57783. export class WorkerPool implements IDisposable {
  57784. private _workerInfos;
  57785. private _pendingActions;
  57786. /**
  57787. * Constructor
  57788. * @param workers Array of workers to use for actions
  57789. */
  57790. constructor(workers: Array<Worker>);
  57791. /**
  57792. * Terminates all workers and clears any pending actions.
  57793. */
  57794. dispose(): void;
  57795. /**
  57796. * Pushes an action to the worker pool. If all the workers are active, the action will be
  57797. * pended until a worker has completed its action.
  57798. * @param action The action to perform. Call onComplete when the action is complete.
  57799. */
  57800. push(action: (worker: Worker, onComplete: () => void) => void): void;
  57801. private _execute;
  57802. }
  57803. }
  57804. declare module "babylonjs/Misc/screenshotTools" {
  57805. import { Camera } from "babylonjs/Cameras/camera";
  57806. import { Engine } from "babylonjs/Engines/engine";
  57807. /**
  57808. * Class containing a set of static utilities functions for screenshots
  57809. */
  57810. export class ScreenshotTools {
  57811. /**
  57812. * Captures a screenshot of the current rendering
  57813. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  57814. * @param engine defines the rendering engine
  57815. * @param camera defines the source camera
  57816. * @param size This parameter can be set to a single number or to an object with the
  57817. * following (optional) properties: precision, width, height. If a single number is passed,
  57818. * it will be used for both width and height. If an object is passed, the screenshot size
  57819. * will be derived from the parameters. The precision property is a multiplier allowing
  57820. * rendering at a higher or lower resolution
  57821. * @param successCallback defines the callback receives a single parameter which contains the
  57822. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  57823. * src parameter of an <img> to display it
  57824. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  57825. * Check your browser for supported MIME types
  57826. */
  57827. static CreateScreenshot(engine: Engine, camera: Camera, size: any, successCallback?: (data: string) => void, mimeType?: string): void;
  57828. /**
  57829. * Generates an image screenshot from the specified camera.
  57830. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  57831. * @param engine The engine to use for rendering
  57832. * @param camera The camera to use for rendering
  57833. * @param size This parameter can be set to a single number or to an object with the
  57834. * following (optional) properties: precision, width, height. If a single number is passed,
  57835. * it will be used for both width and height. If an object is passed, the screenshot size
  57836. * will be derived from the parameters. The precision property is a multiplier allowing
  57837. * rendering at a higher or lower resolution
  57838. * @param successCallback The callback receives a single parameter which contains the
  57839. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  57840. * src parameter of an <img> to display it
  57841. * @param mimeType The MIME type of the screenshot image (default: image/png).
  57842. * Check your browser for supported MIME types
  57843. * @param samples Texture samples (default: 1)
  57844. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  57845. * @param fileName A name for for the downloaded file.
  57846. */
  57847. static CreateScreenshotUsingRenderTarget(engine: Engine, camera: Camera, size: any, successCallback?: (data: string) => void, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): void;
  57848. }
  57849. }
  57850. declare module "babylonjs/Misc/index" {
  57851. export * from "babylonjs/Misc/andOrNotEvaluator";
  57852. export * from "babylonjs/Misc/assetsManager";
  57853. export * from "babylonjs/Misc/dds";
  57854. export * from "babylonjs/Misc/decorators";
  57855. export * from "babylonjs/Misc/deferred";
  57856. export * from "babylonjs/Misc/environmentTextureTools";
  57857. export * from "babylonjs/Misc/meshExploder";
  57858. export * from "babylonjs/Misc/filesInput";
  57859. export * from "babylonjs/Misc/HighDynamicRange/index";
  57860. export * from "babylonjs/Misc/khronosTextureContainer";
  57861. export * from "babylonjs/Misc/observable";
  57862. export * from "babylonjs/Misc/performanceMonitor";
  57863. export * from "babylonjs/Misc/promise";
  57864. export * from "babylonjs/Misc/sceneOptimizer";
  57865. export * from "babylonjs/Misc/sceneSerializer";
  57866. export * from "babylonjs/Misc/smartArray";
  57867. export * from "babylonjs/Misc/stringDictionary";
  57868. export * from "babylonjs/Misc/tags";
  57869. export * from "babylonjs/Misc/textureTools";
  57870. export * from "babylonjs/Misc/tga";
  57871. export * from "babylonjs/Misc/tools";
  57872. export * from "babylonjs/Misc/videoRecorder";
  57873. export * from "babylonjs/Misc/virtualJoystick";
  57874. export * from "babylonjs/Misc/workerPool";
  57875. export * from "babylonjs/Misc/logger";
  57876. export * from "babylonjs/Misc/typeStore";
  57877. export * from "babylonjs/Misc/filesInputStore";
  57878. export * from "babylonjs/Misc/deepCopier";
  57879. export * from "babylonjs/Misc/pivotTools";
  57880. export * from "babylonjs/Misc/precisionDate";
  57881. export * from "babylonjs/Misc/screenshotTools";
  57882. export * from "babylonjs/Misc/typeStore";
  57883. export * from "babylonjs/Misc/webRequest";
  57884. export * from "babylonjs/Misc/iInspectable";
  57885. }
  57886. declare module "babylonjs/index" {
  57887. export * from "babylonjs/abstractScene";
  57888. export * from "babylonjs/Actions/index";
  57889. export * from "babylonjs/Animations/index";
  57890. export * from "babylonjs/assetContainer";
  57891. export * from "babylonjs/Audio/index";
  57892. export * from "babylonjs/Behaviors/index";
  57893. export * from "babylonjs/Bones/index";
  57894. export * from "babylonjs/Cameras/index";
  57895. export * from "babylonjs/Collisions/index";
  57896. export * from "babylonjs/Culling/index";
  57897. export * from "babylonjs/Debug/index";
  57898. export * from "babylonjs/Engines/index";
  57899. export * from "babylonjs/Events/index";
  57900. export * from "babylonjs/Gamepads/index";
  57901. export * from "babylonjs/Gizmos/index";
  57902. export * from "babylonjs/Helpers/index";
  57903. export * from "babylonjs/Instrumentation/index";
  57904. export * from "babylonjs/Layers/index";
  57905. export * from "babylonjs/LensFlares/index";
  57906. export * from "babylonjs/Lights/index";
  57907. export * from "babylonjs/Loading/index";
  57908. export * from "babylonjs/Materials/index";
  57909. export * from "babylonjs/Maths/index";
  57910. export * from "babylonjs/Meshes/index";
  57911. export * from "babylonjs/Morph/index";
  57912. export * from "babylonjs/node";
  57913. export * from "babylonjs/Offline/index";
  57914. export * from "babylonjs/Particles/index";
  57915. export * from "babylonjs/Physics/index";
  57916. export * from "babylonjs/PostProcesses/index";
  57917. export * from "babylonjs/Probes/index";
  57918. export * from "babylonjs/Rendering/index";
  57919. export * from "babylonjs/scene";
  57920. export * from "babylonjs/sceneComponent";
  57921. export * from "babylonjs/Sprites/index";
  57922. export * from "babylonjs/States/index";
  57923. export * from "babylonjs/Misc/index";
  57924. export * from "babylonjs/types";
  57925. }
  57926. declare module "babylonjs/Animations/pathCursor" {
  57927. import { Path2, Vector3 } from "babylonjs/Maths/math";
  57928. /**
  57929. * A cursor which tracks a point on a path
  57930. */
  57931. export class PathCursor {
  57932. private path;
  57933. /**
  57934. * Stores path cursor callbacks for when an onchange event is triggered
  57935. */
  57936. private _onchange;
  57937. /**
  57938. * The value of the path cursor
  57939. */
  57940. value: number;
  57941. /**
  57942. * The animation array of the path cursor
  57943. */
  57944. animations: Animation[];
  57945. /**
  57946. * Initializes the path cursor
  57947. * @param path The path to track
  57948. */
  57949. constructor(path: Path2);
  57950. /**
  57951. * Gets the cursor point on the path
  57952. * @returns A point on the path cursor at the cursor location
  57953. */
  57954. getPoint(): Vector3;
  57955. /**
  57956. * Moves the cursor ahead by the step amount
  57957. * @param step The amount to move the cursor forward
  57958. * @returns This path cursor
  57959. */
  57960. moveAhead(step?: number): PathCursor;
  57961. /**
  57962. * Moves the cursor behind by the step amount
  57963. * @param step The amount to move the cursor back
  57964. * @returns This path cursor
  57965. */
  57966. moveBack(step?: number): PathCursor;
  57967. /**
  57968. * Moves the cursor by the step amount
  57969. * If the step amount is greater than one, an exception is thrown
  57970. * @param step The amount to move the cursor
  57971. * @returns This path cursor
  57972. */
  57973. move(step: number): PathCursor;
  57974. /**
  57975. * Ensures that the value is limited between zero and one
  57976. * @returns This path cursor
  57977. */
  57978. private ensureLimits;
  57979. /**
  57980. * Runs onchange callbacks on change (used by the animation engine)
  57981. * @returns This path cursor
  57982. */
  57983. private raiseOnChange;
  57984. /**
  57985. * Executes a function on change
  57986. * @param f A path cursor onchange callback
  57987. * @returns This path cursor
  57988. */
  57989. onchange(f: (cursor: PathCursor) => void): PathCursor;
  57990. }
  57991. }
  57992. declare module "babylonjs/Legacy/legacy" {
  57993. import * as Babylon from "babylonjs/index";
  57994. export * from "babylonjs/index";
  57995. }
  57996. declare module "babylonjs/Shaders/blur.fragment" {
  57997. /** @hidden */
  57998. export var blurPixelShader: {
  57999. name: string;
  58000. shader: string;
  58001. };
  58002. }
  58003. declare module "babylonjs/Shaders/ShadersInclude/bones300Declaration" {
  58004. /** @hidden */
  58005. export var bones300Declaration: {
  58006. name: string;
  58007. shader: string;
  58008. };
  58009. }
  58010. declare module "babylonjs/Shaders/ShadersInclude/instances300Declaration" {
  58011. /** @hidden */
  58012. export var instances300Declaration: {
  58013. name: string;
  58014. shader: string;
  58015. };
  58016. }
  58017. declare module "babylonjs/Shaders/ShadersInclude/pointCloudVertexDeclaration" {
  58018. /** @hidden */
  58019. export var pointCloudVertexDeclaration: {
  58020. name: string;
  58021. shader: string;
  58022. };
  58023. }
  58024. // Mixins
  58025. interface Window {
  58026. mozIndexedDB: IDBFactory;
  58027. webkitIndexedDB: IDBFactory;
  58028. msIndexedDB: IDBFactory;
  58029. webkitURL: typeof URL;
  58030. mozRequestAnimationFrame(callback: FrameRequestCallback): number;
  58031. oRequestAnimationFrame(callback: FrameRequestCallback): number;
  58032. WebGLRenderingContext: WebGLRenderingContext;
  58033. MSGesture: MSGesture;
  58034. CANNON: any;
  58035. AudioContext: AudioContext;
  58036. webkitAudioContext: AudioContext;
  58037. PointerEvent: any;
  58038. Math: Math;
  58039. Uint8Array: Uint8ArrayConstructor;
  58040. Float32Array: Float32ArrayConstructor;
  58041. mozURL: typeof URL;
  58042. msURL: typeof URL;
  58043. VRFrameData: any; // WebVR, from specs 1.1
  58044. DracoDecoderModule: any;
  58045. setImmediate(handler: (...args: any[]) => void): number;
  58046. }
  58047. interface HTMLCanvasElement {
  58048. requestPointerLock(): void;
  58049. msRequestPointerLock?(): void;
  58050. mozRequestPointerLock?(): void;
  58051. webkitRequestPointerLock?(): void;
  58052. /** Track wether a record is in progress */
  58053. isRecording: boolean;
  58054. /** Capture Stream method defined by some browsers */
  58055. captureStream(fps?: number): MediaStream;
  58056. }
  58057. interface CanvasRenderingContext2D {
  58058. msImageSmoothingEnabled: boolean;
  58059. }
  58060. interface MouseEvent {
  58061. mozMovementX: number;
  58062. mozMovementY: number;
  58063. webkitMovementX: number;
  58064. webkitMovementY: number;
  58065. msMovementX: number;
  58066. msMovementY: number;
  58067. }
  58068. interface Navigator {
  58069. mozGetVRDevices: (any: any) => any;
  58070. webkitGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  58071. mozGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  58072. msGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  58073. webkitGetGamepads(): Gamepad[];
  58074. msGetGamepads(): Gamepad[];
  58075. webkitGamepads(): Gamepad[];
  58076. }
  58077. interface HTMLVideoElement {
  58078. mozSrcObject: any;
  58079. }
  58080. interface Math {
  58081. fround(x: number): number;
  58082. imul(a: number, b: number): number;
  58083. }
  58084. interface WebGLProgram {
  58085. context?: WebGLRenderingContext;
  58086. vertexShader?: WebGLShader;
  58087. fragmentShader?: WebGLShader;
  58088. isParallelCompiled: boolean;
  58089. onCompiled?: () => void;
  58090. }
  58091. interface WebGLRenderingContext {
  58092. drawArraysInstanced(mode: number, first: number, count: number, primcount: number): void;
  58093. drawElementsInstanced(mode: number, count: number, type: number, offset: number, primcount: number): void;
  58094. vertexAttribDivisor(index: number, divisor: number): void;
  58095. createVertexArray(): any;
  58096. bindVertexArray(vao?: WebGLVertexArrayObject | null): void;
  58097. deleteVertexArray(vao: WebGLVertexArrayObject): void;
  58098. blitFramebuffer(srcX0: number, srcY0: number, srcX1: number, srcY1: number, dstX0: number, dstY0: number, dstX1: number, dstY1: number, mask: number, filter: number): void;
  58099. renderbufferStorageMultisample(target: number, samples: number, internalformat: number, width: number, height: number): void;
  58100. bindBufferBase(target: number, index: number, buffer: WebGLBuffer | null): void;
  58101. getUniformBlockIndex(program: WebGLProgram, uniformBlockName: string): number;
  58102. uniformBlockBinding(program: WebGLProgram, uniformBlockIndex: number, uniformBlockBinding: number): void;
  58103. // Queries
  58104. createQuery(): WebGLQuery;
  58105. deleteQuery(query: WebGLQuery): void;
  58106. beginQuery(target: number, query: WebGLQuery): void;
  58107. endQuery(target: number): void;
  58108. getQueryParameter(query: WebGLQuery, pname: number): any;
  58109. getQuery(target: number, pname: number): any;
  58110. MAX_SAMPLES: number;
  58111. RGBA8: number;
  58112. READ_FRAMEBUFFER: number;
  58113. DRAW_FRAMEBUFFER: number;
  58114. UNIFORM_BUFFER: number;
  58115. HALF_FLOAT_OES: number;
  58116. RGBA16F: number;
  58117. RGBA32F: number;
  58118. R32F: number;
  58119. RG32F: number;
  58120. RGB32F: number;
  58121. R16F: number;
  58122. RG16F: number;
  58123. RGB16F: number;
  58124. RED: number;
  58125. RG: number;
  58126. R8: number;
  58127. RG8: number;
  58128. UNSIGNED_INT_24_8: number;
  58129. DEPTH24_STENCIL8: number;
  58130. /* Multiple Render Targets */
  58131. drawBuffers(buffers: number[]): void;
  58132. readBuffer(src: number): void;
  58133. readonly COLOR_ATTACHMENT0: number; // 0x8CE1
  58134. readonly COLOR_ATTACHMENT1: number; // 0x8CE2
  58135. readonly COLOR_ATTACHMENT2: number; // 0x8CE3
  58136. readonly COLOR_ATTACHMENT3: number; // 0x8CE4
  58137. // Occlusion Query
  58138. ANY_SAMPLES_PASSED_CONSERVATIVE: number;
  58139. ANY_SAMPLES_PASSED: number;
  58140. QUERY_RESULT_AVAILABLE: number;
  58141. QUERY_RESULT: number;
  58142. }
  58143. interface WebGLBuffer {
  58144. references: number;
  58145. capacity: number;
  58146. is32Bits: boolean;
  58147. }
  58148. interface WebGLProgram {
  58149. transformFeedback?: WebGLTransformFeedback | null;
  58150. __SPECTOR_rebuildProgram?: ((vertexSourceCode: string, fragmentSourceCode: string, onCompiled: (program: WebGLProgram) => void, onError: (message: string) => void) => void) | null;
  58151. }
  58152. interface EXT_disjoint_timer_query {
  58153. QUERY_COUNTER_BITS_EXT: number;
  58154. TIME_ELAPSED_EXT: number;
  58155. TIMESTAMP_EXT: number;
  58156. GPU_DISJOINT_EXT: number;
  58157. QUERY_RESULT_EXT: number;
  58158. QUERY_RESULT_AVAILABLE_EXT: number;
  58159. queryCounterEXT(query: WebGLQuery, target: number): void;
  58160. createQueryEXT(): WebGLQuery;
  58161. beginQueryEXT(target: number, query: WebGLQuery): void;
  58162. endQueryEXT(target: number): void;
  58163. getQueryObjectEXT(query: WebGLQuery, target: number): any;
  58164. deleteQueryEXT(query: WebGLQuery): void;
  58165. }
  58166. interface WebGLUniformLocation {
  58167. _currentState: any;
  58168. }
  58169. // Type definitions for WebGL 2, Editor's Draft Fri Feb 24 16:10:18 2017 -0800
  58170. // Project: https://www.khronos.org/registry/webgl/specs/latest/2.0/
  58171. // Definitions by: Nico Kemnitz <https://github.com/nkemnitz/>
  58172. // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
  58173. interface WebGLRenderingContext {
  58174. readonly RASTERIZER_DISCARD: number;
  58175. readonly DEPTH_COMPONENT24: number;
  58176. readonly TEXTURE_3D: number;
  58177. readonly TEXTURE_2D_ARRAY: number;
  58178. readonly TEXTURE_COMPARE_FUNC: number;
  58179. readonly TEXTURE_COMPARE_MODE: number;
  58180. readonly COMPARE_REF_TO_TEXTURE: number;
  58181. readonly TEXTURE_WRAP_R: number;
  58182. readonly HALF_FLOAT: number;
  58183. readonly RGB8: number;
  58184. readonly RED_INTEGER: number;
  58185. readonly RG_INTEGER: number;
  58186. readonly RGB_INTEGER: number;
  58187. readonly RGBA_INTEGER: number;
  58188. readonly R8_SNORM: number;
  58189. readonly RG8_SNORM: number;
  58190. readonly RGB8_SNORM: number;
  58191. readonly RGBA8_SNORM: number;
  58192. readonly R8I: number;
  58193. readonly RG8I: number;
  58194. readonly RGB8I: number;
  58195. readonly RGBA8I: number;
  58196. readonly R8UI: number;
  58197. readonly RG8UI: number;
  58198. readonly RGB8UI: number;
  58199. readonly RGBA8UI: number;
  58200. readonly R16I: number;
  58201. readonly RG16I: number;
  58202. readonly RGB16I: number;
  58203. readonly RGBA16I: number;
  58204. readonly R16UI: number;
  58205. readonly RG16UI: number;
  58206. readonly RGB16UI: number;
  58207. readonly RGBA16UI: number;
  58208. readonly R32I: number;
  58209. readonly RG32I: number;
  58210. readonly RGB32I: number;
  58211. readonly RGBA32I: number;
  58212. readonly R32UI: number;
  58213. readonly RG32UI: number;
  58214. readonly RGB32UI: number;
  58215. readonly RGBA32UI: number;
  58216. readonly RGB10_A2UI: number;
  58217. readonly R11F_G11F_B10F: number;
  58218. readonly RGB9_E5: number;
  58219. readonly RGB10_A2: number;
  58220. readonly UNSIGNED_INT_2_10_10_10_REV: number;
  58221. readonly UNSIGNED_INT_10F_11F_11F_REV: number;
  58222. readonly UNSIGNED_INT_5_9_9_9_REV: number;
  58223. readonly FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  58224. texImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, format: number, type: number, pixels: ArrayBufferView | null): void;
  58225. texImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, format: number, type: number, pixels: ArrayBufferView, offset: number): void;
  58226. 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;
  58227. compressedTexImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, data: ArrayBufferView, offset?: number, length?: number): void;
  58228. readonly TRANSFORM_FEEDBACK: number;
  58229. readonly INTERLEAVED_ATTRIBS: number;
  58230. readonly TRANSFORM_FEEDBACK_BUFFER: number;
  58231. createTransformFeedback(): WebGLTransformFeedback;
  58232. deleteTransformFeedback(transformFeedbac: WebGLTransformFeedback): void;
  58233. bindTransformFeedback(target: number, transformFeedback: WebGLTransformFeedback | null): void;
  58234. beginTransformFeedback(primitiveMode: number): void;
  58235. endTransformFeedback(): void;
  58236. transformFeedbackVaryings(program: WebGLProgram, varyings: string[], bufferMode: number): void;
  58237. clearBufferfv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  58238. clearBufferiv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  58239. clearBufferuiv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  58240. clearBufferfi(buffer: number, drawbuffer: number, depth: number, stencil: number): void;
  58241. }
  58242. interface ImageBitmap {
  58243. readonly width: number;
  58244. readonly height: number;
  58245. close(): void;
  58246. }
  58247. interface WebGLQuery extends WebGLObject {
  58248. }
  58249. declare var WebGLQuery: {
  58250. prototype: WebGLQuery;
  58251. new(): WebGLQuery;
  58252. };
  58253. interface WebGLSampler extends WebGLObject {
  58254. }
  58255. declare var WebGLSampler: {
  58256. prototype: WebGLSampler;
  58257. new(): WebGLSampler;
  58258. };
  58259. interface WebGLSync extends WebGLObject {
  58260. }
  58261. declare var WebGLSync: {
  58262. prototype: WebGLSync;
  58263. new(): WebGLSync;
  58264. };
  58265. interface WebGLTransformFeedback extends WebGLObject {
  58266. }
  58267. declare var WebGLTransformFeedback: {
  58268. prototype: WebGLTransformFeedback;
  58269. new(): WebGLTransformFeedback;
  58270. };
  58271. interface WebGLVertexArrayObject extends WebGLObject {
  58272. }
  58273. declare var WebGLVertexArrayObject: {
  58274. prototype: WebGLVertexArrayObject;
  58275. new(): WebGLVertexArrayObject;
  58276. };
  58277. // Type definitions for WebVR API
  58278. // Project: https://w3c.github.io/webvr/
  58279. // Definitions by: six a <https://github.com/lostfictions>
  58280. // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
  58281. interface VRDisplay extends EventTarget {
  58282. /**
  58283. * Dictionary of capabilities describing the VRDisplay.
  58284. */
  58285. readonly capabilities: VRDisplayCapabilities;
  58286. /**
  58287. * z-depth defining the far plane of the eye view frustum
  58288. * enables mapping of values in the render target depth
  58289. * attachment to scene coordinates. Initially set to 10000.0.
  58290. */
  58291. depthFar: number;
  58292. /**
  58293. * z-depth defining the near plane of the eye view frustum
  58294. * enables mapping of values in the render target depth
  58295. * attachment to scene coordinates. Initially set to 0.01.
  58296. */
  58297. depthNear: number;
  58298. /**
  58299. * An identifier for this distinct VRDisplay. Used as an
  58300. * association point in the Gamepad API.
  58301. */
  58302. readonly displayId: number;
  58303. /**
  58304. * A display name, a user-readable name identifying it.
  58305. */
  58306. readonly displayName: string;
  58307. readonly isConnected: boolean;
  58308. readonly isPresenting: boolean;
  58309. /**
  58310. * If this VRDisplay supports room-scale experiences, the optional
  58311. * stage attribute contains details on the room-scale parameters.
  58312. */
  58313. readonly stageParameters: VRStageParameters | null;
  58314. /**
  58315. * Passing the value returned by `requestAnimationFrame` to
  58316. * `cancelAnimationFrame` will unregister the callback.
  58317. * @param handle Define the hanle of the request to cancel
  58318. */
  58319. cancelAnimationFrame(handle: number): void;
  58320. /**
  58321. * Stops presenting to the VRDisplay.
  58322. * @returns a promise to know when it stopped
  58323. */
  58324. exitPresent(): Promise<void>;
  58325. /**
  58326. * Return the current VREyeParameters for the given eye.
  58327. * @param whichEye Define the eye we want the parameter for
  58328. * @returns the eye parameters
  58329. */
  58330. getEyeParameters(whichEye: string): VREyeParameters;
  58331. /**
  58332. * Populates the passed VRFrameData with the information required to render
  58333. * the current frame.
  58334. * @param frameData Define the data structure to populate
  58335. * @returns true if ok otherwise false
  58336. */
  58337. getFrameData(frameData: VRFrameData): boolean;
  58338. /**
  58339. * Get the layers currently being presented.
  58340. * @returns the list of VR layers
  58341. */
  58342. getLayers(): VRLayer[];
  58343. /**
  58344. * Return a VRPose containing the future predicted pose of the VRDisplay
  58345. * when the current frame will be presented. The value returned will not
  58346. * change until JavaScript has returned control to the browser.
  58347. *
  58348. * The VRPose will contain the position, orientation, velocity,
  58349. * and acceleration of each of these properties.
  58350. * @returns the pose object
  58351. */
  58352. getPose(): VRPose;
  58353. /**
  58354. * Return the current instantaneous pose of the VRDisplay, with no
  58355. * prediction applied.
  58356. * @returns the current instantaneous pose
  58357. */
  58358. getImmediatePose(): VRPose;
  58359. /**
  58360. * The callback passed to `requestAnimationFrame` will be called
  58361. * any time a new frame should be rendered. When the VRDisplay is
  58362. * presenting the callback will be called at the native refresh
  58363. * rate of the HMD. When not presenting this function acts
  58364. * identically to how window.requestAnimationFrame acts. Content should
  58365. * make no assumptions of frame rate or vsync behavior as the HMD runs
  58366. * asynchronously from other displays and at differing refresh rates.
  58367. * @param callback Define the eaction to run next frame
  58368. * @returns the request handle it
  58369. */
  58370. requestAnimationFrame(callback: FrameRequestCallback): number;
  58371. /**
  58372. * Begin presenting to the VRDisplay. Must be called in response to a user gesture.
  58373. * Repeat calls while already presenting will update the VRLayers being displayed.
  58374. * @param layers Define the list of layer to present
  58375. * @returns a promise to know when the request has been fulfilled
  58376. */
  58377. requestPresent(layers: VRLayer[]): Promise<void>;
  58378. /**
  58379. * Reset the pose for this display, treating its current position and
  58380. * orientation as the "origin/zero" values. VRPose.position,
  58381. * VRPose.orientation, and VRStageParameters.sittingToStandingTransform may be
  58382. * updated when calling resetPose(). This should be called in only
  58383. * sitting-space experiences.
  58384. */
  58385. resetPose(): void;
  58386. /**
  58387. * The VRLayer provided to the VRDisplay will be captured and presented
  58388. * in the HMD. Calling this function has the same effect on the source
  58389. * canvas as any other operation that uses its source image, and canvases
  58390. * created without preserveDrawingBuffer set to true will be cleared.
  58391. * @param pose Define the pose to submit
  58392. */
  58393. submitFrame(pose?: VRPose): void;
  58394. }
  58395. declare var VRDisplay: {
  58396. prototype: VRDisplay;
  58397. new(): VRDisplay;
  58398. };
  58399. interface VRLayer {
  58400. leftBounds?: number[] | Float32Array | null;
  58401. rightBounds?: number[] | Float32Array | null;
  58402. source?: HTMLCanvasElement | null;
  58403. }
  58404. interface VRDisplayCapabilities {
  58405. readonly canPresent: boolean;
  58406. readonly hasExternalDisplay: boolean;
  58407. readonly hasOrientation: boolean;
  58408. readonly hasPosition: boolean;
  58409. readonly maxLayers: number;
  58410. }
  58411. interface VREyeParameters {
  58412. /** @deprecated */
  58413. readonly fieldOfView: VRFieldOfView;
  58414. readonly offset: Float32Array;
  58415. readonly renderHeight: number;
  58416. readonly renderWidth: number;
  58417. }
  58418. interface VRFieldOfView {
  58419. readonly downDegrees: number;
  58420. readonly leftDegrees: number;
  58421. readonly rightDegrees: number;
  58422. readonly upDegrees: number;
  58423. }
  58424. interface VRFrameData {
  58425. readonly leftProjectionMatrix: Float32Array;
  58426. readonly leftViewMatrix: Float32Array;
  58427. readonly pose: VRPose;
  58428. readonly rightProjectionMatrix: Float32Array;
  58429. readonly rightViewMatrix: Float32Array;
  58430. readonly timestamp: number;
  58431. }
  58432. interface VRPose {
  58433. readonly angularAcceleration: Float32Array | null;
  58434. readonly angularVelocity: Float32Array | null;
  58435. readonly linearAcceleration: Float32Array | null;
  58436. readonly linearVelocity: Float32Array | null;
  58437. readonly orientation: Float32Array | null;
  58438. readonly position: Float32Array | null;
  58439. readonly timestamp: number;
  58440. }
  58441. interface VRStageParameters {
  58442. sittingToStandingTransform?: Float32Array;
  58443. sizeX?: number;
  58444. sizeY?: number;
  58445. }
  58446. interface Navigator {
  58447. getVRDisplays(): Promise<VRDisplay[]>;
  58448. readonly activeVRDisplays: ReadonlyArray<VRDisplay>;
  58449. }
  58450. interface Window {
  58451. onvrdisplayconnected: ((this: Window, ev: Event) => any) | null;
  58452. onvrdisplaydisconnected: ((this: Window, ev: Event) => any) | null;
  58453. onvrdisplaypresentchange: ((this: Window, ev: Event) => any) | null;
  58454. addEventListener(type: "vrdisplayconnected", listener: (ev: Event) => any, useCapture?: boolean): void;
  58455. addEventListener(type: "vrdisplaydisconnected", listener: (ev: Event) => any, useCapture?: boolean): void;
  58456. addEventListener(type: "vrdisplaypresentchange", listener: (ev: Event) => any, useCapture?: boolean): void;
  58457. }
  58458. interface Gamepad {
  58459. readonly displayId: number;
  58460. }
  58461. interface XRDevice {
  58462. requestSession(options: XRSessionCreationOptions): Promise<XRSession>;
  58463. supportsSession(options: XRSessionCreationOptions): Promise<void>;
  58464. }
  58465. interface XRSession {
  58466. getInputSources(): Array<any>;
  58467. baseLayer: XRWebGLLayer;
  58468. requestFrameOfReference(type: string): Promise<void>;
  58469. requestHitTest(origin: Float32Array, direction: Float32Array, frameOfReference: any): any;
  58470. end(): Promise<void>;
  58471. requestAnimationFrame: Function;
  58472. addEventListener: Function;
  58473. }
  58474. interface XRSessionCreationOptions {
  58475. outputContext?: WebGLRenderingContext | null;
  58476. immersive?: boolean;
  58477. environmentIntegration?: boolean;
  58478. }
  58479. interface XRLayer {
  58480. getViewport: Function;
  58481. framebufferWidth: number;
  58482. framebufferHeight: number;
  58483. }
  58484. interface XRView {
  58485. projectionMatrix: Float32Array;
  58486. }
  58487. interface XRFrame {
  58488. getDevicePose: Function;
  58489. getInputPose: Function;
  58490. views: Array<XRView>;
  58491. baseLayer: XRLayer;
  58492. }
  58493. interface XRFrameOfReference {
  58494. }
  58495. interface XRWebGLLayer extends XRLayer {
  58496. framebuffer: WebGLFramebuffer;
  58497. }
  58498. declare var XRWebGLLayer: {
  58499. prototype: XRWebGLLayer;
  58500. new(session: XRSession, context?: WebGLRenderingContext): XRWebGLLayer;
  58501. };
  58502. declare module "babylonjs" {
  58503. export * from "babylonjs/Legacy/legacy";
  58504. }
  58505. declare module BABYLON {
  58506. /** Alias type for value that can be null */
  58507. export type Nullable<T> = T | null;
  58508. /**
  58509. * Alias type for number that are floats
  58510. * @ignorenaming
  58511. */
  58512. export type float = number;
  58513. /**
  58514. * Alias type for number that are doubles.
  58515. * @ignorenaming
  58516. */
  58517. export type double = number;
  58518. /**
  58519. * Alias type for number that are integer
  58520. * @ignorenaming
  58521. */
  58522. export type int = number;
  58523. /** Alias type for number array or Float32Array */
  58524. export type FloatArray = number[] | Float32Array;
  58525. /** Alias type for number array or Float32Array or Int32Array or Uint32Array or Uint16Array */
  58526. export type IndicesArray = number[] | Int32Array | Uint32Array | Uint16Array;
  58527. /**
  58528. * Alias for types that can be used by a Buffer or VertexBuffer.
  58529. */
  58530. export type DataArray = number[] | ArrayBuffer | ArrayBufferView;
  58531. /**
  58532. * Alias type for primitive types
  58533. * @ignorenaming
  58534. */
  58535. type Primitive = undefined | null | boolean | string | number | Function;
  58536. /**
  58537. * Type modifier to make all the properties of an object Readonly
  58538. */
  58539. export type Immutable<T> = T extends Primitive ? T : T extends Array<infer U> ? ReadonlyArray<U> : DeepImmutable<T>;
  58540. /**
  58541. * Type modifier to make all the properties of an object Readonly recursively
  58542. */
  58543. export type DeepImmutable<T> = T extends Primitive ? T : T extends Array<infer U> ? DeepImmutableArray<U> : DeepImmutableObject<T>;
  58544. /** @hidden */
  58545. interface DeepImmutableArray<T> extends ReadonlyArray<DeepImmutable<T>> {
  58546. }
  58547. /** @hidden */
  58548. /** @hidden */
  58549. type DeepImmutableObject<T> = {
  58550. readonly [K in keyof T]: DeepImmutable<T[K]>;
  58551. };
  58552. }
  58553. declare module BABYLON {
  58554. /**
  58555. * Class containing a set of static utilities functions for arrays.
  58556. */
  58557. export class ArrayTools {
  58558. /**
  58559. * Returns an array of the given size filled with element built from the given constructor and the paramters
  58560. * @param size the number of element to construct and put in the array
  58561. * @param itemBuilder a callback responsible for creating new instance of item. Called once per array entry.
  58562. * @returns a new array filled with new objects
  58563. */
  58564. static BuildArray<T>(size: number, itemBuilder: () => T): Array<T>;
  58565. }
  58566. }
  58567. declare module BABYLON {
  58568. /**
  58569. * Scalar computation library
  58570. */
  58571. export class Scalar {
  58572. /**
  58573. * Two pi constants convenient for computation.
  58574. */
  58575. static TwoPi: number;
  58576. /**
  58577. * Boolean : true if the absolute difference between a and b is lower than epsilon (default = 1.401298E-45)
  58578. * @param a number
  58579. * @param b number
  58580. * @param epsilon (default = 1.401298E-45)
  58581. * @returns true if the absolute difference between a and b is lower than epsilon (default = 1.401298E-45)
  58582. */
  58583. static WithinEpsilon(a: number, b: number, epsilon?: number): boolean;
  58584. /**
  58585. * Returns a string : the upper case translation of the number i to hexadecimal.
  58586. * @param i number
  58587. * @returns the upper case translation of the number i to hexadecimal.
  58588. */
  58589. static ToHex(i: number): string;
  58590. /**
  58591. * Returns -1 if value is negative and +1 is value is positive.
  58592. * @param value the value
  58593. * @returns the value itself if it's equal to zero.
  58594. */
  58595. static Sign(value: number): number;
  58596. /**
  58597. * Returns the value itself if it's between min and max.
  58598. * Returns min if the value is lower than min.
  58599. * Returns max if the value is greater than max.
  58600. * @param value the value to clmap
  58601. * @param min the min value to clamp to (default: 0)
  58602. * @param max the max value to clamp to (default: 1)
  58603. * @returns the clamped value
  58604. */
  58605. static Clamp(value: number, min?: number, max?: number): number;
  58606. /**
  58607. * the log2 of value.
  58608. * @param value the value to compute log2 of
  58609. * @returns the log2 of value.
  58610. */
  58611. static Log2(value: number): number;
  58612. /**
  58613. * Loops the value, so that it is never larger than length and never smaller than 0.
  58614. *
  58615. * This is similar to the modulo operator but it works with floating point numbers.
  58616. * For example, using 3.0 for t and 2.5 for length, the result would be 0.5.
  58617. * With t = 5 and length = 2.5, the result would be 0.0.
  58618. * Note, however, that the behaviour is not defined for negative numbers as it is for the modulo operator
  58619. * @param value the value
  58620. * @param length the length
  58621. * @returns the looped value
  58622. */
  58623. static Repeat(value: number, length: number): number;
  58624. /**
  58625. * Normalize the value between 0.0 and 1.0 using min and max values
  58626. * @param value value to normalize
  58627. * @param min max to normalize between
  58628. * @param max min to normalize between
  58629. * @returns the normalized value
  58630. */
  58631. static Normalize(value: number, min: number, max: number): number;
  58632. /**
  58633. * Denormalize the value from 0.0 and 1.0 using min and max values
  58634. * @param normalized value to denormalize
  58635. * @param min max to denormalize between
  58636. * @param max min to denormalize between
  58637. * @returns the denormalized value
  58638. */
  58639. static Denormalize(normalized: number, min: number, max: number): number;
  58640. /**
  58641. * Calculates the shortest difference between two given angles given in degrees.
  58642. * @param current current angle in degrees
  58643. * @param target target angle in degrees
  58644. * @returns the delta
  58645. */
  58646. static DeltaAngle(current: number, target: number): number;
  58647. /**
  58648. * PingPongs the value t, so that it is never larger than length and never smaller than 0.
  58649. * @param tx value
  58650. * @param length length
  58651. * @returns The returned value will move back and forth between 0 and length
  58652. */
  58653. static PingPong(tx: number, length: number): number;
  58654. /**
  58655. * Interpolates between min and max with smoothing at the limits.
  58656. *
  58657. * This function interpolates between min and max in a similar way to Lerp. However, the interpolation will gradually speed up
  58658. * from the start and slow down toward the end. This is useful for creating natural-looking animation, fading and other transitions.
  58659. * @param from from
  58660. * @param to to
  58661. * @param tx value
  58662. * @returns the smooth stepped value
  58663. */
  58664. static SmoothStep(from: number, to: number, tx: number): number;
  58665. /**
  58666. * Moves a value current towards target.
  58667. *
  58668. * This is essentially the same as Mathf.Lerp but instead the function will ensure that the speed never exceeds maxDelta.
  58669. * Negative values of maxDelta pushes the value away from target.
  58670. * @param current current value
  58671. * @param target target value
  58672. * @param maxDelta max distance to move
  58673. * @returns resulting value
  58674. */
  58675. static MoveTowards(current: number, target: number, maxDelta: number): number;
  58676. /**
  58677. * Same as MoveTowards but makes sure the values interpolate correctly when they wrap around 360 degrees.
  58678. *
  58679. * Variables current and target are assumed to be in degrees. For optimization reasons, negative values of maxDelta
  58680. * are not supported and may cause oscillation. To push current away from a target angle, add 180 to that angle instead.
  58681. * @param current current value
  58682. * @param target target value
  58683. * @param maxDelta max distance to move
  58684. * @returns resulting angle
  58685. */
  58686. static MoveTowardsAngle(current: number, target: number, maxDelta: number): number;
  58687. /**
  58688. * Creates a new scalar with values linearly interpolated of "amount" between the start scalar and the end scalar.
  58689. * @param start start value
  58690. * @param end target value
  58691. * @param amount amount to lerp between
  58692. * @returns the lerped value
  58693. */
  58694. static Lerp(start: number, end: number, amount: number): number;
  58695. /**
  58696. * Same as Lerp but makes sure the values interpolate correctly when they wrap around 360 degrees.
  58697. * The parameter t is clamped to the range [0, 1]. Variables a and b are assumed to be in degrees.
  58698. * @param start start value
  58699. * @param end target value
  58700. * @param amount amount to lerp between
  58701. * @returns the lerped value
  58702. */
  58703. static LerpAngle(start: number, end: number, amount: number): number;
  58704. /**
  58705. * Calculates the linear parameter t that produces the interpolant value within the range [a, b].
  58706. * @param a start value
  58707. * @param b target value
  58708. * @param value value between a and b
  58709. * @returns the inverseLerp value
  58710. */
  58711. static InverseLerp(a: number, b: number, value: number): number;
  58712. /**
  58713. * Returns a new scalar located for "amount" (float) on the Hermite spline defined by the scalars "value1", "value3", "tangent1", "tangent2".
  58714. * @see http://mathworld.wolfram.com/HermitePolynomial.html
  58715. * @param value1 spline value
  58716. * @param tangent1 spline value
  58717. * @param value2 spline value
  58718. * @param tangent2 spline value
  58719. * @param amount input value
  58720. * @returns hermite result
  58721. */
  58722. static Hermite(value1: number, tangent1: number, value2: number, tangent2: number, amount: number): number;
  58723. /**
  58724. * Returns a random float number between and min and max values
  58725. * @param min min value of random
  58726. * @param max max value of random
  58727. * @returns random value
  58728. */
  58729. static RandomRange(min: number, max: number): number;
  58730. /**
  58731. * This function returns percentage of a number in a given range.
  58732. *
  58733. * RangeToPercent(40,20,60) will return 0.5 (50%)
  58734. * RangeToPercent(34,0,100) will return 0.34 (34%)
  58735. * @param number to convert to percentage
  58736. * @param min min range
  58737. * @param max max range
  58738. * @returns the percentage
  58739. */
  58740. static RangeToPercent(number: number, min: number, max: number): number;
  58741. /**
  58742. * This function returns number that corresponds to the percentage in a given range.
  58743. *
  58744. * PercentToRange(0.34,0,100) will return 34.
  58745. * @param percent to convert to number
  58746. * @param min min range
  58747. * @param max max range
  58748. * @returns the number
  58749. */
  58750. static PercentToRange(percent: number, min: number, max: number): number;
  58751. /**
  58752. * Returns the angle converted to equivalent value between -Math.PI and Math.PI radians.
  58753. * @param angle The angle to normalize in radian.
  58754. * @return The converted angle.
  58755. */
  58756. static NormalizeRadians(angle: number): number;
  58757. }
  58758. }
  58759. declare module BABYLON {
  58760. /**
  58761. * Constant used to convert a value to gamma space
  58762. * @ignorenaming
  58763. */
  58764. export const ToGammaSpace: number;
  58765. /**
  58766. * Constant used to convert a value to linear space
  58767. * @ignorenaming
  58768. */
  58769. export const ToLinearSpace = 2.2;
  58770. /**
  58771. * Constant used to define the minimal number value in Babylon.js
  58772. * @ignorenaming
  58773. */
  58774. export const Epsilon = 0.001;
  58775. /**
  58776. * Class used to hold a RBG color
  58777. */
  58778. export class Color3 {
  58779. /**
  58780. * Defines the red component (between 0 and 1, default is 0)
  58781. */
  58782. r: number;
  58783. /**
  58784. * Defines the green component (between 0 and 1, default is 0)
  58785. */
  58786. g: number;
  58787. /**
  58788. * Defines the blue component (between 0 and 1, default is 0)
  58789. */
  58790. b: number;
  58791. /**
  58792. * Creates a new Color3 object from red, green, blue values, all between 0 and 1
  58793. * @param r defines the red component (between 0 and 1, default is 0)
  58794. * @param g defines the green component (between 0 and 1, default is 0)
  58795. * @param b defines the blue component (between 0 and 1, default is 0)
  58796. */
  58797. constructor(
  58798. /**
  58799. * Defines the red component (between 0 and 1, default is 0)
  58800. */
  58801. r?: number,
  58802. /**
  58803. * Defines the green component (between 0 and 1, default is 0)
  58804. */
  58805. g?: number,
  58806. /**
  58807. * Defines the blue component (between 0 and 1, default is 0)
  58808. */
  58809. b?: number);
  58810. /**
  58811. * Creates a string with the Color3 current values
  58812. * @returns the string representation of the Color3 object
  58813. */
  58814. toString(): string;
  58815. /**
  58816. * Returns the string "Color3"
  58817. * @returns "Color3"
  58818. */
  58819. getClassName(): string;
  58820. /**
  58821. * Compute the Color3 hash code
  58822. * @returns an unique number that can be used to hash Color3 objects
  58823. */
  58824. getHashCode(): number;
  58825. /**
  58826. * Stores in the given array from the given starting index the red, green, blue values as successive elements
  58827. * @param array defines the array where to store the r,g,b components
  58828. * @param index defines an optional index in the target array to define where to start storing values
  58829. * @returns the current Color3 object
  58830. */
  58831. toArray(array: FloatArray, index?: number): Color3;
  58832. /**
  58833. * Returns a new Color4 object from the current Color3 and the given alpha
  58834. * @param alpha defines the alpha component on the new Color4 object (default is 1)
  58835. * @returns a new Color4 object
  58836. */
  58837. toColor4(alpha?: number): Color4;
  58838. /**
  58839. * Returns a new array populated with 3 numeric elements : red, green and blue values
  58840. * @returns the new array
  58841. */
  58842. asArray(): number[];
  58843. /**
  58844. * Returns the luminance value
  58845. * @returns a float value
  58846. */
  58847. toLuminance(): number;
  58848. /**
  58849. * Multiply each Color3 rgb values by the given Color3 rgb values in a new Color3 object
  58850. * @param otherColor defines the second operand
  58851. * @returns the new Color3 object
  58852. */
  58853. multiply(otherColor: DeepImmutable<Color3>): Color3;
  58854. /**
  58855. * Multiply the rgb values of the Color3 and the given Color3 and stores the result in the object "result"
  58856. * @param otherColor defines the second operand
  58857. * @param result defines the Color3 object where to store the result
  58858. * @returns the current Color3
  58859. */
  58860. multiplyToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  58861. /**
  58862. * Determines equality between Color3 objects
  58863. * @param otherColor defines the second operand
  58864. * @returns true if the rgb values are equal to the given ones
  58865. */
  58866. equals(otherColor: DeepImmutable<Color3>): boolean;
  58867. /**
  58868. * Determines equality between the current Color3 object and a set of r,b,g values
  58869. * @param r defines the red component to check
  58870. * @param g defines the green component to check
  58871. * @param b defines the blue component to check
  58872. * @returns true if the rgb values are equal to the given ones
  58873. */
  58874. equalsFloats(r: number, g: number, b: number): boolean;
  58875. /**
  58876. * Multiplies in place each rgb value by scale
  58877. * @param scale defines the scaling factor
  58878. * @returns the updated Color3
  58879. */
  58880. scale(scale: number): Color3;
  58881. /**
  58882. * Multiplies the rgb values by scale and stores the result into "result"
  58883. * @param scale defines the scaling factor
  58884. * @param result defines the Color3 object where to store the result
  58885. * @returns the unmodified current Color3
  58886. */
  58887. scaleToRef(scale: number, result: Color3): Color3;
  58888. /**
  58889. * Scale the current Color3 values by a factor and add the result to a given Color3
  58890. * @param scale defines the scale factor
  58891. * @param result defines color to store the result into
  58892. * @returns the unmodified current Color3
  58893. */
  58894. scaleAndAddToRef(scale: number, result: Color3): Color3;
  58895. /**
  58896. * Clamps the rgb values by the min and max values and stores the result into "result"
  58897. * @param min defines minimum clamping value (default is 0)
  58898. * @param max defines maximum clamping value (default is 1)
  58899. * @param result defines color to store the result into
  58900. * @returns the original Color3
  58901. */
  58902. clampToRef(min: number | undefined, max: number | undefined, result: Color3): Color3;
  58903. /**
  58904. * Creates a new Color3 set with the added values of the current Color3 and of the given one
  58905. * @param otherColor defines the second operand
  58906. * @returns the new Color3
  58907. */
  58908. add(otherColor: DeepImmutable<Color3>): Color3;
  58909. /**
  58910. * Stores the result of the addition of the current Color3 and given one rgb values into "result"
  58911. * @param otherColor defines the second operand
  58912. * @param result defines Color3 object to store the result into
  58913. * @returns the unmodified current Color3
  58914. */
  58915. addToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  58916. /**
  58917. * Returns a new Color3 set with the subtracted values of the given one from the current Color3
  58918. * @param otherColor defines the second operand
  58919. * @returns the new Color3
  58920. */
  58921. subtract(otherColor: DeepImmutable<Color3>): Color3;
  58922. /**
  58923. * Stores the result of the subtraction of given one from the current Color3 rgb values into "result"
  58924. * @param otherColor defines the second operand
  58925. * @param result defines Color3 object to store the result into
  58926. * @returns the unmodified current Color3
  58927. */
  58928. subtractToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  58929. /**
  58930. * Copy the current object
  58931. * @returns a new Color3 copied the current one
  58932. */
  58933. clone(): Color3;
  58934. /**
  58935. * Copies the rgb values from the source in the current Color3
  58936. * @param source defines the source Color3 object
  58937. * @returns the updated Color3 object
  58938. */
  58939. copyFrom(source: DeepImmutable<Color3>): Color3;
  58940. /**
  58941. * Updates the Color3 rgb values from the given floats
  58942. * @param r defines the red component to read from
  58943. * @param g defines the green component to read from
  58944. * @param b defines the blue component to read from
  58945. * @returns the current Color3 object
  58946. */
  58947. copyFromFloats(r: number, g: number, b: number): Color3;
  58948. /**
  58949. * Updates the Color3 rgb values from the given floats
  58950. * @param r defines the red component to read from
  58951. * @param g defines the green component to read from
  58952. * @param b defines the blue component to read from
  58953. * @returns the current Color3 object
  58954. */
  58955. set(r: number, g: number, b: number): Color3;
  58956. /**
  58957. * Compute the Color3 hexadecimal code as a string
  58958. * @returns a string containing the hexadecimal representation of the Color3 object
  58959. */
  58960. toHexString(): string;
  58961. /**
  58962. * Computes a new Color3 converted from the current one to linear space
  58963. * @returns a new Color3 object
  58964. */
  58965. toLinearSpace(): Color3;
  58966. /**
  58967. * Converts the Color3 values to linear space and stores the result in "convertedColor"
  58968. * @param convertedColor defines the Color3 object where to store the linear space version
  58969. * @returns the unmodified Color3
  58970. */
  58971. toLinearSpaceToRef(convertedColor: Color3): Color3;
  58972. /**
  58973. * Computes a new Color3 converted from the current one to gamma space
  58974. * @returns a new Color3 object
  58975. */
  58976. toGammaSpace(): Color3;
  58977. /**
  58978. * Converts the Color3 values to gamma space and stores the result in "convertedColor"
  58979. * @param convertedColor defines the Color3 object where to store the gamma space version
  58980. * @returns the unmodified Color3
  58981. */
  58982. toGammaSpaceToRef(convertedColor: Color3): Color3;
  58983. private static _BlackReadOnly;
  58984. /**
  58985. * Creates a new Color3 from the string containing valid hexadecimal values
  58986. * @param hex defines a string containing valid hexadecimal values
  58987. * @returns a new Color3 object
  58988. */
  58989. static FromHexString(hex: string): Color3;
  58990. /**
  58991. * Creates a new Vector3 from the starting index of the given array
  58992. * @param array defines the source array
  58993. * @param offset defines an offset in the source array
  58994. * @returns a new Color3 object
  58995. */
  58996. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color3;
  58997. /**
  58998. * Creates a new Color3 from integer values (< 256)
  58999. * @param r defines the red component to read from (value between 0 and 255)
  59000. * @param g defines the green component to read from (value between 0 and 255)
  59001. * @param b defines the blue component to read from (value between 0 and 255)
  59002. * @returns a new Color3 object
  59003. */
  59004. static FromInts(r: number, g: number, b: number): Color3;
  59005. /**
  59006. * Creates a new Color3 with values linearly interpolated of "amount" between the start Color3 and the end Color3
  59007. * @param start defines the start Color3 value
  59008. * @param end defines the end Color3 value
  59009. * @param amount defines the gradient value between start and end
  59010. * @returns a new Color3 object
  59011. */
  59012. static Lerp(start: DeepImmutable<Color3>, end: DeepImmutable<Color3>, amount: number): Color3;
  59013. /**
  59014. * Creates a new Color3 with values linearly interpolated of "amount" between the start Color3 and the end Color3
  59015. * @param left defines the start value
  59016. * @param right defines the end value
  59017. * @param amount defines the gradient factor
  59018. * @param result defines the Color3 object where to store the result
  59019. */
  59020. static LerpToRef(left: DeepImmutable<Color3>, right: DeepImmutable<Color3>, amount: number, result: Color3): void;
  59021. /**
  59022. * Returns a Color3 value containing a red color
  59023. * @returns a new Color3 object
  59024. */
  59025. static Red(): Color3;
  59026. /**
  59027. * Returns a Color3 value containing a green color
  59028. * @returns a new Color3 object
  59029. */
  59030. static Green(): Color3;
  59031. /**
  59032. * Returns a Color3 value containing a blue color
  59033. * @returns a new Color3 object
  59034. */
  59035. static Blue(): Color3;
  59036. /**
  59037. * Returns a Color3 value containing a black color
  59038. * @returns a new Color3 object
  59039. */
  59040. static Black(): Color3;
  59041. /**
  59042. * Gets a Color3 value containing a black color that must not be updated
  59043. */
  59044. static readonly BlackReadOnly: DeepImmutable<Color3>;
  59045. /**
  59046. * Returns a Color3 value containing a white color
  59047. * @returns a new Color3 object
  59048. */
  59049. static White(): Color3;
  59050. /**
  59051. * Returns a Color3 value containing a purple color
  59052. * @returns a new Color3 object
  59053. */
  59054. static Purple(): Color3;
  59055. /**
  59056. * Returns a Color3 value containing a magenta color
  59057. * @returns a new Color3 object
  59058. */
  59059. static Magenta(): Color3;
  59060. /**
  59061. * Returns a Color3 value containing a yellow color
  59062. * @returns a new Color3 object
  59063. */
  59064. static Yellow(): Color3;
  59065. /**
  59066. * Returns a Color3 value containing a gray color
  59067. * @returns a new Color3 object
  59068. */
  59069. static Gray(): Color3;
  59070. /**
  59071. * Returns a Color3 value containing a teal color
  59072. * @returns a new Color3 object
  59073. */
  59074. static Teal(): Color3;
  59075. /**
  59076. * Returns a Color3 value containing a random color
  59077. * @returns a new Color3 object
  59078. */
  59079. static Random(): Color3;
  59080. }
  59081. /**
  59082. * Class used to hold a RBGA color
  59083. */
  59084. export class Color4 {
  59085. /**
  59086. * Defines the red component (between 0 and 1, default is 0)
  59087. */
  59088. r: number;
  59089. /**
  59090. * Defines the green component (between 0 and 1, default is 0)
  59091. */
  59092. g: number;
  59093. /**
  59094. * Defines the blue component (between 0 and 1, default is 0)
  59095. */
  59096. b: number;
  59097. /**
  59098. * Defines the alpha component (between 0 and 1, default is 1)
  59099. */
  59100. a: number;
  59101. /**
  59102. * Creates a new Color4 object from red, green, blue values, all between 0 and 1
  59103. * @param r defines the red component (between 0 and 1, default is 0)
  59104. * @param g defines the green component (between 0 and 1, default is 0)
  59105. * @param b defines the blue component (between 0 and 1, default is 0)
  59106. * @param a defines the alpha component (between 0 and 1, default is 1)
  59107. */
  59108. constructor(
  59109. /**
  59110. * Defines the red component (between 0 and 1, default is 0)
  59111. */
  59112. r?: number,
  59113. /**
  59114. * Defines the green component (between 0 and 1, default is 0)
  59115. */
  59116. g?: number,
  59117. /**
  59118. * Defines the blue component (between 0 and 1, default is 0)
  59119. */
  59120. b?: number,
  59121. /**
  59122. * Defines the alpha component (between 0 and 1, default is 1)
  59123. */
  59124. a?: number);
  59125. /**
  59126. * Adds in place the given Color4 values to the current Color4 object
  59127. * @param right defines the second operand
  59128. * @returns the current updated Color4 object
  59129. */
  59130. addInPlace(right: DeepImmutable<Color4>): Color4;
  59131. /**
  59132. * Creates a new array populated with 4 numeric elements : red, green, blue, alpha values
  59133. * @returns the new array
  59134. */
  59135. asArray(): number[];
  59136. /**
  59137. * Stores from the starting index in the given array the Color4 successive values
  59138. * @param array defines the array where to store the r,g,b components
  59139. * @param index defines an optional index in the target array to define where to start storing values
  59140. * @returns the current Color4 object
  59141. */
  59142. toArray(array: number[], index?: number): Color4;
  59143. /**
  59144. * Determines equality between Color4 objects
  59145. * @param otherColor defines the second operand
  59146. * @returns true if the rgba values are equal to the given ones
  59147. */
  59148. equals(otherColor: DeepImmutable<Color4>): boolean;
  59149. /**
  59150. * Creates a new Color4 set with the added values of the current Color4 and of the given one
  59151. * @param right defines the second operand
  59152. * @returns a new Color4 object
  59153. */
  59154. add(right: DeepImmutable<Color4>): Color4;
  59155. /**
  59156. * Creates a new Color4 set with the subtracted values of the given one from the current Color4
  59157. * @param right defines the second operand
  59158. * @returns a new Color4 object
  59159. */
  59160. subtract(right: DeepImmutable<Color4>): Color4;
  59161. /**
  59162. * Subtracts the given ones from the current Color4 values and stores the results in "result"
  59163. * @param right defines the second operand
  59164. * @param result defines the Color4 object where to store the result
  59165. * @returns the current Color4 object
  59166. */
  59167. subtractToRef(right: DeepImmutable<Color4>, result: Color4): Color4;
  59168. /**
  59169. * Creates a new Color4 with the current Color4 values multiplied by scale
  59170. * @param scale defines the scaling factor to apply
  59171. * @returns a new Color4 object
  59172. */
  59173. scale(scale: number): Color4;
  59174. /**
  59175. * Multiplies the current Color4 values by scale and stores the result in "result"
  59176. * @param scale defines the scaling factor to apply
  59177. * @param result defines the Color4 object where to store the result
  59178. * @returns the current unmodified Color4
  59179. */
  59180. scaleToRef(scale: number, result: Color4): Color4;
  59181. /**
  59182. * Scale the current Color4 values by a factor and add the result to a given Color4
  59183. * @param scale defines the scale factor
  59184. * @param result defines the Color4 object where to store the result
  59185. * @returns the unmodified current Color4
  59186. */
  59187. scaleAndAddToRef(scale: number, result: Color4): Color4;
  59188. /**
  59189. * Clamps the rgb values by the min and max values and stores the result into "result"
  59190. * @param min defines minimum clamping value (default is 0)
  59191. * @param max defines maximum clamping value (default is 1)
  59192. * @param result defines color to store the result into.
  59193. * @returns the cuurent Color4
  59194. */
  59195. clampToRef(min: number | undefined, max: number | undefined, result: Color4): Color4;
  59196. /**
  59197. * Multipy an Color4 value by another and return a new Color4 object
  59198. * @param color defines the Color4 value to multiply by
  59199. * @returns a new Color4 object
  59200. */
  59201. multiply(color: Color4): Color4;
  59202. /**
  59203. * Multipy a Color4 value by another and push the result in a reference value
  59204. * @param color defines the Color4 value to multiply by
  59205. * @param result defines the Color4 to fill the result in
  59206. * @returns the result Color4
  59207. */
  59208. multiplyToRef(color: Color4, result: Color4): Color4;
  59209. /**
  59210. * Creates a string with the Color4 current values
  59211. * @returns the string representation of the Color4 object
  59212. */
  59213. toString(): string;
  59214. /**
  59215. * Returns the string "Color4"
  59216. * @returns "Color4"
  59217. */
  59218. getClassName(): string;
  59219. /**
  59220. * Compute the Color4 hash code
  59221. * @returns an unique number that can be used to hash Color4 objects
  59222. */
  59223. getHashCode(): number;
  59224. /**
  59225. * Creates a new Color4 copied from the current one
  59226. * @returns a new Color4 object
  59227. */
  59228. clone(): Color4;
  59229. /**
  59230. * Copies the given Color4 values into the current one
  59231. * @param source defines the source Color4 object
  59232. * @returns the current updated Color4 object
  59233. */
  59234. copyFrom(source: Color4): Color4;
  59235. /**
  59236. * Copies the given float values into the current one
  59237. * @param r defines the red component to read from
  59238. * @param g defines the green component to read from
  59239. * @param b defines the blue component to read from
  59240. * @param a defines the alpha component to read from
  59241. * @returns the current updated Color4 object
  59242. */
  59243. copyFromFloats(r: number, g: number, b: number, a: number): Color4;
  59244. /**
  59245. * Copies the given float values into the current one
  59246. * @param r defines the red component to read from
  59247. * @param g defines the green component to read from
  59248. * @param b defines the blue component to read from
  59249. * @param a defines the alpha component to read from
  59250. * @returns the current updated Color4 object
  59251. */
  59252. set(r: number, g: number, b: number, a: number): Color4;
  59253. /**
  59254. * Compute the Color4 hexadecimal code as a string
  59255. * @returns a string containing the hexadecimal representation of the Color4 object
  59256. */
  59257. toHexString(): string;
  59258. /**
  59259. * Computes a new Color4 converted from the current one to linear space
  59260. * @returns a new Color4 object
  59261. */
  59262. toLinearSpace(): Color4;
  59263. /**
  59264. * Converts the Color4 values to linear space and stores the result in "convertedColor"
  59265. * @param convertedColor defines the Color4 object where to store the linear space version
  59266. * @returns the unmodified Color4
  59267. */
  59268. toLinearSpaceToRef(convertedColor: Color4): Color4;
  59269. /**
  59270. * Computes a new Color4 converted from the current one to gamma space
  59271. * @returns a new Color4 object
  59272. */
  59273. toGammaSpace(): Color4;
  59274. /**
  59275. * Converts the Color4 values to gamma space and stores the result in "convertedColor"
  59276. * @param convertedColor defines the Color4 object where to store the gamma space version
  59277. * @returns the unmodified Color4
  59278. */
  59279. toGammaSpaceToRef(convertedColor: Color4): Color4;
  59280. /**
  59281. * Creates a new Color4 from the string containing valid hexadecimal values
  59282. * @param hex defines a string containing valid hexadecimal values
  59283. * @returns a new Color4 object
  59284. */
  59285. static FromHexString(hex: string): Color4;
  59286. /**
  59287. * Creates a new Color4 object set with the linearly interpolated values of "amount" between the left Color4 object and the right Color4 object
  59288. * @param left defines the start value
  59289. * @param right defines the end value
  59290. * @param amount defines the gradient factor
  59291. * @returns a new Color4 object
  59292. */
  59293. static Lerp(left: DeepImmutable<Color4>, right: DeepImmutable<Color4>, amount: number): Color4;
  59294. /**
  59295. * Set the given "result" with the linearly interpolated values of "amount" between the left Color4 object and the right Color4 object
  59296. * @param left defines the start value
  59297. * @param right defines the end value
  59298. * @param amount defines the gradient factor
  59299. * @param result defines the Color4 object where to store data
  59300. */
  59301. static LerpToRef(left: DeepImmutable<Color4>, right: DeepImmutable<Color4>, amount: number, result: Color4): void;
  59302. /**
  59303. * Creates a new Color4 from a Color3 and an alpha value
  59304. * @param color3 defines the source Color3 to read from
  59305. * @param alpha defines the alpha component (1.0 by default)
  59306. * @returns a new Color4 object
  59307. */
  59308. static FromColor3(color3: DeepImmutable<Color3>, alpha?: number): Color4;
  59309. /**
  59310. * Creates a new Color4 from the starting index element of the given array
  59311. * @param array defines the source array to read from
  59312. * @param offset defines the offset in the source array
  59313. * @returns a new Color4 object
  59314. */
  59315. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color4;
  59316. /**
  59317. * Creates a new Color3 from integer values (< 256)
  59318. * @param r defines the red component to read from (value between 0 and 255)
  59319. * @param g defines the green component to read from (value between 0 and 255)
  59320. * @param b defines the blue component to read from (value between 0 and 255)
  59321. * @param a defines the alpha component to read from (value between 0 and 255)
  59322. * @returns a new Color3 object
  59323. */
  59324. static FromInts(r: number, g: number, b: number, a: number): Color4;
  59325. /**
  59326. * Check the content of a given array and convert it to an array containing RGBA data
  59327. * If the original array was already containing count * 4 values then it is returned directly
  59328. * @param colors defines the array to check
  59329. * @param count defines the number of RGBA data to expect
  59330. * @returns an array containing count * 4 values (RGBA)
  59331. */
  59332. static CheckColors4(colors: number[], count: number): number[];
  59333. }
  59334. /**
  59335. * Class representing a vector containing 2 coordinates
  59336. */
  59337. export class Vector2 {
  59338. /** defines the first coordinate */
  59339. x: number;
  59340. /** defines the second coordinate */
  59341. y: number;
  59342. /**
  59343. * Creates a new Vector2 from the given x and y coordinates
  59344. * @param x defines the first coordinate
  59345. * @param y defines the second coordinate
  59346. */
  59347. constructor(
  59348. /** defines the first coordinate */
  59349. x?: number,
  59350. /** defines the second coordinate */
  59351. y?: number);
  59352. /**
  59353. * Gets a string with the Vector2 coordinates
  59354. * @returns a string with the Vector2 coordinates
  59355. */
  59356. toString(): string;
  59357. /**
  59358. * Gets class name
  59359. * @returns the string "Vector2"
  59360. */
  59361. getClassName(): string;
  59362. /**
  59363. * Gets current vector hash code
  59364. * @returns the Vector2 hash code as a number
  59365. */
  59366. getHashCode(): number;
  59367. /**
  59368. * Sets the Vector2 coordinates in the given array or Float32Array from the given index.
  59369. * @param array defines the source array
  59370. * @param index defines the offset in source array
  59371. * @returns the current Vector2
  59372. */
  59373. toArray(array: FloatArray, index?: number): Vector2;
  59374. /**
  59375. * Copy the current vector to an array
  59376. * @returns a new array with 2 elements: the Vector2 coordinates.
  59377. */
  59378. asArray(): number[];
  59379. /**
  59380. * Sets the Vector2 coordinates with the given Vector2 coordinates
  59381. * @param source defines the source Vector2
  59382. * @returns the current updated Vector2
  59383. */
  59384. copyFrom(source: DeepImmutable<Vector2>): Vector2;
  59385. /**
  59386. * Sets the Vector2 coordinates with the given floats
  59387. * @param x defines the first coordinate
  59388. * @param y defines the second coordinate
  59389. * @returns the current updated Vector2
  59390. */
  59391. copyFromFloats(x: number, y: number): Vector2;
  59392. /**
  59393. * Sets the Vector2 coordinates with the given floats
  59394. * @param x defines the first coordinate
  59395. * @param y defines the second coordinate
  59396. * @returns the current updated Vector2
  59397. */
  59398. set(x: number, y: number): Vector2;
  59399. /**
  59400. * Add another vector with the current one
  59401. * @param otherVector defines the other vector
  59402. * @returns a new Vector2 set with the addition of the current Vector2 and the given one coordinates
  59403. */
  59404. add(otherVector: DeepImmutable<Vector2>): Vector2;
  59405. /**
  59406. * Sets the "result" coordinates with the addition of the current Vector2 and the given one coordinates
  59407. * @param otherVector defines the other vector
  59408. * @param result defines the target vector
  59409. * @returns the unmodified current Vector2
  59410. */
  59411. addToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  59412. /**
  59413. * Set the Vector2 coordinates by adding the given Vector2 coordinates
  59414. * @param otherVector defines the other vector
  59415. * @returns the current updated Vector2
  59416. */
  59417. addInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  59418. /**
  59419. * Gets a new Vector2 by adding the current Vector2 coordinates to the given Vector3 x, y coordinates
  59420. * @param otherVector defines the other vector
  59421. * @returns a new Vector2
  59422. */
  59423. addVector3(otherVector: Vector3): Vector2;
  59424. /**
  59425. * Gets a new Vector2 set with the subtracted coordinates of the given one from the current Vector2
  59426. * @param otherVector defines the other vector
  59427. * @returns a new Vector2
  59428. */
  59429. subtract(otherVector: Vector2): Vector2;
  59430. /**
  59431. * Sets the "result" coordinates with the subtraction of the given one from the current Vector2 coordinates.
  59432. * @param otherVector defines the other vector
  59433. * @param result defines the target vector
  59434. * @returns the unmodified current Vector2
  59435. */
  59436. subtractToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  59437. /**
  59438. * Sets the current Vector2 coordinates by subtracting from it the given one coordinates
  59439. * @param otherVector defines the other vector
  59440. * @returns the current updated Vector2
  59441. */
  59442. subtractInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  59443. /**
  59444. * Multiplies in place the current Vector2 coordinates by the given ones
  59445. * @param otherVector defines the other vector
  59446. * @returns the current updated Vector2
  59447. */
  59448. multiplyInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  59449. /**
  59450. * Returns a new Vector2 set with the multiplication of the current Vector2 and the given one coordinates
  59451. * @param otherVector defines the other vector
  59452. * @returns a new Vector2
  59453. */
  59454. multiply(otherVector: DeepImmutable<Vector2>): Vector2;
  59455. /**
  59456. * Sets "result" coordinates with the multiplication of the current Vector2 and the given one coordinates
  59457. * @param otherVector defines the other vector
  59458. * @param result defines the target vector
  59459. * @returns the unmodified current Vector2
  59460. */
  59461. multiplyToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  59462. /**
  59463. * Gets a new Vector2 set with the Vector2 coordinates multiplied by the given floats
  59464. * @param x defines the first coordinate
  59465. * @param y defines the second coordinate
  59466. * @returns a new Vector2
  59467. */
  59468. multiplyByFloats(x: number, y: number): Vector2;
  59469. /**
  59470. * Returns a new Vector2 set with the Vector2 coordinates divided by the given one coordinates
  59471. * @param otherVector defines the other vector
  59472. * @returns a new Vector2
  59473. */
  59474. divide(otherVector: Vector2): Vector2;
  59475. /**
  59476. * Sets the "result" coordinates with the Vector2 divided by the given one coordinates
  59477. * @param otherVector defines the other vector
  59478. * @param result defines the target vector
  59479. * @returns the unmodified current Vector2
  59480. */
  59481. divideToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  59482. /**
  59483. * Divides the current Vector2 coordinates by the given ones
  59484. * @param otherVector defines the other vector
  59485. * @returns the current updated Vector2
  59486. */
  59487. divideInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  59488. /**
  59489. * Gets a new Vector2 with current Vector2 negated coordinates
  59490. * @returns a new Vector2
  59491. */
  59492. negate(): Vector2;
  59493. /**
  59494. * Multiply the Vector2 coordinates by scale
  59495. * @param scale defines the scaling factor
  59496. * @returns the current updated Vector2
  59497. */
  59498. scaleInPlace(scale: number): Vector2;
  59499. /**
  59500. * Returns a new Vector2 scaled by "scale" from the current Vector2
  59501. * @param scale defines the scaling factor
  59502. * @returns a new Vector2
  59503. */
  59504. scale(scale: number): Vector2;
  59505. /**
  59506. * Scale the current Vector2 values by a factor to a given Vector2
  59507. * @param scale defines the scale factor
  59508. * @param result defines the Vector2 object where to store the result
  59509. * @returns the unmodified current Vector2
  59510. */
  59511. scaleToRef(scale: number, result: Vector2): Vector2;
  59512. /**
  59513. * Scale the current Vector2 values by a factor and add the result to a given Vector2
  59514. * @param scale defines the scale factor
  59515. * @param result defines the Vector2 object where to store the result
  59516. * @returns the unmodified current Vector2
  59517. */
  59518. scaleAndAddToRef(scale: number, result: Vector2): Vector2;
  59519. /**
  59520. * Gets a boolean if two vectors are equals
  59521. * @param otherVector defines the other vector
  59522. * @returns true if the given vector coordinates strictly equal the current Vector2 ones
  59523. */
  59524. equals(otherVector: DeepImmutable<Vector2>): boolean;
  59525. /**
  59526. * Gets a boolean if two vectors are equals (using an epsilon value)
  59527. * @param otherVector defines the other vector
  59528. * @param epsilon defines the minimal distance to consider equality
  59529. * @returns true if the given vector coordinates are close to the current ones by a distance of epsilon.
  59530. */
  59531. equalsWithEpsilon(otherVector: DeepImmutable<Vector2>, epsilon?: number): boolean;
  59532. /**
  59533. * Gets a new Vector2 from current Vector2 floored values
  59534. * @returns a new Vector2
  59535. */
  59536. floor(): Vector2;
  59537. /**
  59538. * Gets a new Vector2 from current Vector2 floored values
  59539. * @returns a new Vector2
  59540. */
  59541. fract(): Vector2;
  59542. /**
  59543. * Gets the length of the vector
  59544. * @returns the vector length (float)
  59545. */
  59546. length(): number;
  59547. /**
  59548. * Gets the vector squared length
  59549. * @returns the vector squared length (float)
  59550. */
  59551. lengthSquared(): number;
  59552. /**
  59553. * Normalize the vector
  59554. * @returns the current updated Vector2
  59555. */
  59556. normalize(): Vector2;
  59557. /**
  59558. * Gets a new Vector2 copied from the Vector2
  59559. * @returns a new Vector2
  59560. */
  59561. clone(): Vector2;
  59562. /**
  59563. * Gets a new Vector2(0, 0)
  59564. * @returns a new Vector2
  59565. */
  59566. static Zero(): Vector2;
  59567. /**
  59568. * Gets a new Vector2(1, 1)
  59569. * @returns a new Vector2
  59570. */
  59571. static One(): Vector2;
  59572. /**
  59573. * Gets a new Vector2 set from the given index element of the given array
  59574. * @param array defines the data source
  59575. * @param offset defines the offset in the data source
  59576. * @returns a new Vector2
  59577. */
  59578. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector2;
  59579. /**
  59580. * Sets "result" from the given index element of the given array
  59581. * @param array defines the data source
  59582. * @param offset defines the offset in the data source
  59583. * @param result defines the target vector
  59584. */
  59585. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector2): void;
  59586. /**
  59587. * Gets a new Vector2 located for "amount" (float) on the CatmullRom spline defined by the given four Vector2
  59588. * @param value1 defines 1st point of control
  59589. * @param value2 defines 2nd point of control
  59590. * @param value3 defines 3rd point of control
  59591. * @param value4 defines 4th point of control
  59592. * @param amount defines the interpolation factor
  59593. * @returns a new Vector2
  59594. */
  59595. static CatmullRom(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>, value3: DeepImmutable<Vector2>, value4: DeepImmutable<Vector2>, amount: number): Vector2;
  59596. /**
  59597. * 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".
  59598. * If a coordinate of "value" is lower than "min" coordinates, the returned Vector2 is given this "min" coordinate.
  59599. * If a coordinate of "value" is greater than "max" coordinates, the returned Vector2 is given this "max" coordinate
  59600. * @param value defines the value to clamp
  59601. * @param min defines the lower limit
  59602. * @param max defines the upper limit
  59603. * @returns a new Vector2
  59604. */
  59605. static Clamp(value: DeepImmutable<Vector2>, min: DeepImmutable<Vector2>, max: DeepImmutable<Vector2>): Vector2;
  59606. /**
  59607. * Returns a new Vector2 located for "amount" (float) on the Hermite spline defined by the vectors "value1", "value3", "tangent1", "tangent2"
  59608. * @param value1 defines the 1st control point
  59609. * @param tangent1 defines the outgoing tangent
  59610. * @param value2 defines the 2nd control point
  59611. * @param tangent2 defines the incoming tangent
  59612. * @param amount defines the interpolation factor
  59613. * @returns a new Vector2
  59614. */
  59615. static Hermite(value1: DeepImmutable<Vector2>, tangent1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>, tangent2: DeepImmutable<Vector2>, amount: number): Vector2;
  59616. /**
  59617. * Returns a new Vector2 located for "amount" (float) on the linear interpolation between the vector "start" adn the vector "end".
  59618. * @param start defines the start vector
  59619. * @param end defines the end vector
  59620. * @param amount defines the interpolation factor
  59621. * @returns a new Vector2
  59622. */
  59623. static Lerp(start: DeepImmutable<Vector2>, end: DeepImmutable<Vector2>, amount: number): Vector2;
  59624. /**
  59625. * Gets the dot product of the vector "left" and the vector "right"
  59626. * @param left defines first vector
  59627. * @param right defines second vector
  59628. * @returns the dot product (float)
  59629. */
  59630. static Dot(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): number;
  59631. /**
  59632. * Returns a new Vector2 equal to the normalized given vector
  59633. * @param vector defines the vector to normalize
  59634. * @returns a new Vector2
  59635. */
  59636. static Normalize(vector: DeepImmutable<Vector2>): Vector2;
  59637. /**
  59638. * Gets a new Vector2 set with the minimal coordinate values from the "left" and "right" vectors
  59639. * @param left defines 1st vector
  59640. * @param right defines 2nd vector
  59641. * @returns a new Vector2
  59642. */
  59643. static Minimize(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): Vector2;
  59644. /**
  59645. * Gets a new Vecto2 set with the maximal coordinate values from the "left" and "right" vectors
  59646. * @param left defines 1st vector
  59647. * @param right defines 2nd vector
  59648. * @returns a new Vector2
  59649. */
  59650. static Maximize(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): Vector2;
  59651. /**
  59652. * Gets a new Vector2 set with the transformed coordinates of the given vector by the given transformation matrix
  59653. * @param vector defines the vector to transform
  59654. * @param transformation defines the matrix to apply
  59655. * @returns a new Vector2
  59656. */
  59657. static Transform(vector: DeepImmutable<Vector2>, transformation: DeepImmutable<Matrix>): Vector2;
  59658. /**
  59659. * Transforms the given vector coordinates by the given transformation matrix and stores the result in the vector "result" coordinates
  59660. * @param vector defines the vector to transform
  59661. * @param transformation defines the matrix to apply
  59662. * @param result defines the target vector
  59663. */
  59664. static TransformToRef(vector: DeepImmutable<Vector2>, transformation: DeepImmutable<Matrix>, result: Vector2): void;
  59665. /**
  59666. * Determines if a given vector is included in a triangle
  59667. * @param p defines the vector to test
  59668. * @param p0 defines 1st triangle point
  59669. * @param p1 defines 2nd triangle point
  59670. * @param p2 defines 3rd triangle point
  59671. * @returns true if the point "p" is in the triangle defined by the vertors "p0", "p1", "p2"
  59672. */
  59673. static PointInTriangle(p: DeepImmutable<Vector2>, p0: DeepImmutable<Vector2>, p1: DeepImmutable<Vector2>, p2: DeepImmutable<Vector2>): boolean;
  59674. /**
  59675. * Gets the distance between the vectors "value1" and "value2"
  59676. * @param value1 defines first vector
  59677. * @param value2 defines second vector
  59678. * @returns the distance between vectors
  59679. */
  59680. static Distance(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): number;
  59681. /**
  59682. * Returns the squared distance between the vectors "value1" and "value2"
  59683. * @param value1 defines first vector
  59684. * @param value2 defines second vector
  59685. * @returns the squared distance between vectors
  59686. */
  59687. static DistanceSquared(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): number;
  59688. /**
  59689. * Gets a new Vector2 located at the center of the vectors "value1" and "value2"
  59690. * @param value1 defines first vector
  59691. * @param value2 defines second vector
  59692. * @returns a new Vector2
  59693. */
  59694. static Center(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): Vector2;
  59695. /**
  59696. * Gets the shortest distance (float) between the point "p" and the segment defined by the two points "segA" and "segB".
  59697. * @param p defines the middle point
  59698. * @param segA defines one point of the segment
  59699. * @param segB defines the other point of the segment
  59700. * @returns the shortest distance
  59701. */
  59702. static DistanceOfPointFromSegment(p: DeepImmutable<Vector2>, segA: DeepImmutable<Vector2>, segB: DeepImmutable<Vector2>): number;
  59703. }
  59704. /**
  59705. * Classed used to store (x,y,z) vector representation
  59706. * A Vector3 is the main object used in 3D geometry
  59707. * It can represent etiher the coordinates of a point the space, either a direction
  59708. * Reminder: js uses a left handed forward facing system
  59709. */
  59710. export class Vector3 {
  59711. /**
  59712. * Defines the first coordinates (on X axis)
  59713. */
  59714. x: number;
  59715. /**
  59716. * Defines the second coordinates (on Y axis)
  59717. */
  59718. y: number;
  59719. /**
  59720. * Defines the third coordinates (on Z axis)
  59721. */
  59722. z: number;
  59723. private static _UpReadOnly;
  59724. /**
  59725. * Creates a new Vector3 object from the given x, y, z (floats) coordinates.
  59726. * @param x defines the first coordinates (on X axis)
  59727. * @param y defines the second coordinates (on Y axis)
  59728. * @param z defines the third coordinates (on Z axis)
  59729. */
  59730. constructor(
  59731. /**
  59732. * Defines the first coordinates (on X axis)
  59733. */
  59734. x?: number,
  59735. /**
  59736. * Defines the second coordinates (on Y axis)
  59737. */
  59738. y?: number,
  59739. /**
  59740. * Defines the third coordinates (on Z axis)
  59741. */
  59742. z?: number);
  59743. /**
  59744. * Creates a string representation of the Vector3
  59745. * @returns a string with the Vector3 coordinates.
  59746. */
  59747. toString(): string;
  59748. /**
  59749. * Gets the class name
  59750. * @returns the string "Vector3"
  59751. */
  59752. getClassName(): string;
  59753. /**
  59754. * Creates the Vector3 hash code
  59755. * @returns a number which tends to be unique between Vector3 instances
  59756. */
  59757. getHashCode(): number;
  59758. /**
  59759. * Creates an array containing three elements : the coordinates of the Vector3
  59760. * @returns a new array of numbers
  59761. */
  59762. asArray(): number[];
  59763. /**
  59764. * Populates the given array or Float32Array from the given index with the successive coordinates of the Vector3
  59765. * @param array defines the destination array
  59766. * @param index defines the offset in the destination array
  59767. * @returns the current Vector3
  59768. */
  59769. toArray(array: FloatArray, index?: number): Vector3;
  59770. /**
  59771. * Converts the current Vector3 into a quaternion (considering that the Vector3 contains Euler angles representation of a rotation)
  59772. * @returns a new Quaternion object, computed from the Vector3 coordinates
  59773. */
  59774. toQuaternion(): Quaternion;
  59775. /**
  59776. * Adds the given vector to the current Vector3
  59777. * @param otherVector defines the second operand
  59778. * @returns the current updated Vector3
  59779. */
  59780. addInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  59781. /**
  59782. * Adds the given coordinates to the current Vector3
  59783. * @param x defines the x coordinate of the operand
  59784. * @param y defines the y coordinate of the operand
  59785. * @param z defines the z coordinate of the operand
  59786. * @returns the current updated Vector3
  59787. */
  59788. addInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  59789. /**
  59790. * Gets a new Vector3, result of the addition the current Vector3 and the given vector
  59791. * @param otherVector defines the second operand
  59792. * @returns the resulting Vector3
  59793. */
  59794. add(otherVector: DeepImmutable<Vector3>): Vector3;
  59795. /**
  59796. * Adds the current Vector3 to the given one and stores the result in the vector "result"
  59797. * @param otherVector defines the second operand
  59798. * @param result defines the Vector3 object where to store the result
  59799. * @returns the current Vector3
  59800. */
  59801. addToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  59802. /**
  59803. * Subtract the given vector from the current Vector3
  59804. * @param otherVector defines the second operand
  59805. * @returns the current updated Vector3
  59806. */
  59807. subtractInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  59808. /**
  59809. * Returns a new Vector3, result of the subtraction of the given vector from the current Vector3
  59810. * @param otherVector defines the second operand
  59811. * @returns the resulting Vector3
  59812. */
  59813. subtract(otherVector: DeepImmutable<Vector3>): Vector3;
  59814. /**
  59815. * Subtracts the given vector from the current Vector3 and stores the result in the vector "result".
  59816. * @param otherVector defines the second operand
  59817. * @param result defines the Vector3 object where to store the result
  59818. * @returns the current Vector3
  59819. */
  59820. subtractToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  59821. /**
  59822. * Returns a new Vector3 set with the subtraction of the given floats from the current Vector3 coordinates
  59823. * @param x defines the x coordinate of the operand
  59824. * @param y defines the y coordinate of the operand
  59825. * @param z defines the z coordinate of the operand
  59826. * @returns the resulting Vector3
  59827. */
  59828. subtractFromFloats(x: number, y: number, z: number): Vector3;
  59829. /**
  59830. * Subtracts the given floats from the current Vector3 coordinates and set the given vector "result" with this result
  59831. * @param x defines the x coordinate of the operand
  59832. * @param y defines the y coordinate of the operand
  59833. * @param z defines the z coordinate of the operand
  59834. * @param result defines the Vector3 object where to store the result
  59835. * @returns the current Vector3
  59836. */
  59837. subtractFromFloatsToRef(x: number, y: number, z: number, result: Vector3): Vector3;
  59838. /**
  59839. * Gets a new Vector3 set with the current Vector3 negated coordinates
  59840. * @returns a new Vector3
  59841. */
  59842. negate(): Vector3;
  59843. /**
  59844. * Multiplies the Vector3 coordinates by the float "scale"
  59845. * @param scale defines the multiplier factor
  59846. * @returns the current updated Vector3
  59847. */
  59848. scaleInPlace(scale: number): Vector3;
  59849. /**
  59850. * Returns a new Vector3 set with the current Vector3 coordinates multiplied by the float "scale"
  59851. * @param scale defines the multiplier factor
  59852. * @returns a new Vector3
  59853. */
  59854. scale(scale: number): Vector3;
  59855. /**
  59856. * Multiplies the current Vector3 coordinates by the float "scale" and stores the result in the given vector "result" coordinates
  59857. * @param scale defines the multiplier factor
  59858. * @param result defines the Vector3 object where to store the result
  59859. * @returns the current Vector3
  59860. */
  59861. scaleToRef(scale: number, result: Vector3): Vector3;
  59862. /**
  59863. * Scale the current Vector3 values by a factor and add the result to a given Vector3
  59864. * @param scale defines the scale factor
  59865. * @param result defines the Vector3 object where to store the result
  59866. * @returns the unmodified current Vector3
  59867. */
  59868. scaleAndAddToRef(scale: number, result: Vector3): Vector3;
  59869. /**
  59870. * Returns true if the current Vector3 and the given vector coordinates are strictly equal
  59871. * @param otherVector defines the second operand
  59872. * @returns true if both vectors are equals
  59873. */
  59874. equals(otherVector: DeepImmutable<Vector3>): boolean;
  59875. /**
  59876. * Returns true if the current Vector3 and the given vector coordinates are distant less than epsilon
  59877. * @param otherVector defines the second operand
  59878. * @param epsilon defines the minimal distance to define values as equals
  59879. * @returns true if both vectors are distant less than epsilon
  59880. */
  59881. equalsWithEpsilon(otherVector: DeepImmutable<Vector3>, epsilon?: number): boolean;
  59882. /**
  59883. * Returns true if the current Vector3 coordinates equals the given floats
  59884. * @param x defines the x coordinate of the operand
  59885. * @param y defines the y coordinate of the operand
  59886. * @param z defines the z coordinate of the operand
  59887. * @returns true if both vectors are equals
  59888. */
  59889. equalsToFloats(x: number, y: number, z: number): boolean;
  59890. /**
  59891. * Multiplies the current Vector3 coordinates by the given ones
  59892. * @param otherVector defines the second operand
  59893. * @returns the current updated Vector3
  59894. */
  59895. multiplyInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  59896. /**
  59897. * Returns a new Vector3, result of the multiplication of the current Vector3 by the given vector
  59898. * @param otherVector defines the second operand
  59899. * @returns the new Vector3
  59900. */
  59901. multiply(otherVector: DeepImmutable<Vector3>): Vector3;
  59902. /**
  59903. * Multiplies the current Vector3 by the given one and stores the result in the given vector "result"
  59904. * @param otherVector defines the second operand
  59905. * @param result defines the Vector3 object where to store the result
  59906. * @returns the current Vector3
  59907. */
  59908. multiplyToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  59909. /**
  59910. * Returns a new Vector3 set with the result of the mulliplication of the current Vector3 coordinates by the given floats
  59911. * @param x defines the x coordinate of the operand
  59912. * @param y defines the y coordinate of the operand
  59913. * @param z defines the z coordinate of the operand
  59914. * @returns the new Vector3
  59915. */
  59916. multiplyByFloats(x: number, y: number, z: number): Vector3;
  59917. /**
  59918. * Returns a new Vector3 set with the result of the division of the current Vector3 coordinates by the given ones
  59919. * @param otherVector defines the second operand
  59920. * @returns the new Vector3
  59921. */
  59922. divide(otherVector: DeepImmutable<Vector3>): Vector3;
  59923. /**
  59924. * Divides the current Vector3 coordinates by the given ones and stores the result in the given vector "result"
  59925. * @param otherVector defines the second operand
  59926. * @param result defines the Vector3 object where to store the result
  59927. * @returns the current Vector3
  59928. */
  59929. divideToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  59930. /**
  59931. * Divides the current Vector3 coordinates by the given ones.
  59932. * @param otherVector defines the second operand
  59933. * @returns the current updated Vector3
  59934. */
  59935. divideInPlace(otherVector: Vector3): Vector3;
  59936. /**
  59937. * Updates the current Vector3 with the minimal coordinate values between its and the given vector ones
  59938. * @param other defines the second operand
  59939. * @returns the current updated Vector3
  59940. */
  59941. minimizeInPlace(other: DeepImmutable<Vector3>): Vector3;
  59942. /**
  59943. * Updates the current Vector3 with the maximal coordinate values between its and the given vector ones.
  59944. * @param other defines the second operand
  59945. * @returns the current updated Vector3
  59946. */
  59947. maximizeInPlace(other: DeepImmutable<Vector3>): Vector3;
  59948. /**
  59949. * Updates the current Vector3 with the minimal coordinate values between its and the given coordinates
  59950. * @param x defines the x coordinate of the operand
  59951. * @param y defines the y coordinate of the operand
  59952. * @param z defines the z coordinate of the operand
  59953. * @returns the current updated Vector3
  59954. */
  59955. minimizeInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  59956. /**
  59957. * Updates the current Vector3 with the maximal coordinate values between its and the given coordinates.
  59958. * @param x defines the x coordinate of the operand
  59959. * @param y defines the y coordinate of the operand
  59960. * @param z defines the z coordinate of the operand
  59961. * @returns the current updated Vector3
  59962. */
  59963. maximizeInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  59964. /**
  59965. * Due to float precision, scale of a mesh could be uniform but float values are off by a small fraction
  59966. * Check if is non uniform within a certain amount of decimal places to account for this
  59967. * @param epsilon the amount the values can differ
  59968. * @returns if the the vector is non uniform to a certain number of decimal places
  59969. */
  59970. isNonUniformWithinEpsilon(epsilon: number): boolean;
  59971. /**
  59972. * Gets a boolean indicating that the vector is non uniform meaning x, y or z are not all the same
  59973. */
  59974. readonly isNonUniform: boolean;
  59975. /**
  59976. * Gets a new Vector3 from current Vector3 floored values
  59977. * @returns a new Vector3
  59978. */
  59979. floor(): Vector3;
  59980. /**
  59981. * Gets a new Vector3 from current Vector3 floored values
  59982. * @returns a new Vector3
  59983. */
  59984. fract(): Vector3;
  59985. /**
  59986. * Gets the length of the Vector3
  59987. * @returns the length of the Vecto3
  59988. */
  59989. length(): number;
  59990. /**
  59991. * Gets the squared length of the Vector3
  59992. * @returns squared length of the Vector3
  59993. */
  59994. lengthSquared(): number;
  59995. /**
  59996. * Normalize the current Vector3.
  59997. * Please note that this is an in place operation.
  59998. * @returns the current updated Vector3
  59999. */
  60000. normalize(): Vector3;
  60001. /**
  60002. * Reorders the x y z properties of the vector in place
  60003. * @param order new ordering of the properties (eg. for vector 1,2,3 with "ZYX" will produce 3,2,1)
  60004. * @returns the current updated vector
  60005. */
  60006. reorderInPlace(order: string): this;
  60007. /**
  60008. * Rotates the vector around 0,0,0 by a quaternion
  60009. * @param quaternion the rotation quaternion
  60010. * @param result vector to store the result
  60011. * @returns the resulting vector
  60012. */
  60013. rotateByQuaternionToRef(quaternion: Quaternion, result: Vector3): Vector3;
  60014. /**
  60015. * Rotates a vector around a given point
  60016. * @param quaternion the rotation quaternion
  60017. * @param point the point to rotate around
  60018. * @param result vector to store the result
  60019. * @returns the resulting vector
  60020. */
  60021. rotateByQuaternionAroundPointToRef(quaternion: Quaternion, point: Vector3, result: Vector3): Vector3;
  60022. /**
  60023. * Normalize the current Vector3 with the given input length.
  60024. * Please note that this is an in place operation.
  60025. * @param len the length of the vector
  60026. * @returns the current updated Vector3
  60027. */
  60028. normalizeFromLength(len: number): Vector3;
  60029. /**
  60030. * Normalize the current Vector3 to a new vector
  60031. * @returns the new Vector3
  60032. */
  60033. normalizeToNew(): Vector3;
  60034. /**
  60035. * Normalize the current Vector3 to the reference
  60036. * @param reference define the Vector3 to update
  60037. * @returns the updated Vector3
  60038. */
  60039. normalizeToRef(reference: DeepImmutable<Vector3>): Vector3;
  60040. /**
  60041. * Creates a new Vector3 copied from the current Vector3
  60042. * @returns the new Vector3
  60043. */
  60044. clone(): Vector3;
  60045. /**
  60046. * Copies the given vector coordinates to the current Vector3 ones
  60047. * @param source defines the source Vector3
  60048. * @returns the current updated Vector3
  60049. */
  60050. copyFrom(source: DeepImmutable<Vector3>): Vector3;
  60051. /**
  60052. * Copies the given floats to the current Vector3 coordinates
  60053. * @param x defines the x coordinate of the operand
  60054. * @param y defines the y coordinate of the operand
  60055. * @param z defines the z coordinate of the operand
  60056. * @returns the current updated Vector3
  60057. */
  60058. copyFromFloats(x: number, y: number, z: number): Vector3;
  60059. /**
  60060. * Copies the given floats to the current Vector3 coordinates
  60061. * @param x defines the x coordinate of the operand
  60062. * @param y defines the y coordinate of the operand
  60063. * @param z defines the z coordinate of the operand
  60064. * @returns the current updated Vector3
  60065. */
  60066. set(x: number, y: number, z: number): Vector3;
  60067. /**
  60068. * Copies the given float to the current Vector3 coordinates
  60069. * @param v defines the x, y and z coordinates of the operand
  60070. * @returns the current updated Vector3
  60071. */
  60072. setAll(v: number): Vector3;
  60073. /**
  60074. * Get the clip factor between two vectors
  60075. * @param vector0 defines the first operand
  60076. * @param vector1 defines the second operand
  60077. * @param axis defines the axis to use
  60078. * @param size defines the size along the axis
  60079. * @returns the clip factor
  60080. */
  60081. static GetClipFactor(vector0: DeepImmutable<Vector3>, vector1: DeepImmutable<Vector3>, axis: DeepImmutable<Vector3>, size: number): number;
  60082. /**
  60083. * Get angle between two vectors
  60084. * @param vector0 angle between vector0 and vector1
  60085. * @param vector1 angle between vector0 and vector1
  60086. * @param normal direction of the normal
  60087. * @return the angle between vector0 and vector1
  60088. */
  60089. static GetAngleBetweenVectors(vector0: DeepImmutable<Vector3>, vector1: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>): number;
  60090. /**
  60091. * Returns a new Vector3 set from the index "offset" of the given array
  60092. * @param array defines the source array
  60093. * @param offset defines the offset in the source array
  60094. * @returns the new Vector3
  60095. */
  60096. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector3;
  60097. /**
  60098. * Returns a new Vector3 set from the index "offset" of the given Float32Array
  60099. * This function is deprecated. Use FromArray instead
  60100. * @param array defines the source array
  60101. * @param offset defines the offset in the source array
  60102. * @returns the new Vector3
  60103. */
  60104. static FromFloatArray(array: DeepImmutable<Float32Array>, offset?: number): Vector3;
  60105. /**
  60106. * Sets the given vector "result" with the element values from the index "offset" of the given array
  60107. * @param array defines the source array
  60108. * @param offset defines the offset in the source array
  60109. * @param result defines the Vector3 where to store the result
  60110. */
  60111. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector3): void;
  60112. /**
  60113. * Sets the given vector "result" with the element values from the index "offset" of the given Float32Array
  60114. * This function is deprecated. Use FromArrayToRef instead.
  60115. * @param array defines the source array
  60116. * @param offset defines the offset in the source array
  60117. * @param result defines the Vector3 where to store the result
  60118. */
  60119. static FromFloatArrayToRef(array: DeepImmutable<Float32Array>, offset: number, result: Vector3): void;
  60120. /**
  60121. * Sets the given vector "result" with the given floats.
  60122. * @param x defines the x coordinate of the source
  60123. * @param y defines the y coordinate of the source
  60124. * @param z defines the z coordinate of the source
  60125. * @param result defines the Vector3 where to store the result
  60126. */
  60127. static FromFloatsToRef(x: number, y: number, z: number, result: Vector3): void;
  60128. /**
  60129. * Returns a new Vector3 set to (0.0, 0.0, 0.0)
  60130. * @returns a new empty Vector3
  60131. */
  60132. static Zero(): Vector3;
  60133. /**
  60134. * Returns a new Vector3 set to (1.0, 1.0, 1.0)
  60135. * @returns a new unit Vector3
  60136. */
  60137. static One(): Vector3;
  60138. /**
  60139. * Returns a new Vector3 set to (0.0, 1.0, 0.0)
  60140. * @returns a new up Vector3
  60141. */
  60142. static Up(): Vector3;
  60143. /**
  60144. * Gets a up Vector3 that must not be updated
  60145. */
  60146. static readonly UpReadOnly: DeepImmutable<Vector3>;
  60147. /**
  60148. * Returns a new Vector3 set to (0.0, -1.0, 0.0)
  60149. * @returns a new down Vector3
  60150. */
  60151. static Down(): Vector3;
  60152. /**
  60153. * Returns a new Vector3 set to (0.0, 0.0, 1.0)
  60154. * @returns a new forward Vector3
  60155. */
  60156. static Forward(): Vector3;
  60157. /**
  60158. * Returns a new Vector3 set to (0.0, 0.0, -1.0)
  60159. * @returns a new forward Vector3
  60160. */
  60161. static Backward(): Vector3;
  60162. /**
  60163. * Returns a new Vector3 set to (1.0, 0.0, 0.0)
  60164. * @returns a new right Vector3
  60165. */
  60166. static Right(): Vector3;
  60167. /**
  60168. * Returns a new Vector3 set to (-1.0, 0.0, 0.0)
  60169. * @returns a new left Vector3
  60170. */
  60171. static Left(): Vector3;
  60172. /**
  60173. * Returns a new Vector3 set with the result of the transformation by the given matrix of the given vector.
  60174. * This method computes tranformed coordinates only, not transformed direction vectors (ie. it takes translation in account)
  60175. * @param vector defines the Vector3 to transform
  60176. * @param transformation defines the transformation matrix
  60177. * @returns the transformed Vector3
  60178. */
  60179. static TransformCoordinates(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>): Vector3;
  60180. /**
  60181. * Sets the given vector "result" coordinates with the result of the transformation by the given matrix of the given vector
  60182. * This method computes tranformed coordinates only, not transformed direction vectors (ie. it takes translation in account)
  60183. * @param vector defines the Vector3 to transform
  60184. * @param transformation defines the transformation matrix
  60185. * @param result defines the Vector3 where to store the result
  60186. */
  60187. static TransformCoordinatesToRef(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  60188. /**
  60189. * Sets the given vector "result" coordinates with the result of the transformation by the given matrix of the given floats (x, y, z)
  60190. * This method computes tranformed coordinates only, not transformed direction vectors
  60191. * @param x define the x coordinate of the source vector
  60192. * @param y define the y coordinate of the source vector
  60193. * @param z define the z coordinate of the source vector
  60194. * @param transformation defines the transformation matrix
  60195. * @param result defines the Vector3 where to store the result
  60196. */
  60197. static TransformCoordinatesFromFloatsToRef(x: number, y: number, z: number, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  60198. /**
  60199. * Returns a new Vector3 set with the result of the normal transformation by the given matrix of the given vector
  60200. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  60201. * @param vector defines the Vector3 to transform
  60202. * @param transformation defines the transformation matrix
  60203. * @returns the new Vector3
  60204. */
  60205. static TransformNormal(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>): Vector3;
  60206. /**
  60207. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given vector
  60208. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  60209. * @param vector defines the Vector3 to transform
  60210. * @param transformation defines the transformation matrix
  60211. * @param result defines the Vector3 where to store the result
  60212. */
  60213. static TransformNormalToRef(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  60214. /**
  60215. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given floats (x, y, z)
  60216. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  60217. * @param x define the x coordinate of the source vector
  60218. * @param y define the y coordinate of the source vector
  60219. * @param z define the z coordinate of the source vector
  60220. * @param transformation defines the transformation matrix
  60221. * @param result defines the Vector3 where to store the result
  60222. */
  60223. static TransformNormalFromFloatsToRef(x: number, y: number, z: number, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  60224. /**
  60225. * Returns a new Vector3 located for "amount" on the CatmullRom interpolation spline defined by the vectors "value1", "value2", "value3", "value4"
  60226. * @param value1 defines the first control point
  60227. * @param value2 defines the second control point
  60228. * @param value3 defines the third control point
  60229. * @param value4 defines the fourth control point
  60230. * @param amount defines the amount on the spline to use
  60231. * @returns the new Vector3
  60232. */
  60233. static CatmullRom(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>, value3: DeepImmutable<Vector3>, value4: DeepImmutable<Vector3>, amount: number): Vector3;
  60234. /**
  60235. * 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"
  60236. * If a coordinate value of "value" is lower than one of the "min" coordinate, then this "value" coordinate is set with the "min" one
  60237. * If a coordinate value of "value" is greater than one of the "max" coordinate, then this "value" coordinate is set with the "max" one
  60238. * @param value defines the current value
  60239. * @param min defines the lower range value
  60240. * @param max defines the upper range value
  60241. * @returns the new Vector3
  60242. */
  60243. static Clamp(value: DeepImmutable<Vector3>, min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>): Vector3;
  60244. /**
  60245. * 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"
  60246. * If a coordinate value of "value" is lower than one of the "min" coordinate, then this "value" coordinate is set with the "min" one
  60247. * If a coordinate value of "value" is greater than one of the "max" coordinate, then this "value" coordinate is set with the "max" one
  60248. * @param value defines the current value
  60249. * @param min defines the lower range value
  60250. * @param max defines the upper range value
  60251. * @param result defines the Vector3 where to store the result
  60252. */
  60253. static ClampToRef(value: DeepImmutable<Vector3>, min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, result: Vector3): void;
  60254. /**
  60255. * Returns a new Vector3 located for "amount" (float) on the Hermite interpolation spline defined by the vectors "value1", "tangent1", "value2", "tangent2"
  60256. * @param value1 defines the first control point
  60257. * @param tangent1 defines the first tangent vector
  60258. * @param value2 defines the second control point
  60259. * @param tangent2 defines the second tangent vector
  60260. * @param amount defines the amount on the interpolation spline (between 0 and 1)
  60261. * @returns the new Vector3
  60262. */
  60263. static Hermite(value1: DeepImmutable<Vector3>, tangent1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>, tangent2: DeepImmutable<Vector3>, amount: number): Vector3;
  60264. /**
  60265. * Returns a new Vector3 located for "amount" (float) on the linear interpolation between the vectors "start" and "end"
  60266. * @param start defines the start value
  60267. * @param end defines the end value
  60268. * @param amount max defines amount between both (between 0 and 1)
  60269. * @returns the new Vector3
  60270. */
  60271. static Lerp(start: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, amount: number): Vector3;
  60272. /**
  60273. * Sets the given vector "result" with the result of the linear interpolation from the vector "start" for "amount" to the vector "end"
  60274. * @param start defines the start value
  60275. * @param end defines the end value
  60276. * @param amount max defines amount between both (between 0 and 1)
  60277. * @param result defines the Vector3 where to store the result
  60278. */
  60279. static LerpToRef(start: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, amount: number, result: Vector3): void;
  60280. /**
  60281. * Returns the dot product (float) between the vectors "left" and "right"
  60282. * @param left defines the left operand
  60283. * @param right defines the right operand
  60284. * @returns the dot product
  60285. */
  60286. static Dot(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): number;
  60287. /**
  60288. * Returns a new Vector3 as the cross product of the vectors "left" and "right"
  60289. * The cross product is then orthogonal to both "left" and "right"
  60290. * @param left defines the left operand
  60291. * @param right defines the right operand
  60292. * @returns the cross product
  60293. */
  60294. static Cross(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  60295. /**
  60296. * Sets the given vector "result" with the cross product of "left" and "right"
  60297. * The cross product is then orthogonal to both "left" and "right"
  60298. * @param left defines the left operand
  60299. * @param right defines the right operand
  60300. * @param result defines the Vector3 where to store the result
  60301. */
  60302. static CrossToRef(left: Vector3, right: Vector3, result: Vector3): void;
  60303. /**
  60304. * Returns a new Vector3 as the normalization of the given vector
  60305. * @param vector defines the Vector3 to normalize
  60306. * @returns the new Vector3
  60307. */
  60308. static Normalize(vector: DeepImmutable<Vector3>): Vector3;
  60309. /**
  60310. * Sets the given vector "result" with the normalization of the given first vector
  60311. * @param vector defines the Vector3 to normalize
  60312. * @param result defines the Vector3 where to store the result
  60313. */
  60314. static NormalizeToRef(vector: DeepImmutable<Vector3>, result: Vector3): void;
  60315. /**
  60316. * Project a Vector3 onto screen space
  60317. * @param vector defines the Vector3 to project
  60318. * @param world defines the world matrix to use
  60319. * @param transform defines the transform (view x projection) matrix to use
  60320. * @param viewport defines the screen viewport to use
  60321. * @returns the new Vector3
  60322. */
  60323. static Project(vector: DeepImmutable<Vector3>, world: DeepImmutable<Matrix>, transform: DeepImmutable<Matrix>, viewport: DeepImmutable<Viewport>): Vector3;
  60324. /** @hidden */
  60325. static _UnprojectFromInvertedMatrixToRef(source: DeepImmutable<Vector3>, matrix: DeepImmutable<Matrix>, result: Vector3): void;
  60326. /**
  60327. * Unproject from screen space to object space
  60328. * @param source defines the screen space Vector3 to use
  60329. * @param viewportWidth defines the current width of the viewport
  60330. * @param viewportHeight defines the current height of the viewport
  60331. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  60332. * @param transform defines the transform (view x projection) matrix to use
  60333. * @returns the new Vector3
  60334. */
  60335. static UnprojectFromTransform(source: Vector3, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, transform: DeepImmutable<Matrix>): Vector3;
  60336. /**
  60337. * Unproject from screen space to object space
  60338. * @param source defines the screen space Vector3 to use
  60339. * @param viewportWidth defines the current width of the viewport
  60340. * @param viewportHeight defines the current height of the viewport
  60341. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  60342. * @param view defines the view matrix to use
  60343. * @param projection defines the projection matrix to use
  60344. * @returns the new Vector3
  60345. */
  60346. static Unproject(source: DeepImmutable<Vector3>, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Vector3;
  60347. /**
  60348. * Unproject from screen space to object space
  60349. * @param source defines the screen space Vector3 to use
  60350. * @param viewportWidth defines the current width of the viewport
  60351. * @param viewportHeight defines the current height of the viewport
  60352. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  60353. * @param view defines the view matrix to use
  60354. * @param projection defines the projection matrix to use
  60355. * @param result defines the Vector3 where to store the result
  60356. */
  60357. static UnprojectToRef(source: DeepImmutable<Vector3>, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, result: Vector3): void;
  60358. /**
  60359. * Unproject from screen space to object space
  60360. * @param sourceX defines the screen space x coordinate to use
  60361. * @param sourceY defines the screen space y coordinate to use
  60362. * @param sourceZ defines the screen space z coordinate to use
  60363. * @param viewportWidth defines the current width of the viewport
  60364. * @param viewportHeight defines the current height of the viewport
  60365. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  60366. * @param view defines the view matrix to use
  60367. * @param projection defines the projection matrix to use
  60368. * @param result defines the Vector3 where to store the result
  60369. */
  60370. static UnprojectFloatsToRef(sourceX: float, sourceY: float, sourceZ: float, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, result: Vector3): void;
  60371. /**
  60372. * Gets the minimal coordinate values between two Vector3
  60373. * @param left defines the first operand
  60374. * @param right defines the second operand
  60375. * @returns the new Vector3
  60376. */
  60377. static Minimize(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  60378. /**
  60379. * Gets the maximal coordinate values between two Vector3
  60380. * @param left defines the first operand
  60381. * @param right defines the second operand
  60382. * @returns the new Vector3
  60383. */
  60384. static Maximize(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  60385. /**
  60386. * Returns the distance between the vectors "value1" and "value2"
  60387. * @param value1 defines the first operand
  60388. * @param value2 defines the second operand
  60389. * @returns the distance
  60390. */
  60391. static Distance(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): number;
  60392. /**
  60393. * Returns the squared distance between the vectors "value1" and "value2"
  60394. * @param value1 defines the first operand
  60395. * @param value2 defines the second operand
  60396. * @returns the squared distance
  60397. */
  60398. static DistanceSquared(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): number;
  60399. /**
  60400. * Returns a new Vector3 located at the center between "value1" and "value2"
  60401. * @param value1 defines the first operand
  60402. * @param value2 defines the second operand
  60403. * @returns the new Vector3
  60404. */
  60405. static Center(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): Vector3;
  60406. /**
  60407. * Given three orthogonal normalized left-handed oriented Vector3 axis in space (target system),
  60408. * RotationFromAxis() returns the rotation Euler angles (ex : rotation.x, rotation.y, rotation.z) to apply
  60409. * to something in order to rotate it from its local system to the given target system
  60410. * Note: axis1, axis2 and axis3 are normalized during this operation
  60411. * @param axis1 defines the first axis
  60412. * @param axis2 defines the second axis
  60413. * @param axis3 defines the third axis
  60414. * @returns a new Vector3
  60415. */
  60416. static RotationFromAxis(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>): Vector3;
  60417. /**
  60418. * The same than RotationFromAxis but updates the given ref Vector3 parameter instead of returning a new Vector3
  60419. * @param axis1 defines the first axis
  60420. * @param axis2 defines the second axis
  60421. * @param axis3 defines the third axis
  60422. * @param ref defines the Vector3 where to store the result
  60423. */
  60424. static RotationFromAxisToRef(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>, ref: Vector3): void;
  60425. }
  60426. /**
  60427. * Vector4 class created for EulerAngle class conversion to Quaternion
  60428. */
  60429. export class Vector4 {
  60430. /** x value of the vector */
  60431. x: number;
  60432. /** y value of the vector */
  60433. y: number;
  60434. /** z value of the vector */
  60435. z: number;
  60436. /** w value of the vector */
  60437. w: number;
  60438. /**
  60439. * Creates a Vector4 object from the given floats.
  60440. * @param x x value of the vector
  60441. * @param y y value of the vector
  60442. * @param z z value of the vector
  60443. * @param w w value of the vector
  60444. */
  60445. constructor(
  60446. /** x value of the vector */
  60447. x: number,
  60448. /** y value of the vector */
  60449. y: number,
  60450. /** z value of the vector */
  60451. z: number,
  60452. /** w value of the vector */
  60453. w: number);
  60454. /**
  60455. * Returns the string with the Vector4 coordinates.
  60456. * @returns a string containing all the vector values
  60457. */
  60458. toString(): string;
  60459. /**
  60460. * Returns the string "Vector4".
  60461. * @returns "Vector4"
  60462. */
  60463. getClassName(): string;
  60464. /**
  60465. * Returns the Vector4 hash code.
  60466. * @returns a unique hash code
  60467. */
  60468. getHashCode(): number;
  60469. /**
  60470. * Returns a new array populated with 4 elements : the Vector4 coordinates.
  60471. * @returns the resulting array
  60472. */
  60473. asArray(): number[];
  60474. /**
  60475. * Populates the given array from the given index with the Vector4 coordinates.
  60476. * @param array array to populate
  60477. * @param index index of the array to start at (default: 0)
  60478. * @returns the Vector4.
  60479. */
  60480. toArray(array: FloatArray, index?: number): Vector4;
  60481. /**
  60482. * Adds the given vector to the current Vector4.
  60483. * @param otherVector the vector to add
  60484. * @returns the updated Vector4.
  60485. */
  60486. addInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  60487. /**
  60488. * Returns a new Vector4 as the result of the addition of the current Vector4 and the given one.
  60489. * @param otherVector the vector to add
  60490. * @returns the resulting vector
  60491. */
  60492. add(otherVector: DeepImmutable<Vector4>): Vector4;
  60493. /**
  60494. * Updates the given vector "result" with the result of the addition of the current Vector4 and the given one.
  60495. * @param otherVector the vector to add
  60496. * @param result the vector to store the result
  60497. * @returns the current Vector4.
  60498. */
  60499. addToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  60500. /**
  60501. * Subtract in place the given vector from the current Vector4.
  60502. * @param otherVector the vector to subtract
  60503. * @returns the updated Vector4.
  60504. */
  60505. subtractInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  60506. /**
  60507. * Returns a new Vector4 with the result of the subtraction of the given vector from the current Vector4.
  60508. * @param otherVector the vector to add
  60509. * @returns the new vector with the result
  60510. */
  60511. subtract(otherVector: DeepImmutable<Vector4>): Vector4;
  60512. /**
  60513. * Sets the given vector "result" with the result of the subtraction of the given vector from the current Vector4.
  60514. * @param otherVector the vector to subtract
  60515. * @param result the vector to store the result
  60516. * @returns the current Vector4.
  60517. */
  60518. subtractToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  60519. /**
  60520. * Returns a new Vector4 set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  60521. */
  60522. /**
  60523. * Returns a new Vector4 set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  60524. * @param x value to subtract
  60525. * @param y value to subtract
  60526. * @param z value to subtract
  60527. * @param w value to subtract
  60528. * @returns new vector containing the result
  60529. */
  60530. subtractFromFloats(x: number, y: number, z: number, w: number): Vector4;
  60531. /**
  60532. * Sets the given vector "result" set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  60533. * @param x value to subtract
  60534. * @param y value to subtract
  60535. * @param z value to subtract
  60536. * @param w value to subtract
  60537. * @param result the vector to store the result in
  60538. * @returns the current Vector4.
  60539. */
  60540. subtractFromFloatsToRef(x: number, y: number, z: number, w: number, result: Vector4): Vector4;
  60541. /**
  60542. * Returns a new Vector4 set with the current Vector4 negated coordinates.
  60543. * @returns a new vector with the negated values
  60544. */
  60545. negate(): Vector4;
  60546. /**
  60547. * Multiplies the current Vector4 coordinates by scale (float).
  60548. * @param scale the number to scale with
  60549. * @returns the updated Vector4.
  60550. */
  60551. scaleInPlace(scale: number): Vector4;
  60552. /**
  60553. * Returns a new Vector4 set with the current Vector4 coordinates multiplied by scale (float).
  60554. * @param scale the number to scale with
  60555. * @returns a new vector with the result
  60556. */
  60557. scale(scale: number): Vector4;
  60558. /**
  60559. * Sets the given vector "result" with the current Vector4 coordinates multiplied by scale (float).
  60560. * @param scale the number to scale with
  60561. * @param result a vector to store the result in
  60562. * @returns the current Vector4.
  60563. */
  60564. scaleToRef(scale: number, result: Vector4): Vector4;
  60565. /**
  60566. * Scale the current Vector4 values by a factor and add the result to a given Vector4
  60567. * @param scale defines the scale factor
  60568. * @param result defines the Vector4 object where to store the result
  60569. * @returns the unmodified current Vector4
  60570. */
  60571. scaleAndAddToRef(scale: number, result: Vector4): Vector4;
  60572. /**
  60573. * Boolean : True if the current Vector4 coordinates are stricly equal to the given ones.
  60574. * @param otherVector the vector to compare against
  60575. * @returns true if they are equal
  60576. */
  60577. equals(otherVector: DeepImmutable<Vector4>): boolean;
  60578. /**
  60579. * Boolean : True if the current Vector4 coordinates are each beneath the distance "epsilon" from the given vector ones.
  60580. * @param otherVector vector to compare against
  60581. * @param epsilon (Default: very small number)
  60582. * @returns true if they are equal
  60583. */
  60584. equalsWithEpsilon(otherVector: DeepImmutable<Vector4>, epsilon?: number): boolean;
  60585. /**
  60586. * Boolean : True if the given floats are strictly equal to the current Vector4 coordinates.
  60587. * @param x x value to compare against
  60588. * @param y y value to compare against
  60589. * @param z z value to compare against
  60590. * @param w w value to compare against
  60591. * @returns true if equal
  60592. */
  60593. equalsToFloats(x: number, y: number, z: number, w: number): boolean;
  60594. /**
  60595. * Multiplies in place the current Vector4 by the given one.
  60596. * @param otherVector vector to multiple with
  60597. * @returns the updated Vector4.
  60598. */
  60599. multiplyInPlace(otherVector: Vector4): Vector4;
  60600. /**
  60601. * Returns a new Vector4 set with the multiplication result of the current Vector4 and the given one.
  60602. * @param otherVector vector to multiple with
  60603. * @returns resulting new vector
  60604. */
  60605. multiply(otherVector: DeepImmutable<Vector4>): Vector4;
  60606. /**
  60607. * Updates the given vector "result" with the multiplication result of the current Vector4 and the given one.
  60608. * @param otherVector vector to multiple with
  60609. * @param result vector to store the result
  60610. * @returns the current Vector4.
  60611. */
  60612. multiplyToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  60613. /**
  60614. * Returns a new Vector4 set with the multiplication result of the given floats and the current Vector4 coordinates.
  60615. * @param x x value multiply with
  60616. * @param y y value multiply with
  60617. * @param z z value multiply with
  60618. * @param w w value multiply with
  60619. * @returns resulting new vector
  60620. */
  60621. multiplyByFloats(x: number, y: number, z: number, w: number): Vector4;
  60622. /**
  60623. * Returns a new Vector4 set with the division result of the current Vector4 by the given one.
  60624. * @param otherVector vector to devide with
  60625. * @returns resulting new vector
  60626. */
  60627. divide(otherVector: DeepImmutable<Vector4>): Vector4;
  60628. /**
  60629. * Updates the given vector "result" with the division result of the current Vector4 by the given one.
  60630. * @param otherVector vector to devide with
  60631. * @param result vector to store the result
  60632. * @returns the current Vector4.
  60633. */
  60634. divideToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  60635. /**
  60636. * Divides the current Vector3 coordinates by the given ones.
  60637. * @param otherVector vector to devide with
  60638. * @returns the updated Vector3.
  60639. */
  60640. divideInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  60641. /**
  60642. * Updates the Vector4 coordinates with the minimum values between its own and the given vector ones
  60643. * @param other defines the second operand
  60644. * @returns the current updated Vector4
  60645. */
  60646. minimizeInPlace(other: DeepImmutable<Vector4>): Vector4;
  60647. /**
  60648. * Updates the Vector4 coordinates with the maximum values between its own and the given vector ones
  60649. * @param other defines the second operand
  60650. * @returns the current updated Vector4
  60651. */
  60652. maximizeInPlace(other: DeepImmutable<Vector4>): Vector4;
  60653. /**
  60654. * Gets a new Vector4 from current Vector4 floored values
  60655. * @returns a new Vector4
  60656. */
  60657. floor(): Vector4;
  60658. /**
  60659. * Gets a new Vector4 from current Vector3 floored values
  60660. * @returns a new Vector4
  60661. */
  60662. fract(): Vector4;
  60663. /**
  60664. * Returns the Vector4 length (float).
  60665. * @returns the length
  60666. */
  60667. length(): number;
  60668. /**
  60669. * Returns the Vector4 squared length (float).
  60670. * @returns the length squared
  60671. */
  60672. lengthSquared(): number;
  60673. /**
  60674. * Normalizes in place the Vector4.
  60675. * @returns the updated Vector4.
  60676. */
  60677. normalize(): Vector4;
  60678. /**
  60679. * Returns a new Vector3 from the Vector4 (x, y, z) coordinates.
  60680. * @returns this converted to a new vector3
  60681. */
  60682. toVector3(): Vector3;
  60683. /**
  60684. * Returns a new Vector4 copied from the current one.
  60685. * @returns the new cloned vector
  60686. */
  60687. clone(): Vector4;
  60688. /**
  60689. * Updates the current Vector4 with the given one coordinates.
  60690. * @param source the source vector to copy from
  60691. * @returns the updated Vector4.
  60692. */
  60693. copyFrom(source: DeepImmutable<Vector4>): Vector4;
  60694. /**
  60695. * Updates the current Vector4 coordinates with the given floats.
  60696. * @param x float to copy from
  60697. * @param y float to copy from
  60698. * @param z float to copy from
  60699. * @param w float to copy from
  60700. * @returns the updated Vector4.
  60701. */
  60702. copyFromFloats(x: number, y: number, z: number, w: number): Vector4;
  60703. /**
  60704. * Updates the current Vector4 coordinates with the given floats.
  60705. * @param x float to set from
  60706. * @param y float to set from
  60707. * @param z float to set from
  60708. * @param w float to set from
  60709. * @returns the updated Vector4.
  60710. */
  60711. set(x: number, y: number, z: number, w: number): Vector4;
  60712. /**
  60713. * Copies the given float to the current Vector3 coordinates
  60714. * @param v defines the x, y, z and w coordinates of the operand
  60715. * @returns the current updated Vector3
  60716. */
  60717. setAll(v: number): Vector4;
  60718. /**
  60719. * Returns a new Vector4 set from the starting index of the given array.
  60720. * @param array the array to pull values from
  60721. * @param offset the offset into the array to start at
  60722. * @returns the new vector
  60723. */
  60724. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector4;
  60725. /**
  60726. * Updates the given vector "result" from the starting index of the given array.
  60727. * @param array the array to pull values from
  60728. * @param offset the offset into the array to start at
  60729. * @param result the vector to store the result in
  60730. */
  60731. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector4): void;
  60732. /**
  60733. * Updates the given vector "result" from the starting index of the given Float32Array.
  60734. * @param array the array to pull values from
  60735. * @param offset the offset into the array to start at
  60736. * @param result the vector to store the result in
  60737. */
  60738. static FromFloatArrayToRef(array: DeepImmutable<Float32Array>, offset: number, result: Vector4): void;
  60739. /**
  60740. * Updates the given vector "result" coordinates from the given floats.
  60741. * @param x float to set from
  60742. * @param y float to set from
  60743. * @param z float to set from
  60744. * @param w float to set from
  60745. * @param result the vector to the floats in
  60746. */
  60747. static FromFloatsToRef(x: number, y: number, z: number, w: number, result: Vector4): void;
  60748. /**
  60749. * Returns a new Vector4 set to (0.0, 0.0, 0.0, 0.0)
  60750. * @returns the new vector
  60751. */
  60752. static Zero(): Vector4;
  60753. /**
  60754. * Returns a new Vector4 set to (1.0, 1.0, 1.0, 1.0)
  60755. * @returns the new vector
  60756. */
  60757. static One(): Vector4;
  60758. /**
  60759. * Returns a new normalized Vector4 from the given one.
  60760. * @param vector the vector to normalize
  60761. * @returns the vector
  60762. */
  60763. static Normalize(vector: DeepImmutable<Vector4>): Vector4;
  60764. /**
  60765. * Updates the given vector "result" from the normalization of the given one.
  60766. * @param vector the vector to normalize
  60767. * @param result the vector to store the result in
  60768. */
  60769. static NormalizeToRef(vector: DeepImmutable<Vector4>, result: Vector4): void;
  60770. /**
  60771. * Returns a vector with the minimum values from the left and right vectors
  60772. * @param left left vector to minimize
  60773. * @param right right vector to minimize
  60774. * @returns a new vector with the minimum of the left and right vector values
  60775. */
  60776. static Minimize(left: DeepImmutable<Vector4>, right: DeepImmutable<Vector4>): Vector4;
  60777. /**
  60778. * Returns a vector with the maximum values from the left and right vectors
  60779. * @param left left vector to maximize
  60780. * @param right right vector to maximize
  60781. * @returns a new vector with the maximum of the left and right vector values
  60782. */
  60783. static Maximize(left: DeepImmutable<Vector4>, right: DeepImmutable<Vector4>): Vector4;
  60784. /**
  60785. * Returns the distance (float) between the vectors "value1" and "value2".
  60786. * @param value1 value to calulate the distance between
  60787. * @param value2 value to calulate the distance between
  60788. * @return the distance between the two vectors
  60789. */
  60790. static Distance(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): number;
  60791. /**
  60792. * Returns the squared distance (float) between the vectors "value1" and "value2".
  60793. * @param value1 value to calulate the distance between
  60794. * @param value2 value to calulate the distance between
  60795. * @return the distance between the two vectors squared
  60796. */
  60797. static DistanceSquared(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): number;
  60798. /**
  60799. * Returns a new Vector4 located at the center between the vectors "value1" and "value2".
  60800. * @param value1 value to calulate the center between
  60801. * @param value2 value to calulate the center between
  60802. * @return the center between the two vectors
  60803. */
  60804. static Center(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): Vector4;
  60805. /**
  60806. * Returns a new Vector4 set with the result of the normal transformation by the given matrix of the given vector.
  60807. * This methods computes transformed normalized direction vectors only.
  60808. * @param vector the vector to transform
  60809. * @param transformation the transformation matrix to apply
  60810. * @returns the new vector
  60811. */
  60812. static TransformNormal(vector: DeepImmutable<Vector4>, transformation: DeepImmutable<Matrix>): Vector4;
  60813. /**
  60814. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given vector.
  60815. * This methods computes transformed normalized direction vectors only.
  60816. * @param vector the vector to transform
  60817. * @param transformation the transformation matrix to apply
  60818. * @param result the vector to store the result in
  60819. */
  60820. static TransformNormalToRef(vector: DeepImmutable<Vector4>, transformation: DeepImmutable<Matrix>, result: Vector4): void;
  60821. /**
  60822. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given floats (x, y, z, w).
  60823. * This methods computes transformed normalized direction vectors only.
  60824. * @param x value to transform
  60825. * @param y value to transform
  60826. * @param z value to transform
  60827. * @param w value to transform
  60828. * @param transformation the transformation matrix to apply
  60829. * @param result the vector to store the results in
  60830. */
  60831. static TransformNormalFromFloatsToRef(x: number, y: number, z: number, w: number, transformation: DeepImmutable<Matrix>, result: Vector4): void;
  60832. /**
  60833. * Creates a new Vector4 from a Vector3
  60834. * @param source defines the source data
  60835. * @param w defines the 4th component (default is 0)
  60836. * @returns a new Vector4
  60837. */
  60838. static FromVector3(source: Vector3, w?: number): Vector4;
  60839. }
  60840. /**
  60841. * Interface for the size containing width and height
  60842. */
  60843. export interface ISize {
  60844. /**
  60845. * Width
  60846. */
  60847. width: number;
  60848. /**
  60849. * Heighht
  60850. */
  60851. height: number;
  60852. }
  60853. /**
  60854. * Size containing widht and height
  60855. */
  60856. export class Size implements ISize {
  60857. /**
  60858. * Width
  60859. */
  60860. width: number;
  60861. /**
  60862. * Height
  60863. */
  60864. height: number;
  60865. /**
  60866. * Creates a Size object from the given width and height (floats).
  60867. * @param width width of the new size
  60868. * @param height height of the new size
  60869. */
  60870. constructor(width: number, height: number);
  60871. /**
  60872. * Returns a string with the Size width and height
  60873. * @returns a string with the Size width and height
  60874. */
  60875. toString(): string;
  60876. /**
  60877. * "Size"
  60878. * @returns the string "Size"
  60879. */
  60880. getClassName(): string;
  60881. /**
  60882. * Returns the Size hash code.
  60883. * @returns a hash code for a unique width and height
  60884. */
  60885. getHashCode(): number;
  60886. /**
  60887. * Updates the current size from the given one.
  60888. * @param src the given size
  60889. */
  60890. copyFrom(src: Size): void;
  60891. /**
  60892. * Updates in place the current Size from the given floats.
  60893. * @param width width of the new size
  60894. * @param height height of the new size
  60895. * @returns the updated Size.
  60896. */
  60897. copyFromFloats(width: number, height: number): Size;
  60898. /**
  60899. * Updates in place the current Size from the given floats.
  60900. * @param width width to set
  60901. * @param height height to set
  60902. * @returns the updated Size.
  60903. */
  60904. set(width: number, height: number): Size;
  60905. /**
  60906. * Multiplies the width and height by numbers
  60907. * @param w factor to multiple the width by
  60908. * @param h factor to multiple the height by
  60909. * @returns a new Size set with the multiplication result of the current Size and the given floats.
  60910. */
  60911. multiplyByFloats(w: number, h: number): Size;
  60912. /**
  60913. * Clones the size
  60914. * @returns a new Size copied from the given one.
  60915. */
  60916. clone(): Size;
  60917. /**
  60918. * True if the current Size and the given one width and height are strictly equal.
  60919. * @param other the other size to compare against
  60920. * @returns True if the current Size and the given one width and height are strictly equal.
  60921. */
  60922. equals(other: Size): boolean;
  60923. /**
  60924. * The surface of the Size : width * height (float).
  60925. */
  60926. readonly surface: number;
  60927. /**
  60928. * Create a new size of zero
  60929. * @returns a new Size set to (0.0, 0.0)
  60930. */
  60931. static Zero(): Size;
  60932. /**
  60933. * Sums the width and height of two sizes
  60934. * @param otherSize size to add to this size
  60935. * @returns a new Size set as the addition result of the current Size and the given one.
  60936. */
  60937. add(otherSize: Size): Size;
  60938. /**
  60939. * Subtracts the width and height of two
  60940. * @param otherSize size to subtract to this size
  60941. * @returns a new Size set as the subtraction result of the given one from the current Size.
  60942. */
  60943. subtract(otherSize: Size): Size;
  60944. /**
  60945. * Creates a new Size set at the linear interpolation "amount" between "start" and "end"
  60946. * @param start starting size to lerp between
  60947. * @param end end size to lerp between
  60948. * @param amount amount to lerp between the start and end values
  60949. * @returns a new Size set at the linear interpolation "amount" between "start" and "end"
  60950. */
  60951. static Lerp(start: Size, end: Size, amount: number): Size;
  60952. }
  60953. /**
  60954. * Class used to store quaternion data
  60955. * @see https://en.wikipedia.org/wiki/Quaternion
  60956. * @see http://doc.babylonjs.com/features/position,_rotation,_scaling
  60957. */
  60958. export class Quaternion {
  60959. /** defines the first component (0 by default) */
  60960. x: number;
  60961. /** defines the second component (0 by default) */
  60962. y: number;
  60963. /** defines the third component (0 by default) */
  60964. z: number;
  60965. /** defines the fourth component (1.0 by default) */
  60966. w: number;
  60967. /**
  60968. * Creates a new Quaternion from the given floats
  60969. * @param x defines the first component (0 by default)
  60970. * @param y defines the second component (0 by default)
  60971. * @param z defines the third component (0 by default)
  60972. * @param w defines the fourth component (1.0 by default)
  60973. */
  60974. constructor(
  60975. /** defines the first component (0 by default) */
  60976. x?: number,
  60977. /** defines the second component (0 by default) */
  60978. y?: number,
  60979. /** defines the third component (0 by default) */
  60980. z?: number,
  60981. /** defines the fourth component (1.0 by default) */
  60982. w?: number);
  60983. /**
  60984. * Gets a string representation for the current quaternion
  60985. * @returns a string with the Quaternion coordinates
  60986. */
  60987. toString(): string;
  60988. /**
  60989. * Gets the class name of the quaternion
  60990. * @returns the string "Quaternion"
  60991. */
  60992. getClassName(): string;
  60993. /**
  60994. * Gets a hash code for this quaternion
  60995. * @returns the quaternion hash code
  60996. */
  60997. getHashCode(): number;
  60998. /**
  60999. * Copy the quaternion to an array
  61000. * @returns a new array populated with 4 elements from the quaternion coordinates
  61001. */
  61002. asArray(): number[];
  61003. /**
  61004. * Check if two quaternions are equals
  61005. * @param otherQuaternion defines the second operand
  61006. * @return true if the current quaternion and the given one coordinates are strictly equals
  61007. */
  61008. equals(otherQuaternion: DeepImmutable<Quaternion>): boolean;
  61009. /**
  61010. * Clone the current quaternion
  61011. * @returns a new quaternion copied from the current one
  61012. */
  61013. clone(): Quaternion;
  61014. /**
  61015. * Copy a quaternion to the current one
  61016. * @param other defines the other quaternion
  61017. * @returns the updated current quaternion
  61018. */
  61019. copyFrom(other: DeepImmutable<Quaternion>): Quaternion;
  61020. /**
  61021. * Updates the current quaternion with the given float coordinates
  61022. * @param x defines the x coordinate
  61023. * @param y defines the y coordinate
  61024. * @param z defines the z coordinate
  61025. * @param w defines the w coordinate
  61026. * @returns the updated current quaternion
  61027. */
  61028. copyFromFloats(x: number, y: number, z: number, w: number): Quaternion;
  61029. /**
  61030. * Updates the current quaternion from the given float coordinates
  61031. * @param x defines the x coordinate
  61032. * @param y defines the y coordinate
  61033. * @param z defines the z coordinate
  61034. * @param w defines the w coordinate
  61035. * @returns the updated current quaternion
  61036. */
  61037. set(x: number, y: number, z: number, w: number): Quaternion;
  61038. /**
  61039. * Adds two quaternions
  61040. * @param other defines the second operand
  61041. * @returns a new quaternion as the addition result of the given one and the current quaternion
  61042. */
  61043. add(other: DeepImmutable<Quaternion>): Quaternion;
  61044. /**
  61045. * Add a quaternion to the current one
  61046. * @param other defines the quaternion to add
  61047. * @returns the current quaternion
  61048. */
  61049. addInPlace(other: DeepImmutable<Quaternion>): Quaternion;
  61050. /**
  61051. * Subtract two quaternions
  61052. * @param other defines the second operand
  61053. * @returns a new quaternion as the subtraction result of the given one from the current one
  61054. */
  61055. subtract(other: Quaternion): Quaternion;
  61056. /**
  61057. * Multiplies the current quaternion by a scale factor
  61058. * @param value defines the scale factor
  61059. * @returns a new quaternion set by multiplying the current quaternion coordinates by the float "scale"
  61060. */
  61061. scale(value: number): Quaternion;
  61062. /**
  61063. * Scale the current quaternion values by a factor and stores the result to a given quaternion
  61064. * @param scale defines the scale factor
  61065. * @param result defines the Quaternion object where to store the result
  61066. * @returns the unmodified current quaternion
  61067. */
  61068. scaleToRef(scale: number, result: Quaternion): Quaternion;
  61069. /**
  61070. * Multiplies in place the current quaternion by a scale factor
  61071. * @param value defines the scale factor
  61072. * @returns the current modified quaternion
  61073. */
  61074. scaleInPlace(value: number): Quaternion;
  61075. /**
  61076. * Scale the current quaternion values by a factor and add the result to a given quaternion
  61077. * @param scale defines the scale factor
  61078. * @param result defines the Quaternion object where to store the result
  61079. * @returns the unmodified current quaternion
  61080. */
  61081. scaleAndAddToRef(scale: number, result: Quaternion): Quaternion;
  61082. /**
  61083. * Multiplies two quaternions
  61084. * @param q1 defines the second operand
  61085. * @returns a new quaternion set as the multiplication result of the current one with the given one "q1"
  61086. */
  61087. multiply(q1: DeepImmutable<Quaternion>): Quaternion;
  61088. /**
  61089. * Sets the given "result" as the the multiplication result of the current one with the given one "q1"
  61090. * @param q1 defines the second operand
  61091. * @param result defines the target quaternion
  61092. * @returns the current quaternion
  61093. */
  61094. multiplyToRef(q1: DeepImmutable<Quaternion>, result: Quaternion): Quaternion;
  61095. /**
  61096. * Updates the current quaternion with the multiplication of itself with the given one "q1"
  61097. * @param q1 defines the second operand
  61098. * @returns the currentupdated quaternion
  61099. */
  61100. multiplyInPlace(q1: DeepImmutable<Quaternion>): Quaternion;
  61101. /**
  61102. * Conjugates (1-q) the current quaternion and stores the result in the given quaternion
  61103. * @param ref defines the target quaternion
  61104. * @returns the current quaternion
  61105. */
  61106. conjugateToRef(ref: Quaternion): Quaternion;
  61107. /**
  61108. * Conjugates in place (1-q) the current quaternion
  61109. * @returns the current updated quaternion
  61110. */
  61111. conjugateInPlace(): Quaternion;
  61112. /**
  61113. * Conjugates in place (1-q) the current quaternion
  61114. * @returns a new quaternion
  61115. */
  61116. conjugate(): Quaternion;
  61117. /**
  61118. * Gets length of current quaternion
  61119. * @returns the quaternion length (float)
  61120. */
  61121. length(): number;
  61122. /**
  61123. * Normalize in place the current quaternion
  61124. * @returns the current updated quaternion
  61125. */
  61126. normalize(): Quaternion;
  61127. /**
  61128. * Returns a new Vector3 set with the Euler angles translated from the current quaternion
  61129. * @param order is a reserved parameter and is ignore for now
  61130. * @returns a new Vector3 containing the Euler angles
  61131. */
  61132. toEulerAngles(order?: string): Vector3;
  61133. /**
  61134. * Sets the given vector3 "result" with the Euler angles translated from the current quaternion
  61135. * @param result defines the vector which will be filled with the Euler angles
  61136. * @param order is a reserved parameter and is ignore for now
  61137. * @returns the current unchanged quaternion
  61138. */
  61139. toEulerAnglesToRef(result: Vector3): Quaternion;
  61140. /**
  61141. * Updates the given rotation matrix with the current quaternion values
  61142. * @param result defines the target matrix
  61143. * @returns the current unchanged quaternion
  61144. */
  61145. toRotationMatrix(result: Matrix): Quaternion;
  61146. /**
  61147. * Updates the current quaternion from the given rotation matrix values
  61148. * @param matrix defines the source matrix
  61149. * @returns the current updated quaternion
  61150. */
  61151. fromRotationMatrix(matrix: DeepImmutable<Matrix>): Quaternion;
  61152. /**
  61153. * Creates a new quaternion from a rotation matrix
  61154. * @param matrix defines the source matrix
  61155. * @returns a new quaternion created from the given rotation matrix values
  61156. */
  61157. static FromRotationMatrix(matrix: DeepImmutable<Matrix>): Quaternion;
  61158. /**
  61159. * Updates the given quaternion with the given rotation matrix values
  61160. * @param matrix defines the source matrix
  61161. * @param result defines the target quaternion
  61162. */
  61163. static FromRotationMatrixToRef(matrix: DeepImmutable<Matrix>, result: Quaternion): void;
  61164. /**
  61165. * Returns the dot product (float) between the quaternions "left" and "right"
  61166. * @param left defines the left operand
  61167. * @param right defines the right operand
  61168. * @returns the dot product
  61169. */
  61170. static Dot(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>): number;
  61171. /**
  61172. * Checks if the two quaternions are close to each other
  61173. * @param quat0 defines the first quaternion to check
  61174. * @param quat1 defines the second quaternion to check
  61175. * @returns true if the two quaternions are close to each other
  61176. */
  61177. static AreClose(quat0: DeepImmutable<Quaternion>, quat1: DeepImmutable<Quaternion>): boolean;
  61178. /**
  61179. * Creates an empty quaternion
  61180. * @returns a new quaternion set to (0.0, 0.0, 0.0)
  61181. */
  61182. static Zero(): Quaternion;
  61183. /**
  61184. * Inverse a given quaternion
  61185. * @param q defines the source quaternion
  61186. * @returns a new quaternion as the inverted current quaternion
  61187. */
  61188. static Inverse(q: DeepImmutable<Quaternion>): Quaternion;
  61189. /**
  61190. * Inverse a given quaternion
  61191. * @param q defines the source quaternion
  61192. * @param result the quaternion the result will be stored in
  61193. * @returns the result quaternion
  61194. */
  61195. static InverseToRef(q: Quaternion, result: Quaternion): Quaternion;
  61196. /**
  61197. * Creates an identity quaternion
  61198. * @returns the identity quaternion
  61199. */
  61200. static Identity(): Quaternion;
  61201. /**
  61202. * Gets a boolean indicating if the given quaternion is identity
  61203. * @param quaternion defines the quaternion to check
  61204. * @returns true if the quaternion is identity
  61205. */
  61206. static IsIdentity(quaternion: DeepImmutable<Quaternion>): boolean;
  61207. /**
  61208. * Creates a quaternion from a rotation around an axis
  61209. * @param axis defines the axis to use
  61210. * @param angle defines the angle to use
  61211. * @returns a new quaternion created from the given axis (Vector3) and angle in radians (float)
  61212. */
  61213. static RotationAxis(axis: DeepImmutable<Vector3>, angle: number): Quaternion;
  61214. /**
  61215. * Creates a rotation around an axis and stores it into the given quaternion
  61216. * @param axis defines the axis to use
  61217. * @param angle defines the angle to use
  61218. * @param result defines the target quaternion
  61219. * @returns the target quaternion
  61220. */
  61221. static RotationAxisToRef(axis: DeepImmutable<Vector3>, angle: number, result: Quaternion): Quaternion;
  61222. /**
  61223. * Creates a new quaternion from data stored into an array
  61224. * @param array defines the data source
  61225. * @param offset defines the offset in the source array where the data starts
  61226. * @returns a new quaternion
  61227. */
  61228. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Quaternion;
  61229. /**
  61230. * Create a quaternion from Euler rotation angles
  61231. * @param x Pitch
  61232. * @param y Yaw
  61233. * @param z Roll
  61234. * @returns the new Quaternion
  61235. */
  61236. static FromEulerAngles(x: number, y: number, z: number): Quaternion;
  61237. /**
  61238. * Updates a quaternion from Euler rotation angles
  61239. * @param x Pitch
  61240. * @param y Yaw
  61241. * @param z Roll
  61242. * @param result the quaternion to store the result
  61243. * @returns the updated quaternion
  61244. */
  61245. static FromEulerAnglesToRef(x: number, y: number, z: number, result: Quaternion): Quaternion;
  61246. /**
  61247. * Create a quaternion from Euler rotation vector
  61248. * @param vec the Euler vector (x Pitch, y Yaw, z Roll)
  61249. * @returns the new Quaternion
  61250. */
  61251. static FromEulerVector(vec: DeepImmutable<Vector3>): Quaternion;
  61252. /**
  61253. * Updates a quaternion from Euler rotation vector
  61254. * @param vec the Euler vector (x Pitch, y Yaw, z Roll)
  61255. * @param result the quaternion to store the result
  61256. * @returns the updated quaternion
  61257. */
  61258. static FromEulerVectorToRef(vec: DeepImmutable<Vector3>, result: Quaternion): Quaternion;
  61259. /**
  61260. * Creates a new quaternion from the given Euler float angles (y, x, z)
  61261. * @param yaw defines the rotation around Y axis
  61262. * @param pitch defines the rotation around X axis
  61263. * @param roll defines the rotation around Z axis
  61264. * @returns the new quaternion
  61265. */
  61266. static RotationYawPitchRoll(yaw: number, pitch: number, roll: number): Quaternion;
  61267. /**
  61268. * Creates a new rotation from the given Euler float angles (y, x, z) and stores it in the target quaternion
  61269. * @param yaw defines the rotation around Y axis
  61270. * @param pitch defines the rotation around X axis
  61271. * @param roll defines the rotation around Z axis
  61272. * @param result defines the target quaternion
  61273. */
  61274. static RotationYawPitchRollToRef(yaw: number, pitch: number, roll: number, result: Quaternion): void;
  61275. /**
  61276. * Creates a new quaternion from the given Euler float angles expressed in z-x-z orientation
  61277. * @param alpha defines the rotation around first axis
  61278. * @param beta defines the rotation around second axis
  61279. * @param gamma defines the rotation around third axis
  61280. * @returns the new quaternion
  61281. */
  61282. static RotationAlphaBetaGamma(alpha: number, beta: number, gamma: number): Quaternion;
  61283. /**
  61284. * Creates a new quaternion from the given Euler float angles expressed in z-x-z orientation and stores it in the target quaternion
  61285. * @param alpha defines the rotation around first axis
  61286. * @param beta defines the rotation around second axis
  61287. * @param gamma defines the rotation around third axis
  61288. * @param result defines the target quaternion
  61289. */
  61290. static RotationAlphaBetaGammaToRef(alpha: number, beta: number, gamma: number, result: Quaternion): void;
  61291. /**
  61292. * 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)
  61293. * @param axis1 defines the first axis
  61294. * @param axis2 defines the second axis
  61295. * @param axis3 defines the third axis
  61296. * @returns the new quaternion
  61297. */
  61298. static RotationQuaternionFromAxis(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>): Quaternion;
  61299. /**
  61300. * 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
  61301. * @param axis1 defines the first axis
  61302. * @param axis2 defines the second axis
  61303. * @param axis3 defines the third axis
  61304. * @param ref defines the target quaternion
  61305. */
  61306. static RotationQuaternionFromAxisToRef(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>, ref: Quaternion): void;
  61307. /**
  61308. * Interpolates between two quaternions
  61309. * @param left defines first quaternion
  61310. * @param right defines second quaternion
  61311. * @param amount defines the gradient to use
  61312. * @returns the new interpolated quaternion
  61313. */
  61314. static Slerp(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>, amount: number): Quaternion;
  61315. /**
  61316. * Interpolates between two quaternions and stores it into a target quaternion
  61317. * @param left defines first quaternion
  61318. * @param right defines second quaternion
  61319. * @param amount defines the gradient to use
  61320. * @param result defines the target quaternion
  61321. */
  61322. static SlerpToRef(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>, amount: number, result: Quaternion): void;
  61323. /**
  61324. * Interpolate between two quaternions using Hermite interpolation
  61325. * @param value1 defines first quaternion
  61326. * @param tangent1 defines the incoming tangent
  61327. * @param value2 defines second quaternion
  61328. * @param tangent2 defines the outgoing tangent
  61329. * @param amount defines the target quaternion
  61330. * @returns the new interpolated quaternion
  61331. */
  61332. static Hermite(value1: DeepImmutable<Quaternion>, tangent1: DeepImmutable<Quaternion>, value2: DeepImmutable<Quaternion>, tangent2: DeepImmutable<Quaternion>, amount: number): Quaternion;
  61333. }
  61334. /**
  61335. * Class used to store matrix data (4x4)
  61336. */
  61337. export class Matrix {
  61338. private static _updateFlagSeed;
  61339. private static _identityReadOnly;
  61340. private _isIdentity;
  61341. private _isIdentityDirty;
  61342. private _isIdentity3x2;
  61343. private _isIdentity3x2Dirty;
  61344. /**
  61345. * Gets the update flag of the matrix which is an unique number for the matrix.
  61346. * It will be incremented every time the matrix data change.
  61347. * You can use it to speed the comparison between two versions of the same matrix.
  61348. */
  61349. updateFlag: number;
  61350. private readonly _m;
  61351. /**
  61352. * Gets the internal data of the matrix
  61353. */
  61354. readonly m: DeepImmutable<Float32Array>;
  61355. /** @hidden */
  61356. _markAsUpdated(): void;
  61357. /** @hidden */
  61358. private _updateIdentityStatus;
  61359. /**
  61360. * Creates an empty matrix (filled with zeros)
  61361. */
  61362. constructor();
  61363. /**
  61364. * Check if the current matrix is identity
  61365. * @returns true is the matrix is the identity matrix
  61366. */
  61367. isIdentity(): boolean;
  61368. /**
  61369. * Check if the current matrix is identity as a texture matrix (3x2 store in 4x4)
  61370. * @returns true is the matrix is the identity matrix
  61371. */
  61372. isIdentityAs3x2(): boolean;
  61373. /**
  61374. * Gets the determinant of the matrix
  61375. * @returns the matrix determinant
  61376. */
  61377. determinant(): number;
  61378. /**
  61379. * Returns the matrix as a Float32Array
  61380. * @returns the matrix underlying array
  61381. */
  61382. toArray(): DeepImmutable<Float32Array>;
  61383. /**
  61384. * Returns the matrix as a Float32Array
  61385. * @returns the matrix underlying array.
  61386. */
  61387. asArray(): DeepImmutable<Float32Array>;
  61388. /**
  61389. * Inverts the current matrix in place
  61390. * @returns the current inverted matrix
  61391. */
  61392. invert(): Matrix;
  61393. /**
  61394. * Sets all the matrix elements to zero
  61395. * @returns the current matrix
  61396. */
  61397. reset(): Matrix;
  61398. /**
  61399. * Adds the current matrix with a second one
  61400. * @param other defines the matrix to add
  61401. * @returns a new matrix as the addition of the current matrix and the given one
  61402. */
  61403. add(other: DeepImmutable<Matrix>): Matrix;
  61404. /**
  61405. * Sets the given matrix "result" to the addition of the current matrix and the given one
  61406. * @param other defines the matrix to add
  61407. * @param result defines the target matrix
  61408. * @returns the current matrix
  61409. */
  61410. addToRef(other: DeepImmutable<Matrix>, result: Matrix): Matrix;
  61411. /**
  61412. * Adds in place the given matrix to the current matrix
  61413. * @param other defines the second operand
  61414. * @returns the current updated matrix
  61415. */
  61416. addToSelf(other: DeepImmutable<Matrix>): Matrix;
  61417. /**
  61418. * Sets the given matrix to the current inverted Matrix
  61419. * @param other defines the target matrix
  61420. * @returns the unmodified current matrix
  61421. */
  61422. invertToRef(other: Matrix): Matrix;
  61423. /**
  61424. * add a value at the specified position in the current Matrix
  61425. * @param index the index of the value within the matrix. between 0 and 15.
  61426. * @param value the value to be added
  61427. * @returns the current updated matrix
  61428. */
  61429. addAtIndex(index: number, value: number): Matrix;
  61430. /**
  61431. * mutiply the specified position in the current Matrix by a value
  61432. * @param index the index of the value within the matrix. between 0 and 15.
  61433. * @param value the value to be added
  61434. * @returns the current updated matrix
  61435. */
  61436. multiplyAtIndex(index: number, value: number): Matrix;
  61437. /**
  61438. * Inserts the translation vector (using 3 floats) in the current matrix
  61439. * @param x defines the 1st component of the translation
  61440. * @param y defines the 2nd component of the translation
  61441. * @param z defines the 3rd component of the translation
  61442. * @returns the current updated matrix
  61443. */
  61444. setTranslationFromFloats(x: number, y: number, z: number): Matrix;
  61445. /**
  61446. * Inserts the translation vector in the current matrix
  61447. * @param vector3 defines the translation to insert
  61448. * @returns the current updated matrix
  61449. */
  61450. setTranslation(vector3: DeepImmutable<Vector3>): Matrix;
  61451. /**
  61452. * Gets the translation value of the current matrix
  61453. * @returns a new Vector3 as the extracted translation from the matrix
  61454. */
  61455. getTranslation(): Vector3;
  61456. /**
  61457. * Fill a Vector3 with the extracted translation from the matrix
  61458. * @param result defines the Vector3 where to store the translation
  61459. * @returns the current matrix
  61460. */
  61461. getTranslationToRef(result: Vector3): Matrix;
  61462. /**
  61463. * Remove rotation and scaling part from the matrix
  61464. * @returns the updated matrix
  61465. */
  61466. removeRotationAndScaling(): Matrix;
  61467. /**
  61468. * Multiply two matrices
  61469. * @param other defines the second operand
  61470. * @returns a new matrix set with the multiplication result of the current Matrix and the given one
  61471. */
  61472. multiply(other: DeepImmutable<Matrix>): Matrix;
  61473. /**
  61474. * Copy the current matrix from the given one
  61475. * @param other defines the source matrix
  61476. * @returns the current updated matrix
  61477. */
  61478. copyFrom(other: DeepImmutable<Matrix>): Matrix;
  61479. /**
  61480. * Populates the given array from the starting index with the current matrix values
  61481. * @param array defines the target array
  61482. * @param offset defines the offset in the target array where to start storing values
  61483. * @returns the current matrix
  61484. */
  61485. copyToArray(array: Float32Array, offset?: number): Matrix;
  61486. /**
  61487. * Sets the given matrix "result" with the multiplication result of the current Matrix and the given one
  61488. * @param other defines the second operand
  61489. * @param result defines the matrix where to store the multiplication
  61490. * @returns the current matrix
  61491. */
  61492. multiplyToRef(other: DeepImmutable<Matrix>, result: Matrix): Matrix;
  61493. /**
  61494. * Sets the Float32Array "result" from the given index "offset" with the multiplication of the current matrix and the given one
  61495. * @param other defines the second operand
  61496. * @param result defines the array where to store the multiplication
  61497. * @param offset defines the offset in the target array where to start storing values
  61498. * @returns the current matrix
  61499. */
  61500. multiplyToArray(other: DeepImmutable<Matrix>, result: Float32Array, offset: number): Matrix;
  61501. /**
  61502. * Check equality between this matrix and a second one
  61503. * @param value defines the second matrix to compare
  61504. * @returns true is the current matrix and the given one values are strictly equal
  61505. */
  61506. equals(value: DeepImmutable<Matrix>): boolean;
  61507. /**
  61508. * Clone the current matrix
  61509. * @returns a new matrix from the current matrix
  61510. */
  61511. clone(): Matrix;
  61512. /**
  61513. * Returns the name of the current matrix class
  61514. * @returns the string "Matrix"
  61515. */
  61516. getClassName(): string;
  61517. /**
  61518. * Gets the hash code of the current matrix
  61519. * @returns the hash code
  61520. */
  61521. getHashCode(): number;
  61522. /**
  61523. * Decomposes the current Matrix into a translation, rotation and scaling components
  61524. * @param scale defines the scale vector3 given as a reference to update
  61525. * @param rotation defines the rotation quaternion given as a reference to update
  61526. * @param translation defines the translation vector3 given as a reference to update
  61527. * @returns true if operation was successful
  61528. */
  61529. decompose(scale?: Vector3, rotation?: Quaternion, translation?: Vector3): boolean;
  61530. /**
  61531. * Gets specific row of the matrix
  61532. * @param index defines the number of the row to get
  61533. * @returns the index-th row of the current matrix as a new Vector4
  61534. */
  61535. getRow(index: number): Nullable<Vector4>;
  61536. /**
  61537. * Sets the index-th row of the current matrix to the vector4 values
  61538. * @param index defines the number of the row to set
  61539. * @param row defines the target vector4
  61540. * @returns the updated current matrix
  61541. */
  61542. setRow(index: number, row: Vector4): Matrix;
  61543. /**
  61544. * Compute the transpose of the matrix
  61545. * @returns the new transposed matrix
  61546. */
  61547. transpose(): Matrix;
  61548. /**
  61549. * Compute the transpose of the matrix and store it in a given matrix
  61550. * @param result defines the target matrix
  61551. * @returns the current matrix
  61552. */
  61553. transposeToRef(result: Matrix): Matrix;
  61554. /**
  61555. * Sets the index-th row of the current matrix with the given 4 x float values
  61556. * @param index defines the row index
  61557. * @param x defines the x component to set
  61558. * @param y defines the y component to set
  61559. * @param z defines the z component to set
  61560. * @param w defines the w component to set
  61561. * @returns the updated current matrix
  61562. */
  61563. setRowFromFloats(index: number, x: number, y: number, z: number, w: number): Matrix;
  61564. /**
  61565. * Compute a new matrix set with the current matrix values multiplied by scale (float)
  61566. * @param scale defines the scale factor
  61567. * @returns a new matrix
  61568. */
  61569. scale(scale: number): Matrix;
  61570. /**
  61571. * Scale the current matrix values by a factor to a given result matrix
  61572. * @param scale defines the scale factor
  61573. * @param result defines the matrix to store the result
  61574. * @returns the current matrix
  61575. */
  61576. scaleToRef(scale: number, result: Matrix): Matrix;
  61577. /**
  61578. * Scale the current matrix values by a factor and add the result to a given matrix
  61579. * @param scale defines the scale factor
  61580. * @param result defines the Matrix to store the result
  61581. * @returns the current matrix
  61582. */
  61583. scaleAndAddToRef(scale: number, result: Matrix): Matrix;
  61584. /**
  61585. * Writes to the given matrix a normal matrix, computed from this one (using values from identity matrix for fourth row and column).
  61586. * @param ref matrix to store the result
  61587. */
  61588. toNormalMatrix(ref: Matrix): void;
  61589. /**
  61590. * Gets only rotation part of the current matrix
  61591. * @returns a new matrix sets to the extracted rotation matrix from the current one
  61592. */
  61593. getRotationMatrix(): Matrix;
  61594. /**
  61595. * Extracts the rotation matrix from the current one and sets it as the given "result"
  61596. * @param result defines the target matrix to store data to
  61597. * @returns the current matrix
  61598. */
  61599. getRotationMatrixToRef(result: Matrix): Matrix;
  61600. /**
  61601. * Toggles model matrix from being right handed to left handed in place and vice versa
  61602. */
  61603. toggleModelMatrixHandInPlace(): void;
  61604. /**
  61605. * Toggles projection matrix from being right handed to left handed in place and vice versa
  61606. */
  61607. toggleProjectionMatrixHandInPlace(): void;
  61608. /**
  61609. * Creates a matrix from an array
  61610. * @param array defines the source array
  61611. * @param offset defines an offset in the source array
  61612. * @returns a new Matrix set from the starting index of the given array
  61613. */
  61614. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Matrix;
  61615. /**
  61616. * Copy the content of an array into a given matrix
  61617. * @param array defines the source array
  61618. * @param offset defines an offset in the source array
  61619. * @param result defines the target matrix
  61620. */
  61621. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Matrix): void;
  61622. /**
  61623. * Stores an array into a matrix after having multiplied each component by a given factor
  61624. * @param array defines the source array
  61625. * @param offset defines the offset in the source array
  61626. * @param scale defines the scaling factor
  61627. * @param result defines the target matrix
  61628. */
  61629. static FromFloat32ArrayToRefScaled(array: DeepImmutable<Float32Array>, offset: number, scale: number, result: Matrix): void;
  61630. /**
  61631. * Gets an identity matrix that must not be updated
  61632. */
  61633. static readonly IdentityReadOnly: DeepImmutable<Matrix>;
  61634. /**
  61635. * Stores a list of values (16) inside a given matrix
  61636. * @param initialM11 defines 1st value of 1st row
  61637. * @param initialM12 defines 2nd value of 1st row
  61638. * @param initialM13 defines 3rd value of 1st row
  61639. * @param initialM14 defines 4th value of 1st row
  61640. * @param initialM21 defines 1st value of 2nd row
  61641. * @param initialM22 defines 2nd value of 2nd row
  61642. * @param initialM23 defines 3rd value of 2nd row
  61643. * @param initialM24 defines 4th value of 2nd row
  61644. * @param initialM31 defines 1st value of 3rd row
  61645. * @param initialM32 defines 2nd value of 3rd row
  61646. * @param initialM33 defines 3rd value of 3rd row
  61647. * @param initialM34 defines 4th value of 3rd row
  61648. * @param initialM41 defines 1st value of 4th row
  61649. * @param initialM42 defines 2nd value of 4th row
  61650. * @param initialM43 defines 3rd value of 4th row
  61651. * @param initialM44 defines 4th value of 4th row
  61652. * @param result defines the target matrix
  61653. */
  61654. 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;
  61655. /**
  61656. * Creates new matrix from a list of values (16)
  61657. * @param initialM11 defines 1st value of 1st row
  61658. * @param initialM12 defines 2nd value of 1st row
  61659. * @param initialM13 defines 3rd value of 1st row
  61660. * @param initialM14 defines 4th value of 1st row
  61661. * @param initialM21 defines 1st value of 2nd row
  61662. * @param initialM22 defines 2nd value of 2nd row
  61663. * @param initialM23 defines 3rd value of 2nd row
  61664. * @param initialM24 defines 4th value of 2nd row
  61665. * @param initialM31 defines 1st value of 3rd row
  61666. * @param initialM32 defines 2nd value of 3rd row
  61667. * @param initialM33 defines 3rd value of 3rd row
  61668. * @param initialM34 defines 4th value of 3rd row
  61669. * @param initialM41 defines 1st value of 4th row
  61670. * @param initialM42 defines 2nd value of 4th row
  61671. * @param initialM43 defines 3rd value of 4th row
  61672. * @param initialM44 defines 4th value of 4th row
  61673. * @returns the new matrix
  61674. */
  61675. 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;
  61676. /**
  61677. * Creates a new matrix composed by merging scale (vector3), rotation (quaternion) and translation (vector3)
  61678. * @param scale defines the scale vector3
  61679. * @param rotation defines the rotation quaternion
  61680. * @param translation defines the translation vector3
  61681. * @returns a new matrix
  61682. */
  61683. static Compose(scale: DeepImmutable<Vector3>, rotation: DeepImmutable<Quaternion>, translation: DeepImmutable<Vector3>): Matrix;
  61684. /**
  61685. * Sets a matrix to a value composed by merging scale (vector3), rotation (quaternion) and translation (vector3)
  61686. * @param scale defines the scale vector3
  61687. * @param rotation defines the rotation quaternion
  61688. * @param translation defines the translation vector3
  61689. * @param result defines the target matrix
  61690. */
  61691. static ComposeToRef(scale: DeepImmutable<Vector3>, rotation: DeepImmutable<Quaternion>, translation: DeepImmutable<Vector3>, result: Matrix): void;
  61692. /**
  61693. * Creates a new identity matrix
  61694. * @returns a new identity matrix
  61695. */
  61696. static Identity(): Matrix;
  61697. /**
  61698. * Creates a new identity matrix and stores the result in a given matrix
  61699. * @param result defines the target matrix
  61700. */
  61701. static IdentityToRef(result: Matrix): void;
  61702. /**
  61703. * Creates a new zero matrix
  61704. * @returns a new zero matrix
  61705. */
  61706. static Zero(): Matrix;
  61707. /**
  61708. * Creates a new rotation matrix for "angle" radians around the X axis
  61709. * @param angle defines the angle (in radians) to use
  61710. * @return the new matrix
  61711. */
  61712. static RotationX(angle: number): Matrix;
  61713. /**
  61714. * Creates a new matrix as the invert of a given matrix
  61715. * @param source defines the source matrix
  61716. * @returns the new matrix
  61717. */
  61718. static Invert(source: DeepImmutable<Matrix>): Matrix;
  61719. /**
  61720. * Creates a new rotation matrix for "angle" radians around the X axis and stores it in a given matrix
  61721. * @param angle defines the angle (in radians) to use
  61722. * @param result defines the target matrix
  61723. */
  61724. static RotationXToRef(angle: number, result: Matrix): void;
  61725. /**
  61726. * Creates a new rotation matrix for "angle" radians around the Y axis
  61727. * @param angle defines the angle (in radians) to use
  61728. * @return the new matrix
  61729. */
  61730. static RotationY(angle: number): Matrix;
  61731. /**
  61732. * Creates a new rotation matrix for "angle" radians around the Y axis and stores it in a given matrix
  61733. * @param angle defines the angle (in radians) to use
  61734. * @param result defines the target matrix
  61735. */
  61736. static RotationYToRef(angle: number, result: Matrix): void;
  61737. /**
  61738. * Creates a new rotation matrix for "angle" radians around the Z axis
  61739. * @param angle defines the angle (in radians) to use
  61740. * @return the new matrix
  61741. */
  61742. static RotationZ(angle: number): Matrix;
  61743. /**
  61744. * Creates a new rotation matrix for "angle" radians around the Z axis and stores it in a given matrix
  61745. * @param angle defines the angle (in radians) to use
  61746. * @param result defines the target matrix
  61747. */
  61748. static RotationZToRef(angle: number, result: Matrix): void;
  61749. /**
  61750. * Creates a new rotation matrix for "angle" radians around the given axis
  61751. * @param axis defines the axis to use
  61752. * @param angle defines the angle (in radians) to use
  61753. * @return the new matrix
  61754. */
  61755. static RotationAxis(axis: DeepImmutable<Vector3>, angle: number): Matrix;
  61756. /**
  61757. * Creates a new rotation matrix for "angle" radians around the given axis and stores it in a given matrix
  61758. * @param axis defines the axis to use
  61759. * @param angle defines the angle (in radians) to use
  61760. * @param result defines the target matrix
  61761. */
  61762. static RotationAxisToRef(axis: DeepImmutable<Vector3>, angle: number, result: Matrix): void;
  61763. /**
  61764. * Creates a rotation matrix
  61765. * @param yaw defines the yaw angle in radians (Y axis)
  61766. * @param pitch defines the pitch angle in radians (X axis)
  61767. * @param roll defines the roll angle in radians (X axis)
  61768. * @returns the new rotation matrix
  61769. */
  61770. static RotationYawPitchRoll(yaw: number, pitch: number, roll: number): Matrix;
  61771. /**
  61772. * Creates a rotation matrix and stores it in a given matrix
  61773. * @param yaw defines the yaw angle in radians (Y axis)
  61774. * @param pitch defines the pitch angle in radians (X axis)
  61775. * @param roll defines the roll angle in radians (X axis)
  61776. * @param result defines the target matrix
  61777. */
  61778. static RotationYawPitchRollToRef(yaw: number, pitch: number, roll: number, result: Matrix): void;
  61779. /**
  61780. * Creates a scaling matrix
  61781. * @param x defines the scale factor on X axis
  61782. * @param y defines the scale factor on Y axis
  61783. * @param z defines the scale factor on Z axis
  61784. * @returns the new matrix
  61785. */
  61786. static Scaling(x: number, y: number, z: number): Matrix;
  61787. /**
  61788. * Creates a scaling matrix and stores it in a given matrix
  61789. * @param x defines the scale factor on X axis
  61790. * @param y defines the scale factor on Y axis
  61791. * @param z defines the scale factor on Z axis
  61792. * @param result defines the target matrix
  61793. */
  61794. static ScalingToRef(x: number, y: number, z: number, result: Matrix): void;
  61795. /**
  61796. * Creates a translation matrix
  61797. * @param x defines the translation on X axis
  61798. * @param y defines the translation on Y axis
  61799. * @param z defines the translationon Z axis
  61800. * @returns the new matrix
  61801. */
  61802. static Translation(x: number, y: number, z: number): Matrix;
  61803. /**
  61804. * Creates a translation matrix and stores it in a given matrix
  61805. * @param x defines the translation on X axis
  61806. * @param y defines the translation on Y axis
  61807. * @param z defines the translationon Z axis
  61808. * @param result defines the target matrix
  61809. */
  61810. static TranslationToRef(x: number, y: number, z: number, result: Matrix): void;
  61811. /**
  61812. * Returns a new Matrix whose values are the interpolated values for "gradient" (float) between the ones of the matrices "startValue" and "endValue".
  61813. * @param startValue defines the start value
  61814. * @param endValue defines the end value
  61815. * @param gradient defines the gradient factor
  61816. * @returns the new matrix
  61817. */
  61818. static Lerp(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number): Matrix;
  61819. /**
  61820. * Set the given matrix "result" as the interpolated values for "gradient" (float) between the ones of the matrices "startValue" and "endValue".
  61821. * @param startValue defines the start value
  61822. * @param endValue defines the end value
  61823. * @param gradient defines the gradient factor
  61824. * @param result defines the Matrix object where to store data
  61825. */
  61826. static LerpToRef(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number, result: Matrix): void;
  61827. /**
  61828. * Builds a new matrix whose values are computed by:
  61829. * * decomposing the the "startValue" and "endValue" matrices into their respective scale, rotation and translation matrices
  61830. * * interpolating for "gradient" (float) the values between each of these decomposed matrices between the start and the end
  61831. * * recomposing a new matrix from these 3 interpolated scale, rotation and translation matrices
  61832. * @param startValue defines the first matrix
  61833. * @param endValue defines the second matrix
  61834. * @param gradient defines the gradient between the two matrices
  61835. * @returns the new matrix
  61836. */
  61837. static DecomposeLerp(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number): Matrix;
  61838. /**
  61839. * Update a matrix to values which are computed by:
  61840. * * decomposing the the "startValue" and "endValue" matrices into their respective scale, rotation and translation matrices
  61841. * * interpolating for "gradient" (float) the values between each of these decomposed matrices between the start and the end
  61842. * * recomposing a new matrix from these 3 interpolated scale, rotation and translation matrices
  61843. * @param startValue defines the first matrix
  61844. * @param endValue defines the second matrix
  61845. * @param gradient defines the gradient between the two matrices
  61846. * @param result defines the target matrix
  61847. */
  61848. static DecomposeLerpToRef(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number, result: Matrix): void;
  61849. /**
  61850. * 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"
  61851. * This function works in left handed mode
  61852. * @param eye defines the final position of the entity
  61853. * @param target defines where the entity should look at
  61854. * @param up defines the up vector for the entity
  61855. * @returns the new matrix
  61856. */
  61857. static LookAtLH(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>): Matrix;
  61858. /**
  61859. * 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".
  61860. * This function works in left handed mode
  61861. * @param eye defines the final position of the entity
  61862. * @param target defines where the entity should look at
  61863. * @param up defines the up vector for the entity
  61864. * @param result defines the target matrix
  61865. */
  61866. static LookAtLHToRef(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>, result: Matrix): void;
  61867. /**
  61868. * 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"
  61869. * This function works in right handed mode
  61870. * @param eye defines the final position of the entity
  61871. * @param target defines where the entity should look at
  61872. * @param up defines the up vector for the entity
  61873. * @returns the new matrix
  61874. */
  61875. static LookAtRH(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>): Matrix;
  61876. /**
  61877. * 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".
  61878. * This function works in right handed mode
  61879. * @param eye defines the final position of the entity
  61880. * @param target defines where the entity should look at
  61881. * @param up defines the up vector for the entity
  61882. * @param result defines the target matrix
  61883. */
  61884. static LookAtRHToRef(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>, result: Matrix): void;
  61885. /**
  61886. * Create a left-handed orthographic projection matrix
  61887. * @param width defines the viewport width
  61888. * @param height defines the viewport height
  61889. * @param znear defines the near clip plane
  61890. * @param zfar defines the far clip plane
  61891. * @returns a new matrix as a left-handed orthographic projection matrix
  61892. */
  61893. static OrthoLH(width: number, height: number, znear: number, zfar: number): Matrix;
  61894. /**
  61895. * Store a left-handed orthographic projection to a given matrix
  61896. * @param width defines the viewport width
  61897. * @param height defines the viewport height
  61898. * @param znear defines the near clip plane
  61899. * @param zfar defines the far clip plane
  61900. * @param result defines the target matrix
  61901. */
  61902. static OrthoLHToRef(width: number, height: number, znear: number, zfar: number, result: Matrix): void;
  61903. /**
  61904. * Create a left-handed orthographic projection matrix
  61905. * @param left defines the viewport left coordinate
  61906. * @param right defines the viewport right coordinate
  61907. * @param bottom defines the viewport bottom coordinate
  61908. * @param top defines the viewport top coordinate
  61909. * @param znear defines the near clip plane
  61910. * @param zfar defines the far clip plane
  61911. * @returns a new matrix as a left-handed orthographic projection matrix
  61912. */
  61913. static OrthoOffCenterLH(left: number, right: number, bottom: number, top: number, znear: number, zfar: number): Matrix;
  61914. /**
  61915. * Stores a left-handed orthographic projection into a given matrix
  61916. * @param left defines the viewport left coordinate
  61917. * @param right defines the viewport right coordinate
  61918. * @param bottom defines the viewport bottom coordinate
  61919. * @param top defines the viewport top coordinate
  61920. * @param znear defines the near clip plane
  61921. * @param zfar defines the far clip plane
  61922. * @param result defines the target matrix
  61923. */
  61924. static OrthoOffCenterLHToRef(left: number, right: number, bottom: number, top: number, znear: number, zfar: number, result: Matrix): void;
  61925. /**
  61926. * Creates a right-handed orthographic projection matrix
  61927. * @param left defines the viewport left coordinate
  61928. * @param right defines the viewport right coordinate
  61929. * @param bottom defines the viewport bottom coordinate
  61930. * @param top defines the viewport top coordinate
  61931. * @param znear defines the near clip plane
  61932. * @param zfar defines the far clip plane
  61933. * @returns a new matrix as a right-handed orthographic projection matrix
  61934. */
  61935. static OrthoOffCenterRH(left: number, right: number, bottom: number, top: number, znear: number, zfar: number): Matrix;
  61936. /**
  61937. * Stores a right-handed orthographic projection into a given matrix
  61938. * @param left defines the viewport left coordinate
  61939. * @param right defines the viewport right coordinate
  61940. * @param bottom defines the viewport bottom coordinate
  61941. * @param top defines the viewport top coordinate
  61942. * @param znear defines the near clip plane
  61943. * @param zfar defines the far clip plane
  61944. * @param result defines the target matrix
  61945. */
  61946. static OrthoOffCenterRHToRef(left: number, right: number, bottom: number, top: number, znear: number, zfar: number, result: Matrix): void;
  61947. /**
  61948. * Creates a left-handed perspective projection matrix
  61949. * @param width defines the viewport width
  61950. * @param height defines the viewport height
  61951. * @param znear defines the near clip plane
  61952. * @param zfar defines the far clip plane
  61953. * @returns a new matrix as a left-handed perspective projection matrix
  61954. */
  61955. static PerspectiveLH(width: number, height: number, znear: number, zfar: number): Matrix;
  61956. /**
  61957. * Creates a left-handed perspective projection matrix
  61958. * @param fov defines the horizontal field of view
  61959. * @param aspect defines the aspect ratio
  61960. * @param znear defines the near clip plane
  61961. * @param zfar defines the far clip plane
  61962. * @returns a new matrix as a left-handed perspective projection matrix
  61963. */
  61964. static PerspectiveFovLH(fov: number, aspect: number, znear: number, zfar: number): Matrix;
  61965. /**
  61966. * Stores a left-handed perspective projection into a given matrix
  61967. * @param fov defines the horizontal field of view
  61968. * @param aspect defines the aspect ratio
  61969. * @param znear defines the near clip plane
  61970. * @param zfar defines the far clip plane
  61971. * @param result defines the target matrix
  61972. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  61973. */
  61974. static PerspectiveFovLHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  61975. /**
  61976. * Creates a right-handed perspective projection matrix
  61977. * @param fov defines the horizontal field of view
  61978. * @param aspect defines the aspect ratio
  61979. * @param znear defines the near clip plane
  61980. * @param zfar defines the far clip plane
  61981. * @returns a new matrix as a right-handed perspective projection matrix
  61982. */
  61983. static PerspectiveFovRH(fov: number, aspect: number, znear: number, zfar: number): Matrix;
  61984. /**
  61985. * Stores a right-handed perspective projection into a given matrix
  61986. * @param fov defines the horizontal field of view
  61987. * @param aspect defines the aspect ratio
  61988. * @param znear defines the near clip plane
  61989. * @param zfar defines the far clip plane
  61990. * @param result defines the target matrix
  61991. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  61992. */
  61993. static PerspectiveFovRHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  61994. /**
  61995. * Stores a perspective projection for WebVR info a given matrix
  61996. * @param fov defines the field of view
  61997. * @param znear defines the near clip plane
  61998. * @param zfar defines the far clip plane
  61999. * @param result defines the target matrix
  62000. * @param rightHanded defines if the matrix must be in right-handed mode (false by default)
  62001. */
  62002. static PerspectiveFovWebVRToRef(fov: {
  62003. upDegrees: number;
  62004. downDegrees: number;
  62005. leftDegrees: number;
  62006. rightDegrees: number;
  62007. }, znear: number, zfar: number, result: Matrix, rightHanded?: boolean): void;
  62008. /**
  62009. * Computes a complete transformation matrix
  62010. * @param viewport defines the viewport to use
  62011. * @param world defines the world matrix
  62012. * @param view defines the view matrix
  62013. * @param projection defines the projection matrix
  62014. * @param zmin defines the near clip plane
  62015. * @param zmax defines the far clip plane
  62016. * @returns the transformation matrix
  62017. */
  62018. static GetFinalMatrix(viewport: DeepImmutable<Viewport>, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, zmin: number, zmax: number): Matrix;
  62019. /**
  62020. * Extracts a 2x2 matrix from a given matrix and store the result in a Float32Array
  62021. * @param matrix defines the matrix to use
  62022. * @returns a new Float32Array array with 4 elements : the 2x2 matrix extracted from the given matrix
  62023. */
  62024. static GetAsMatrix2x2(matrix: DeepImmutable<Matrix>): Float32Array;
  62025. /**
  62026. * Extracts a 3x3 matrix from a given matrix and store the result in a Float32Array
  62027. * @param matrix defines the matrix to use
  62028. * @returns a new Float32Array array with 9 elements : the 3x3 matrix extracted from the given matrix
  62029. */
  62030. static GetAsMatrix3x3(matrix: DeepImmutable<Matrix>): Float32Array;
  62031. /**
  62032. * Compute the transpose of a given matrix
  62033. * @param matrix defines the matrix to transpose
  62034. * @returns the new matrix
  62035. */
  62036. static Transpose(matrix: DeepImmutable<Matrix>): Matrix;
  62037. /**
  62038. * Compute the transpose of a matrix and store it in a target matrix
  62039. * @param matrix defines the matrix to transpose
  62040. * @param result defines the target matrix
  62041. */
  62042. static TransposeToRef(matrix: DeepImmutable<Matrix>, result: Matrix): void;
  62043. /**
  62044. * Computes a reflection matrix from a plane
  62045. * @param plane defines the reflection plane
  62046. * @returns a new matrix
  62047. */
  62048. static Reflection(plane: DeepImmutable<Plane>): Matrix;
  62049. /**
  62050. * Computes a reflection matrix from a plane
  62051. * @param plane defines the reflection plane
  62052. * @param result defines the target matrix
  62053. */
  62054. static ReflectionToRef(plane: DeepImmutable<Plane>, result: Matrix): void;
  62055. /**
  62056. * Sets the given matrix as a rotation matrix composed from the 3 left handed axes
  62057. * @param xaxis defines the value of the 1st axis
  62058. * @param yaxis defines the value of the 2nd axis
  62059. * @param zaxis defines the value of the 3rd axis
  62060. * @param result defines the target matrix
  62061. */
  62062. static FromXYZAxesToRef(xaxis: DeepImmutable<Vector3>, yaxis: DeepImmutable<Vector3>, zaxis: DeepImmutable<Vector3>, result: Matrix): void;
  62063. /**
  62064. * Creates a rotation matrix from a quaternion and stores it in a target matrix
  62065. * @param quat defines the quaternion to use
  62066. * @param result defines the target matrix
  62067. */
  62068. static FromQuaternionToRef(quat: DeepImmutable<Quaternion>, result: Matrix): void;
  62069. }
  62070. /**
  62071. * Represens a plane by the equation ax + by + cz + d = 0
  62072. */
  62073. export class Plane {
  62074. /**
  62075. * Normal of the plane (a,b,c)
  62076. */
  62077. normal: Vector3;
  62078. /**
  62079. * d component of the plane
  62080. */
  62081. d: number;
  62082. /**
  62083. * Creates a Plane object according to the given floats a, b, c, d and the plane equation : ax + by + cz + d = 0
  62084. * @param a a component of the plane
  62085. * @param b b component of the plane
  62086. * @param c c component of the plane
  62087. * @param d d component of the plane
  62088. */
  62089. constructor(a: number, b: number, c: number, d: number);
  62090. /**
  62091. * @returns the plane coordinates as a new array of 4 elements [a, b, c, d].
  62092. */
  62093. asArray(): number[];
  62094. /**
  62095. * @returns a new plane copied from the current Plane.
  62096. */
  62097. clone(): Plane;
  62098. /**
  62099. * @returns the string "Plane".
  62100. */
  62101. getClassName(): string;
  62102. /**
  62103. * @returns the Plane hash code.
  62104. */
  62105. getHashCode(): number;
  62106. /**
  62107. * Normalize the current Plane in place.
  62108. * @returns the updated Plane.
  62109. */
  62110. normalize(): Plane;
  62111. /**
  62112. * Applies a transformation the plane and returns the result
  62113. * @param transformation the transformation matrix to be applied to the plane
  62114. * @returns a new Plane as the result of the transformation of the current Plane by the given matrix.
  62115. */
  62116. transform(transformation: DeepImmutable<Matrix>): Plane;
  62117. /**
  62118. * Calcualtte the dot product between the point and the plane normal
  62119. * @param point point to calculate the dot product with
  62120. * @returns the dot product (float) of the point coordinates and the plane normal.
  62121. */
  62122. dotCoordinate(point: DeepImmutable<Vector3>): number;
  62123. /**
  62124. * Updates the current Plane from the plane defined by the three given points.
  62125. * @param point1 one of the points used to contruct the plane
  62126. * @param point2 one of the points used to contruct the plane
  62127. * @param point3 one of the points used to contruct the plane
  62128. * @returns the updated Plane.
  62129. */
  62130. copyFromPoints(point1: DeepImmutable<Vector3>, point2: DeepImmutable<Vector3>, point3: DeepImmutable<Vector3>): Plane;
  62131. /**
  62132. * Checks if the plane is facing a given direction
  62133. * @param direction the direction to check if the plane is facing
  62134. * @param epsilon value the dot product is compared against (returns true if dot <= epsilon)
  62135. * @returns True is the vector "direction" is the same side than the plane normal.
  62136. */
  62137. isFrontFacingTo(direction: DeepImmutable<Vector3>, epsilon: number): boolean;
  62138. /**
  62139. * Calculates the distance to a point
  62140. * @param point point to calculate distance to
  62141. * @returns the signed distance (float) from the given point to the Plane.
  62142. */
  62143. signedDistanceTo(point: DeepImmutable<Vector3>): number;
  62144. /**
  62145. * Creates a plane from an array
  62146. * @param array the array to create a plane from
  62147. * @returns a new Plane from the given array.
  62148. */
  62149. static FromArray(array: DeepImmutable<ArrayLike<number>>): Plane;
  62150. /**
  62151. * Creates a plane from three points
  62152. * @param point1 point used to create the plane
  62153. * @param point2 point used to create the plane
  62154. * @param point3 point used to create the plane
  62155. * @returns a new Plane defined by the three given points.
  62156. */
  62157. static FromPoints(point1: DeepImmutable<Vector3>, point2: DeepImmutable<Vector3>, point3: DeepImmutable<Vector3>): Plane;
  62158. /**
  62159. * Creates a plane from an origin point and a normal
  62160. * @param origin origin of the plane to be constructed
  62161. * @param normal normal of the plane to be constructed
  62162. * @returns a new Plane the normal vector to this plane at the given origin point.
  62163. * Note : the vector "normal" is updated because normalized.
  62164. */
  62165. static FromPositionAndNormal(origin: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>): Plane;
  62166. /**
  62167. * Calculates the distance from a plane and a point
  62168. * @param origin origin of the plane to be constructed
  62169. * @param normal normal of the plane to be constructed
  62170. * @param point point to calculate distance to
  62171. * @returns the signed distance between the plane defined by the normal vector at the "origin"" point and the given other point.
  62172. */
  62173. static SignedDistanceToPlaneFromPositionAndNormal(origin: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>, point: DeepImmutable<Vector3>): number;
  62174. }
  62175. /**
  62176. * Class used to represent a viewport on screen
  62177. */
  62178. export class Viewport {
  62179. /** viewport left coordinate */
  62180. x: number;
  62181. /** viewport top coordinate */
  62182. y: number;
  62183. /**viewport width */
  62184. width: number;
  62185. /** viewport height */
  62186. height: number;
  62187. /**
  62188. * Creates a Viewport object located at (x, y) and sized (width, height)
  62189. * @param x defines viewport left coordinate
  62190. * @param y defines viewport top coordinate
  62191. * @param width defines the viewport width
  62192. * @param height defines the viewport height
  62193. */
  62194. constructor(
  62195. /** viewport left coordinate */
  62196. x: number,
  62197. /** viewport top coordinate */
  62198. y: number,
  62199. /**viewport width */
  62200. width: number,
  62201. /** viewport height */
  62202. height: number);
  62203. /**
  62204. * Creates a new viewport using absolute sizing (from 0-> width, 0-> height instead of 0->1)
  62205. * @param renderWidth defines the rendering width
  62206. * @param renderHeight defines the rendering height
  62207. * @returns a new Viewport
  62208. */
  62209. toGlobal(renderWidth: number, renderHeight: number): Viewport;
  62210. /**
  62211. * Stores absolute viewport value into a target viewport (from 0-> width, 0-> height instead of 0->1)
  62212. * @param renderWidth defines the rendering width
  62213. * @param renderHeight defines the rendering height
  62214. * @param ref defines the target viewport
  62215. * @returns the current viewport
  62216. */
  62217. toGlobalToRef(renderWidth: number, renderHeight: number, ref: Viewport): Viewport;
  62218. /**
  62219. * Returns a new Viewport copied from the current one
  62220. * @returns a new Viewport
  62221. */
  62222. clone(): Viewport;
  62223. }
  62224. /**
  62225. * Reprasents a camera frustum
  62226. */
  62227. export class Frustum {
  62228. /**
  62229. * Gets the planes representing the frustum
  62230. * @param transform matrix to be applied to the returned planes
  62231. * @returns a new array of 6 Frustum planes computed by the given transformation matrix.
  62232. */
  62233. static GetPlanes(transform: DeepImmutable<Matrix>): Plane[];
  62234. /**
  62235. * Gets the near frustum plane transformed by the transform matrix
  62236. * @param transform transformation matrix to be applied to the resulting frustum plane
  62237. * @param frustumPlane the resuling frustum plane
  62238. */
  62239. static GetNearPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  62240. /**
  62241. * Gets the far frustum plane transformed by the transform matrix
  62242. * @param transform transformation matrix to be applied to the resulting frustum plane
  62243. * @param frustumPlane the resuling frustum plane
  62244. */
  62245. static GetFarPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  62246. /**
  62247. * Gets the left frustum plane transformed by the transform matrix
  62248. * @param transform transformation matrix to be applied to the resulting frustum plane
  62249. * @param frustumPlane the resuling frustum plane
  62250. */
  62251. static GetLeftPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  62252. /**
  62253. * Gets the right frustum plane transformed by the transform matrix
  62254. * @param transform transformation matrix to be applied to the resulting frustum plane
  62255. * @param frustumPlane the resuling frustum plane
  62256. */
  62257. static GetRightPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  62258. /**
  62259. * Gets the top frustum plane transformed by the transform matrix
  62260. * @param transform transformation matrix to be applied to the resulting frustum plane
  62261. * @param frustumPlane the resuling frustum plane
  62262. */
  62263. static GetTopPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  62264. /**
  62265. * Gets the bottom frustum plane transformed by the transform matrix
  62266. * @param transform transformation matrix to be applied to the resulting frustum plane
  62267. * @param frustumPlane the resuling frustum plane
  62268. */
  62269. static GetBottomPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  62270. /**
  62271. * Sets the given array "frustumPlanes" with the 6 Frustum planes computed by the given transformation matrix.
  62272. * @param transform transformation matrix to be applied to the resulting frustum planes
  62273. * @param frustumPlanes the resuling frustum planes
  62274. */
  62275. static GetPlanesToRef(transform: DeepImmutable<Matrix>, frustumPlanes: Plane[]): void;
  62276. }
  62277. /** Defines supported spaces */
  62278. export enum Space {
  62279. /** Local (object) space */
  62280. LOCAL = 0,
  62281. /** World space */
  62282. WORLD = 1,
  62283. /** Bone space */
  62284. BONE = 2
  62285. }
  62286. /** Defines the 3 main axes */
  62287. export class Axis {
  62288. /** X axis */
  62289. static X: Vector3;
  62290. /** Y axis */
  62291. static Y: Vector3;
  62292. /** Z axis */
  62293. static Z: Vector3;
  62294. }
  62295. /** Class used to represent a Bezier curve */
  62296. export class BezierCurve {
  62297. /**
  62298. * Returns the cubic Bezier interpolated value (float) at "t" (float) from the given x1, y1, x2, y2 floats
  62299. * @param t defines the time
  62300. * @param x1 defines the left coordinate on X axis
  62301. * @param y1 defines the left coordinate on Y axis
  62302. * @param x2 defines the right coordinate on X axis
  62303. * @param y2 defines the right coordinate on Y axis
  62304. * @returns the interpolated value
  62305. */
  62306. static Interpolate(t: number, x1: number, y1: number, x2: number, y2: number): number;
  62307. }
  62308. /**
  62309. * Defines potential orientation for back face culling
  62310. */
  62311. export enum Orientation {
  62312. /**
  62313. * Clockwise
  62314. */
  62315. CW = 0,
  62316. /** Counter clockwise */
  62317. CCW = 1
  62318. }
  62319. /**
  62320. * Defines angle representation
  62321. */
  62322. export class Angle {
  62323. private _radians;
  62324. /**
  62325. * Creates an Angle object of "radians" radians (float).
  62326. * @param radians the angle in radians
  62327. */
  62328. constructor(radians: number);
  62329. /**
  62330. * Get value in degrees
  62331. * @returns the Angle value in degrees (float)
  62332. */
  62333. degrees(): number;
  62334. /**
  62335. * Get value in radians
  62336. * @returns the Angle value in radians (float)
  62337. */
  62338. radians(): number;
  62339. /**
  62340. * Gets a new Angle object valued with the angle value in radians between the two given vectors
  62341. * @param a defines first vector
  62342. * @param b defines second vector
  62343. * @returns a new Angle
  62344. */
  62345. static BetweenTwoPoints(a: DeepImmutable<Vector2>, b: DeepImmutable<Vector2>): Angle;
  62346. /**
  62347. * Gets a new Angle object from the given float in radians
  62348. * @param radians defines the angle value in radians
  62349. * @returns a new Angle
  62350. */
  62351. static FromRadians(radians: number): Angle;
  62352. /**
  62353. * Gets a new Angle object from the given float in degrees
  62354. * @param degrees defines the angle value in degrees
  62355. * @returns a new Angle
  62356. */
  62357. static FromDegrees(degrees: number): Angle;
  62358. }
  62359. /**
  62360. * This represents an arc in a 2d space.
  62361. */
  62362. export class Arc2 {
  62363. /** Defines the start point of the arc */
  62364. startPoint: Vector2;
  62365. /** Defines the mid point of the arc */
  62366. midPoint: Vector2;
  62367. /** Defines the end point of the arc */
  62368. endPoint: Vector2;
  62369. /**
  62370. * Defines the center point of the arc.
  62371. */
  62372. centerPoint: Vector2;
  62373. /**
  62374. * Defines the radius of the arc.
  62375. */
  62376. radius: number;
  62377. /**
  62378. * Defines the angle of the arc (from mid point to end point).
  62379. */
  62380. angle: Angle;
  62381. /**
  62382. * Defines the start angle of the arc (from start point to middle point).
  62383. */
  62384. startAngle: Angle;
  62385. /**
  62386. * Defines the orientation of the arc (clock wise/counter clock wise).
  62387. */
  62388. orientation: Orientation;
  62389. /**
  62390. * Creates an Arc object from the three given points : start, middle and end.
  62391. * @param startPoint Defines the start point of the arc
  62392. * @param midPoint Defines the midlle point of the arc
  62393. * @param endPoint Defines the end point of the arc
  62394. */
  62395. constructor(
  62396. /** Defines the start point of the arc */
  62397. startPoint: Vector2,
  62398. /** Defines the mid point of the arc */
  62399. midPoint: Vector2,
  62400. /** Defines the end point of the arc */
  62401. endPoint: Vector2);
  62402. }
  62403. /**
  62404. * Represents a 2D path made up of multiple 2D points
  62405. */
  62406. export class Path2 {
  62407. private _points;
  62408. private _length;
  62409. /**
  62410. * If the path start and end point are the same
  62411. */
  62412. closed: boolean;
  62413. /**
  62414. * Creates a Path2 object from the starting 2D coordinates x and y.
  62415. * @param x the starting points x value
  62416. * @param y the starting points y value
  62417. */
  62418. constructor(x: number, y: number);
  62419. /**
  62420. * Adds a new segment until the given coordinates (x, y) to the current Path2.
  62421. * @param x the added points x value
  62422. * @param y the added points y value
  62423. * @returns the updated Path2.
  62424. */
  62425. addLineTo(x: number, y: number): Path2;
  62426. /**
  62427. * 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.
  62428. * @param midX middle point x value
  62429. * @param midY middle point y value
  62430. * @param endX end point x value
  62431. * @param endY end point y value
  62432. * @param numberOfSegments (default: 36)
  62433. * @returns the updated Path2.
  62434. */
  62435. addArcTo(midX: number, midY: number, endX: number, endY: number, numberOfSegments?: number): Path2;
  62436. /**
  62437. * Closes the Path2.
  62438. * @returns the Path2.
  62439. */
  62440. close(): Path2;
  62441. /**
  62442. * Gets the sum of the distance between each sequential point in the path
  62443. * @returns the Path2 total length (float).
  62444. */
  62445. length(): number;
  62446. /**
  62447. * Gets the points which construct the path
  62448. * @returns the Path2 internal array of points.
  62449. */
  62450. getPoints(): Vector2[];
  62451. /**
  62452. * Retreives the point at the distance aways from the starting point
  62453. * @param normalizedLengthPosition the length along the path to retreive the point from
  62454. * @returns a new Vector2 located at a percentage of the Path2 total length on this path.
  62455. */
  62456. getPointAtLengthPosition(normalizedLengthPosition: number): Vector2;
  62457. /**
  62458. * Creates a new path starting from an x and y position
  62459. * @param x starting x value
  62460. * @param y starting y value
  62461. * @returns a new Path2 starting at the coordinates (x, y).
  62462. */
  62463. static StartingAt(x: number, y: number): Path2;
  62464. }
  62465. /**
  62466. * Represents a 3D path made up of multiple 3D points
  62467. */
  62468. export class Path3D {
  62469. /**
  62470. * an array of Vector3, the curve axis of the Path3D
  62471. */
  62472. path: Vector3[];
  62473. private _curve;
  62474. private _distances;
  62475. private _tangents;
  62476. private _normals;
  62477. private _binormals;
  62478. private _raw;
  62479. /**
  62480. * new Path3D(path, normal, raw)
  62481. * Creates a Path3D. A Path3D is a logical math object, so not a mesh.
  62482. * please read the description in the tutorial : https://doc.babylonjs.com/how_to/how_to_use_path3d
  62483. * @param path an array of Vector3, the curve axis of the Path3D
  62484. * @param firstNormal (options) Vector3, the first wanted normal to the curve. Ex (0, 1, 0) for a vertical normal.
  62485. * @param raw (optional, default false) : boolean, if true the returned Path3D isn't normalized. Useful to depict path acceleration or speed.
  62486. */
  62487. constructor(
  62488. /**
  62489. * an array of Vector3, the curve axis of the Path3D
  62490. */
  62491. path: Vector3[], firstNormal?: Nullable<Vector3>, raw?: boolean);
  62492. /**
  62493. * Returns the Path3D array of successive Vector3 designing its curve.
  62494. * @returns the Path3D array of successive Vector3 designing its curve.
  62495. */
  62496. getCurve(): Vector3[];
  62497. /**
  62498. * Returns an array populated with tangent vectors on each Path3D curve point.
  62499. * @returns an array populated with tangent vectors on each Path3D curve point.
  62500. */
  62501. getTangents(): Vector3[];
  62502. /**
  62503. * Returns an array populated with normal vectors on each Path3D curve point.
  62504. * @returns an array populated with normal vectors on each Path3D curve point.
  62505. */
  62506. getNormals(): Vector3[];
  62507. /**
  62508. * Returns an array populated with binormal vectors on each Path3D curve point.
  62509. * @returns an array populated with binormal vectors on each Path3D curve point.
  62510. */
  62511. getBinormals(): Vector3[];
  62512. /**
  62513. * Returns an array populated with distances (float) of the i-th point from the first curve point.
  62514. * @returns an array populated with distances (float) of the i-th point from the first curve point.
  62515. */
  62516. getDistances(): number[];
  62517. /**
  62518. * Forces the Path3D tangent, normal, binormal and distance recomputation.
  62519. * @param path path which all values are copied into the curves points
  62520. * @param firstNormal which should be projected onto the curve
  62521. * @returns the same object updated.
  62522. */
  62523. update(path: Vector3[], firstNormal?: Nullable<Vector3>): Path3D;
  62524. private _compute;
  62525. private _getFirstNonNullVector;
  62526. private _getLastNonNullVector;
  62527. private _normalVector;
  62528. }
  62529. /**
  62530. * A Curve3 object is a logical object, so not a mesh, to handle curves in the 3D geometric space.
  62531. * A Curve3 is designed from a series of successive Vector3.
  62532. * @see https://doc.babylonjs.com/how_to/how_to_use_curve3
  62533. */
  62534. export class Curve3 {
  62535. private _points;
  62536. private _length;
  62537. /**
  62538. * Returns a Curve3 object along a Quadratic Bezier curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#quadratic-bezier-curve
  62539. * @param v0 (Vector3) the origin point of the Quadratic Bezier
  62540. * @param v1 (Vector3) the control point
  62541. * @param v2 (Vector3) the end point of the Quadratic Bezier
  62542. * @param nbPoints (integer) the wanted number of points in the curve
  62543. * @returns the created Curve3
  62544. */
  62545. static CreateQuadraticBezier(v0: DeepImmutable<Vector3>, v1: DeepImmutable<Vector3>, v2: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  62546. /**
  62547. * Returns a Curve3 object along a Cubic Bezier curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#cubic-bezier-curve
  62548. * @param v0 (Vector3) the origin point of the Cubic Bezier
  62549. * @param v1 (Vector3) the first control point
  62550. * @param v2 (Vector3) the second control point
  62551. * @param v3 (Vector3) the end point of the Cubic Bezier
  62552. * @param nbPoints (integer) the wanted number of points in the curve
  62553. * @returns the created Curve3
  62554. */
  62555. static CreateCubicBezier(v0: DeepImmutable<Vector3>, v1: DeepImmutable<Vector3>, v2: DeepImmutable<Vector3>, v3: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  62556. /**
  62557. * Returns a Curve3 object along a Hermite Spline curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#hermite-spline
  62558. * @param p1 (Vector3) the origin point of the Hermite Spline
  62559. * @param t1 (Vector3) the tangent vector at the origin point
  62560. * @param p2 (Vector3) the end point of the Hermite Spline
  62561. * @param t2 (Vector3) the tangent vector at the end point
  62562. * @param nbPoints (integer) the wanted number of points in the curve
  62563. * @returns the created Curve3
  62564. */
  62565. static CreateHermiteSpline(p1: DeepImmutable<Vector3>, t1: DeepImmutable<Vector3>, p2: DeepImmutable<Vector3>, t2: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  62566. /**
  62567. * Returns a Curve3 object along a CatmullRom Spline curve :
  62568. * @param points (array of Vector3) the points the spline must pass through. At least, four points required
  62569. * @param nbPoints (integer) the wanted number of points between each curve control points
  62570. * @param closed (boolean) optional with default false, when true forms a closed loop from the points
  62571. * @returns the created Curve3
  62572. */
  62573. static CreateCatmullRomSpline(points: DeepImmutable<Vector3[]>, nbPoints: number, closed?: boolean): Curve3;
  62574. /**
  62575. * A Curve3 object is a logical object, so not a mesh, to handle curves in the 3D geometric space.
  62576. * A Curve3 is designed from a series of successive Vector3.
  62577. * Tuto : https://doc.babylonjs.com/how_to/how_to_use_curve3#curve3-object
  62578. * @param points points which make up the curve
  62579. */
  62580. constructor(points: Vector3[]);
  62581. /**
  62582. * @returns the Curve3 stored array of successive Vector3
  62583. */
  62584. getPoints(): Vector3[];
  62585. /**
  62586. * @returns the computed length (float) of the curve.
  62587. */
  62588. length(): number;
  62589. /**
  62590. * Returns a new instance of Curve3 object : var curve = curveA.continue(curveB);
  62591. * This new Curve3 is built by translating and sticking the curveB at the end of the curveA.
  62592. * curveA and curveB keep unchanged.
  62593. * @param curve the curve to continue from this curve
  62594. * @returns the newly constructed curve
  62595. */
  62596. continue(curve: DeepImmutable<Curve3>): Curve3;
  62597. private _computeLength;
  62598. }
  62599. /**
  62600. * Contains position and normal vectors for a vertex
  62601. */
  62602. export class PositionNormalVertex {
  62603. /** the position of the vertex (defaut: 0,0,0) */
  62604. position: Vector3;
  62605. /** the normal of the vertex (defaut: 0,1,0) */
  62606. normal: Vector3;
  62607. /**
  62608. * Creates a PositionNormalVertex
  62609. * @param position the position of the vertex (defaut: 0,0,0)
  62610. * @param normal the normal of the vertex (defaut: 0,1,0)
  62611. */
  62612. constructor(
  62613. /** the position of the vertex (defaut: 0,0,0) */
  62614. position?: Vector3,
  62615. /** the normal of the vertex (defaut: 0,1,0) */
  62616. normal?: Vector3);
  62617. /**
  62618. * Clones the PositionNormalVertex
  62619. * @returns the cloned PositionNormalVertex
  62620. */
  62621. clone(): PositionNormalVertex;
  62622. }
  62623. /**
  62624. * Contains position, normal and uv vectors for a vertex
  62625. */
  62626. export class PositionNormalTextureVertex {
  62627. /** the position of the vertex (defaut: 0,0,0) */
  62628. position: Vector3;
  62629. /** the normal of the vertex (defaut: 0,1,0) */
  62630. normal: Vector3;
  62631. /** the uv of the vertex (default: 0,0) */
  62632. uv: Vector2;
  62633. /**
  62634. * Creates a PositionNormalTextureVertex
  62635. * @param position the position of the vertex (defaut: 0,0,0)
  62636. * @param normal the normal of the vertex (defaut: 0,1,0)
  62637. * @param uv the uv of the vertex (default: 0,0)
  62638. */
  62639. constructor(
  62640. /** the position of the vertex (defaut: 0,0,0) */
  62641. position?: Vector3,
  62642. /** the normal of the vertex (defaut: 0,1,0) */
  62643. normal?: Vector3,
  62644. /** the uv of the vertex (default: 0,0) */
  62645. uv?: Vector2);
  62646. /**
  62647. * Clones the PositionNormalTextureVertex
  62648. * @returns the cloned PositionNormalTextureVertex
  62649. */
  62650. clone(): PositionNormalTextureVertex;
  62651. }
  62652. /**
  62653. * @hidden
  62654. */
  62655. export class Tmp {
  62656. static Color3: Color3[];
  62657. static Color4: Color4[];
  62658. static Vector2: Vector2[];
  62659. static Vector3: Vector3[];
  62660. static Vector4: Vector4[];
  62661. static Quaternion: Quaternion[];
  62662. static Matrix: Matrix[];
  62663. }
  62664. }
  62665. declare module BABYLON {
  62666. /**
  62667. * Class used to enable access to offline support
  62668. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  62669. */
  62670. export interface IOfflineProvider {
  62671. /**
  62672. * Gets a boolean indicating if scene must be saved in the database
  62673. */
  62674. enableSceneOffline: boolean;
  62675. /**
  62676. * Gets a boolean indicating if textures must be saved in the database
  62677. */
  62678. enableTexturesOffline: boolean;
  62679. /**
  62680. * Open the offline support and make it available
  62681. * @param successCallback defines the callback to call on success
  62682. * @param errorCallback defines the callback to call on error
  62683. */
  62684. open(successCallback: () => void, errorCallback: () => void): void;
  62685. /**
  62686. * Loads an image from the offline support
  62687. * @param url defines the url to load from
  62688. * @param image defines the target DOM image
  62689. */
  62690. loadImage(url: string, image: HTMLImageElement): void;
  62691. /**
  62692. * Loads a file from offline support
  62693. * @param url defines the URL to load from
  62694. * @param sceneLoaded defines a callback to call on success
  62695. * @param progressCallBack defines a callback to call when progress changed
  62696. * @param errorCallback defines a callback to call on error
  62697. * @param useArrayBuffer defines a boolean to use array buffer instead of text string
  62698. */
  62699. loadFile(url: string, sceneLoaded: (data: any) => void, progressCallBack?: (data: any) => void, errorCallback?: () => void, useArrayBuffer?: boolean): void;
  62700. }
  62701. }
  62702. declare module BABYLON {
  62703. /**
  62704. * A class serves as a medium between the observable and its observers
  62705. */
  62706. export class EventState {
  62707. /**
  62708. * Create a new EventState
  62709. * @param mask defines the mask associated with this state
  62710. * @param skipNextObservers defines a flag which will instruct the observable to skip following observers when set to true
  62711. * @param target defines the original target of the state
  62712. * @param currentTarget defines the current target of the state
  62713. */
  62714. constructor(mask: number, skipNextObservers?: boolean, target?: any, currentTarget?: any);
  62715. /**
  62716. * Initialize the current event state
  62717. * @param mask defines the mask associated with this state
  62718. * @param skipNextObservers defines a flag which will instruct the observable to skip following observers when set to true
  62719. * @param target defines the original target of the state
  62720. * @param currentTarget defines the current target of the state
  62721. * @returns the current event state
  62722. */
  62723. initalize(mask: number, skipNextObservers?: boolean, target?: any, currentTarget?: any): EventState;
  62724. /**
  62725. * An Observer can set this property to true to prevent subsequent observers of being notified
  62726. */
  62727. skipNextObservers: boolean;
  62728. /**
  62729. * Get the mask value that were used to trigger the event corresponding to this EventState object
  62730. */
  62731. mask: number;
  62732. /**
  62733. * The object that originally notified the event
  62734. */
  62735. target?: any;
  62736. /**
  62737. * The current object in the bubbling phase
  62738. */
  62739. currentTarget?: any;
  62740. /**
  62741. * This will be populated with the return value of the last function that was executed.
  62742. * If it is the first function in the callback chain it will be the event data.
  62743. */
  62744. lastReturnValue?: any;
  62745. }
  62746. /**
  62747. * Represent an Observer registered to a given Observable object.
  62748. */
  62749. export class Observer<T> {
  62750. /**
  62751. * Defines the callback to call when the observer is notified
  62752. */
  62753. callback: (eventData: T, eventState: EventState) => void;
  62754. /**
  62755. * Defines the mask of the observer (used to filter notifications)
  62756. */
  62757. mask: number;
  62758. /**
  62759. * Defines the current scope used to restore the JS context
  62760. */
  62761. scope: any;
  62762. /** @hidden */
  62763. _willBeUnregistered: boolean;
  62764. /**
  62765. * Gets or sets a property defining that the observer as to be unregistered after the next notification
  62766. */
  62767. unregisterOnNextCall: boolean;
  62768. /**
  62769. * Creates a new observer
  62770. * @param callback defines the callback to call when the observer is notified
  62771. * @param mask defines the mask of the observer (used to filter notifications)
  62772. * @param scope defines the current scope used to restore the JS context
  62773. */
  62774. constructor(
  62775. /**
  62776. * Defines the callback to call when the observer is notified
  62777. */
  62778. callback: (eventData: T, eventState: EventState) => void,
  62779. /**
  62780. * Defines the mask of the observer (used to filter notifications)
  62781. */
  62782. mask: number,
  62783. /**
  62784. * Defines the current scope used to restore the JS context
  62785. */
  62786. scope?: any);
  62787. }
  62788. /**
  62789. * Represent a list of observers registered to multiple Observables object.
  62790. */
  62791. export class MultiObserver<T> {
  62792. private _observers;
  62793. private _observables;
  62794. /**
  62795. * Release associated resources
  62796. */
  62797. dispose(): void;
  62798. /**
  62799. * Raise a callback when one of the observable will notify
  62800. * @param observables defines a list of observables to watch
  62801. * @param callback defines the callback to call on notification
  62802. * @param mask defines the mask used to filter notifications
  62803. * @param scope defines the current scope used to restore the JS context
  62804. * @returns the new MultiObserver
  62805. */
  62806. static Watch<T>(observables: Observable<T>[], callback: (eventData: T, eventState: EventState) => void, mask?: number, scope?: any): MultiObserver<T>;
  62807. }
  62808. /**
  62809. * The Observable class is a simple implementation of the Observable pattern.
  62810. *
  62811. * 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.
  62812. * This enable a more fine grained execution without having to rely on multiple different Observable objects.
  62813. * 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).
  62814. * 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.
  62815. */
  62816. export class Observable<T> {
  62817. private _observers;
  62818. private _eventState;
  62819. private _onObserverAdded;
  62820. /**
  62821. * Creates a new observable
  62822. * @param onObserverAdded defines a callback to call when a new observer is added
  62823. */
  62824. constructor(onObserverAdded?: (observer: Observer<T>) => void);
  62825. /**
  62826. * Create a new Observer with the specified callback
  62827. * @param callback the callback that will be executed for that Observer
  62828. * @param mask the mask used to filter observers
  62829. * @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.
  62830. * @param scope optional scope for the callback to be called from
  62831. * @param unregisterOnFirstCall defines if the observer as to be unregistered after the next notification
  62832. * @returns the new observer created for the callback
  62833. */
  62834. add(callback: (eventData: T, eventState: EventState) => void, mask?: number, insertFirst?: boolean, scope?: any, unregisterOnFirstCall?: boolean): Nullable<Observer<T>>;
  62835. /**
  62836. * Create a new Observer with the specified callback and unregisters after the next notification
  62837. * @param callback the callback that will be executed for that Observer
  62838. * @returns the new observer created for the callback
  62839. */
  62840. addOnce(callback: (eventData: T, eventState: EventState) => void): Nullable<Observer<T>>;
  62841. /**
  62842. * Remove an Observer from the Observable object
  62843. * @param observer the instance of the Observer to remove
  62844. * @returns false if it doesn't belong to this Observable
  62845. */
  62846. remove(observer: Nullable<Observer<T>>): boolean;
  62847. /**
  62848. * Remove a callback from the Observable object
  62849. * @param callback the callback to remove
  62850. * @param scope optional scope. If used only the callbacks with this scope will be removed
  62851. * @returns false if it doesn't belong to this Observable
  62852. */
  62853. removeCallback(callback: (eventData: T, eventState: EventState) => void, scope?: any): boolean;
  62854. private _deferUnregister;
  62855. private _remove;
  62856. /**
  62857. * Moves the observable to the top of the observer list making it get called first when notified
  62858. * @param observer the observer to move
  62859. */
  62860. makeObserverTopPriority(observer: Observer<T>): void;
  62861. /**
  62862. * Moves the observable to the bottom of the observer list making it get called last when notified
  62863. * @param observer the observer to move
  62864. */
  62865. makeObserverBottomPriority(observer: Observer<T>): void;
  62866. /**
  62867. * Notify all Observers by calling their respective callback with the given data
  62868. * Will return true if all observers were executed, false if an observer set skipNextObservers to true, then prevent the subsequent ones to execute
  62869. * @param eventData defines the data to send to all observers
  62870. * @param mask defines the mask of the current notification (observers with incompatible mask (ie mask & observer.mask === 0) will not be notified)
  62871. * @param target defines the original target of the state
  62872. * @param currentTarget defines the current target of the state
  62873. * @returns false if the complete observer chain was not processed (because one observer set the skipNextObservers to true)
  62874. */
  62875. notifyObservers(eventData: T, mask?: number, target?: any, currentTarget?: any): boolean;
  62876. /**
  62877. * Calling this will execute each callback, expecting it to be a promise or return a value.
  62878. * If at any point in the chain one function fails, the promise will fail and the execution will not continue.
  62879. * This is useful when a chain of events (sometimes async events) is needed to initialize a certain object
  62880. * and it is crucial that all callbacks will be executed.
  62881. * The order of the callbacks is kept, callbacks are not executed parallel.
  62882. *
  62883. * @param eventData The data to be sent to each callback
  62884. * @param mask is used to filter observers defaults to -1
  62885. * @param target defines the callback target (see EventState)
  62886. * @param currentTarget defines he current object in the bubbling phase
  62887. * @returns {Promise<T>} will return a Promise than resolves when all callbacks executed successfully.
  62888. */
  62889. notifyObserversWithPromise(eventData: T, mask?: number, target?: any, currentTarget?: any): Promise<T>;
  62890. /**
  62891. * Notify a specific observer
  62892. * @param observer defines the observer to notify
  62893. * @param eventData defines the data to be sent to each callback
  62894. * @param mask is used to filter observers defaults to -1
  62895. */
  62896. notifyObserver(observer: Observer<T>, eventData: T, mask?: number): void;
  62897. /**
  62898. * Gets a boolean indicating if the observable has at least one observer
  62899. * @returns true is the Observable has at least one Observer registered
  62900. */
  62901. hasObservers(): boolean;
  62902. /**
  62903. * Clear the list of observers
  62904. */
  62905. clear(): void;
  62906. /**
  62907. * Clone the current observable
  62908. * @returns a new observable
  62909. */
  62910. clone(): Observable<T>;
  62911. /**
  62912. * Does this observable handles observer registered with a given mask
  62913. * @param mask defines the mask to be tested
  62914. * @return whether or not one observer registered with the given mask is handeled
  62915. **/
  62916. hasSpecificMask(mask?: number): boolean;
  62917. }
  62918. }
  62919. declare module BABYLON {
  62920. /**
  62921. * Class used to help managing file picking and drag'n'drop
  62922. * File Storage
  62923. */
  62924. export class FilesInputStore {
  62925. /**
  62926. * List of files ready to be loaded
  62927. */
  62928. static FilesToLoad: {
  62929. [key: string]: File;
  62930. };
  62931. }
  62932. }
  62933. declare module BABYLON {
  62934. /** Defines the cross module used constants to avoid circular dependncies */
  62935. export class Constants {
  62936. /** Defines that alpha blending is disabled */
  62937. static readonly ALPHA_DISABLE: number;
  62938. /** Defines that alpha blending to SRC ALPHA * SRC + DEST */
  62939. static readonly ALPHA_ADD: number;
  62940. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC ALPHA) * DEST */
  62941. static readonly ALPHA_COMBINE: number;
  62942. /** Defines that alpha blending to DEST - SRC * DEST */
  62943. static readonly ALPHA_SUBTRACT: number;
  62944. /** Defines that alpha blending to SRC * DEST */
  62945. static readonly ALPHA_MULTIPLY: number;
  62946. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC) * DEST */
  62947. static readonly ALPHA_MAXIMIZED: number;
  62948. /** Defines that alpha blending to SRC + DEST */
  62949. static readonly ALPHA_ONEONE: number;
  62950. /** Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST */
  62951. static readonly ALPHA_PREMULTIPLIED: number;
  62952. /**
  62953. * Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST
  62954. * Alpha will be set to (1 - SRC ALPHA) * DEST ALPHA
  62955. */
  62956. static readonly ALPHA_PREMULTIPLIED_PORTERDUFF: number;
  62957. /** Defines that alpha blending to CST * SRC + (1 - CST) * DEST */
  62958. static readonly ALPHA_INTERPOLATE: number;
  62959. /**
  62960. * Defines that alpha blending to SRC + (1 - SRC) * DEST
  62961. * Alpha will be set to SRC ALPHA + (1 - SRC ALPHA) * DEST ALPHA
  62962. */
  62963. static readonly ALPHA_SCREENMODE: number;
  62964. /** Defines that the ressource is not delayed*/
  62965. static readonly DELAYLOADSTATE_NONE: number;
  62966. /** Defines that the ressource was successfully delay loaded */
  62967. static readonly DELAYLOADSTATE_LOADED: number;
  62968. /** Defines that the ressource is currently delay loading */
  62969. static readonly DELAYLOADSTATE_LOADING: number;
  62970. /** Defines that the ressource is delayed and has not started loading */
  62971. static readonly DELAYLOADSTATE_NOTLOADED: number;
  62972. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will never pass. i.e. Nothing will be drawn */
  62973. static readonly NEVER: number;
  62974. /** 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 */
  62975. static readonly ALWAYS: number;
  62976. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than the stored value */
  62977. static readonly LESS: number;
  62978. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is equals to the stored value */
  62979. static readonly EQUAL: number;
  62980. /** 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 */
  62981. static readonly LEQUAL: number;
  62982. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than the stored value */
  62983. static readonly GREATER: number;
  62984. /** 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 */
  62985. static readonly GEQUAL: number;
  62986. /** 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 */
  62987. static readonly NOTEQUAL: number;
  62988. /** Passed to stencilOperation to specify that stencil value must be kept */
  62989. static readonly KEEP: number;
  62990. /** Passed to stencilOperation to specify that stencil value must be replaced */
  62991. static readonly REPLACE: number;
  62992. /** Passed to stencilOperation to specify that stencil value must be incremented */
  62993. static readonly INCR: number;
  62994. /** Passed to stencilOperation to specify that stencil value must be decremented */
  62995. static readonly DECR: number;
  62996. /** Passed to stencilOperation to specify that stencil value must be inverted */
  62997. static readonly INVERT: number;
  62998. /** Passed to stencilOperation to specify that stencil value must be incremented with wrapping */
  62999. static readonly INCR_WRAP: number;
  63000. /** Passed to stencilOperation to specify that stencil value must be decremented with wrapping */
  63001. static readonly DECR_WRAP: number;
  63002. /** Texture is not repeating outside of 0..1 UVs */
  63003. static readonly TEXTURE_CLAMP_ADDRESSMODE: number;
  63004. /** Texture is repeating outside of 0..1 UVs */
  63005. static readonly TEXTURE_WRAP_ADDRESSMODE: number;
  63006. /** Texture is repeating and mirrored */
  63007. static readonly TEXTURE_MIRROR_ADDRESSMODE: number;
  63008. /** ALPHA */
  63009. static readonly TEXTUREFORMAT_ALPHA: number;
  63010. /** LUMINANCE */
  63011. static readonly TEXTUREFORMAT_LUMINANCE: number;
  63012. /** LUMINANCE_ALPHA */
  63013. static readonly TEXTUREFORMAT_LUMINANCE_ALPHA: number;
  63014. /** RGB */
  63015. static readonly TEXTUREFORMAT_RGB: number;
  63016. /** RGBA */
  63017. static readonly TEXTUREFORMAT_RGBA: number;
  63018. /** RED */
  63019. static readonly TEXTUREFORMAT_RED: number;
  63020. /** RED (2nd reference) */
  63021. static readonly TEXTUREFORMAT_R: number;
  63022. /** RG */
  63023. static readonly TEXTUREFORMAT_RG: number;
  63024. /** RED_INTEGER */
  63025. static readonly TEXTUREFORMAT_RED_INTEGER: number;
  63026. /** RED_INTEGER (2nd reference) */
  63027. static readonly TEXTUREFORMAT_R_INTEGER: number;
  63028. /** RG_INTEGER */
  63029. static readonly TEXTUREFORMAT_RG_INTEGER: number;
  63030. /** RGB_INTEGER */
  63031. static readonly TEXTUREFORMAT_RGB_INTEGER: number;
  63032. /** RGBA_INTEGER */
  63033. static readonly TEXTUREFORMAT_RGBA_INTEGER: number;
  63034. /** UNSIGNED_BYTE */
  63035. static readonly TEXTURETYPE_UNSIGNED_BYTE: number;
  63036. /** UNSIGNED_BYTE (2nd reference) */
  63037. static readonly TEXTURETYPE_UNSIGNED_INT: number;
  63038. /** FLOAT */
  63039. static readonly TEXTURETYPE_FLOAT: number;
  63040. /** HALF_FLOAT */
  63041. static readonly TEXTURETYPE_HALF_FLOAT: number;
  63042. /** BYTE */
  63043. static readonly TEXTURETYPE_BYTE: number;
  63044. /** SHORT */
  63045. static readonly TEXTURETYPE_SHORT: number;
  63046. /** UNSIGNED_SHORT */
  63047. static readonly TEXTURETYPE_UNSIGNED_SHORT: number;
  63048. /** INT */
  63049. static readonly TEXTURETYPE_INT: number;
  63050. /** UNSIGNED_INT */
  63051. static readonly TEXTURETYPE_UNSIGNED_INTEGER: number;
  63052. /** UNSIGNED_SHORT_4_4_4_4 */
  63053. static readonly TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4: number;
  63054. /** UNSIGNED_SHORT_5_5_5_1 */
  63055. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1: number;
  63056. /** UNSIGNED_SHORT_5_6_5 */
  63057. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_6_5: number;
  63058. /** UNSIGNED_INT_2_10_10_10_REV */
  63059. static readonly TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV: number;
  63060. /** UNSIGNED_INT_24_8 */
  63061. static readonly TEXTURETYPE_UNSIGNED_INT_24_8: number;
  63062. /** UNSIGNED_INT_10F_11F_11F_REV */
  63063. static readonly TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV: number;
  63064. /** UNSIGNED_INT_5_9_9_9_REV */
  63065. static readonly TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV: number;
  63066. /** FLOAT_32_UNSIGNED_INT_24_8_REV */
  63067. static readonly TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  63068. /** nearest is mag = nearest and min = nearest and mip = linear */
  63069. static readonly TEXTURE_NEAREST_SAMPLINGMODE: number;
  63070. /** Bilinear is mag = linear and min = linear and mip = nearest */
  63071. static readonly TEXTURE_BILINEAR_SAMPLINGMODE: number;
  63072. /** Trilinear is mag = linear and min = linear and mip = linear */
  63073. static readonly TEXTURE_TRILINEAR_SAMPLINGMODE: number;
  63074. /** nearest is mag = nearest and min = nearest and mip = linear */
  63075. static readonly TEXTURE_NEAREST_NEAREST_MIPLINEAR: number;
  63076. /** Bilinear is mag = linear and min = linear and mip = nearest */
  63077. static readonly TEXTURE_LINEAR_LINEAR_MIPNEAREST: number;
  63078. /** Trilinear is mag = linear and min = linear and mip = linear */
  63079. static readonly TEXTURE_LINEAR_LINEAR_MIPLINEAR: number;
  63080. /** mag = nearest and min = nearest and mip = nearest */
  63081. static readonly TEXTURE_NEAREST_NEAREST_MIPNEAREST: number;
  63082. /** mag = nearest and min = linear and mip = nearest */
  63083. static readonly TEXTURE_NEAREST_LINEAR_MIPNEAREST: number;
  63084. /** mag = nearest and min = linear and mip = linear */
  63085. static readonly TEXTURE_NEAREST_LINEAR_MIPLINEAR: number;
  63086. /** mag = nearest and min = linear and mip = none */
  63087. static readonly TEXTURE_NEAREST_LINEAR: number;
  63088. /** mag = nearest and min = nearest and mip = none */
  63089. static readonly TEXTURE_NEAREST_NEAREST: number;
  63090. /** mag = linear and min = nearest and mip = nearest */
  63091. static readonly TEXTURE_LINEAR_NEAREST_MIPNEAREST: number;
  63092. /** mag = linear and min = nearest and mip = linear */
  63093. static readonly TEXTURE_LINEAR_NEAREST_MIPLINEAR: number;
  63094. /** mag = linear and min = linear and mip = none */
  63095. static readonly TEXTURE_LINEAR_LINEAR: number;
  63096. /** mag = linear and min = nearest and mip = none */
  63097. static readonly TEXTURE_LINEAR_NEAREST: number;
  63098. /** Explicit coordinates mode */
  63099. static readonly TEXTURE_EXPLICIT_MODE: number;
  63100. /** Spherical coordinates mode */
  63101. static readonly TEXTURE_SPHERICAL_MODE: number;
  63102. /** Planar coordinates mode */
  63103. static readonly TEXTURE_PLANAR_MODE: number;
  63104. /** Cubic coordinates mode */
  63105. static readonly TEXTURE_CUBIC_MODE: number;
  63106. /** Projection coordinates mode */
  63107. static readonly TEXTURE_PROJECTION_MODE: number;
  63108. /** Skybox coordinates mode */
  63109. static readonly TEXTURE_SKYBOX_MODE: number;
  63110. /** Inverse Cubic coordinates mode */
  63111. static readonly TEXTURE_INVCUBIC_MODE: number;
  63112. /** Equirectangular coordinates mode */
  63113. static readonly TEXTURE_EQUIRECTANGULAR_MODE: number;
  63114. /** Equirectangular Fixed coordinates mode */
  63115. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MODE: number;
  63116. /** Equirectangular Fixed Mirrored coordinates mode */
  63117. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  63118. /** Defines that texture rescaling will use a floor to find the closer power of 2 size */
  63119. static readonly SCALEMODE_FLOOR: number;
  63120. /** Defines that texture rescaling will look for the nearest power of 2 size */
  63121. static readonly SCALEMODE_NEAREST: number;
  63122. /** Defines that texture rescaling will use a ceil to find the closer power of 2 size */
  63123. static readonly SCALEMODE_CEILING: number;
  63124. /**
  63125. * The dirty texture flag value
  63126. */
  63127. static readonly MATERIAL_TextureDirtyFlag: number;
  63128. /**
  63129. * The dirty light flag value
  63130. */
  63131. static readonly MATERIAL_LightDirtyFlag: number;
  63132. /**
  63133. * The dirty fresnel flag value
  63134. */
  63135. static readonly MATERIAL_FresnelDirtyFlag: number;
  63136. /**
  63137. * The dirty attribute flag value
  63138. */
  63139. static readonly MATERIAL_AttributesDirtyFlag: number;
  63140. /**
  63141. * The dirty misc flag value
  63142. */
  63143. static readonly MATERIAL_MiscDirtyFlag: number;
  63144. /**
  63145. * The all dirty flag value
  63146. */
  63147. static readonly MATERIAL_AllDirtyFlag: number;
  63148. /**
  63149. * Returns the triangle fill mode
  63150. */
  63151. static readonly MATERIAL_TriangleFillMode: number;
  63152. /**
  63153. * Returns the wireframe mode
  63154. */
  63155. static readonly MATERIAL_WireFrameFillMode: number;
  63156. /**
  63157. * Returns the point fill mode
  63158. */
  63159. static readonly MATERIAL_PointFillMode: number;
  63160. /**
  63161. * Returns the point list draw mode
  63162. */
  63163. static readonly MATERIAL_PointListDrawMode: number;
  63164. /**
  63165. * Returns the line list draw mode
  63166. */
  63167. static readonly MATERIAL_LineListDrawMode: number;
  63168. /**
  63169. * Returns the line loop draw mode
  63170. */
  63171. static readonly MATERIAL_LineLoopDrawMode: number;
  63172. /**
  63173. * Returns the line strip draw mode
  63174. */
  63175. static readonly MATERIAL_LineStripDrawMode: number;
  63176. /**
  63177. * Returns the triangle strip draw mode
  63178. */
  63179. static readonly MATERIAL_TriangleStripDrawMode: number;
  63180. /**
  63181. * Returns the triangle fan draw mode
  63182. */
  63183. static readonly MATERIAL_TriangleFanDrawMode: number;
  63184. /**
  63185. * Stores the clock-wise side orientation
  63186. */
  63187. static readonly MATERIAL_ClockWiseSideOrientation: number;
  63188. /**
  63189. * Stores the counter clock-wise side orientation
  63190. */
  63191. static readonly MATERIAL_CounterClockWiseSideOrientation: number;
  63192. /**
  63193. * Nothing
  63194. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  63195. */
  63196. static readonly ACTION_NothingTrigger: number;
  63197. /**
  63198. * On pick
  63199. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  63200. */
  63201. static readonly ACTION_OnPickTrigger: number;
  63202. /**
  63203. * On left pick
  63204. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  63205. */
  63206. static readonly ACTION_OnLeftPickTrigger: number;
  63207. /**
  63208. * On right pick
  63209. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  63210. */
  63211. static readonly ACTION_OnRightPickTrigger: number;
  63212. /**
  63213. * On center pick
  63214. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  63215. */
  63216. static readonly ACTION_OnCenterPickTrigger: number;
  63217. /**
  63218. * On pick down
  63219. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  63220. */
  63221. static readonly ACTION_OnPickDownTrigger: number;
  63222. /**
  63223. * On double pick
  63224. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  63225. */
  63226. static readonly ACTION_OnDoublePickTrigger: number;
  63227. /**
  63228. * On pick up
  63229. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  63230. */
  63231. static readonly ACTION_OnPickUpTrigger: number;
  63232. /**
  63233. * On pick out.
  63234. * This trigger will only be raised if you also declared a OnPickDown
  63235. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  63236. */
  63237. static readonly ACTION_OnPickOutTrigger: number;
  63238. /**
  63239. * On long press
  63240. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  63241. */
  63242. static readonly ACTION_OnLongPressTrigger: number;
  63243. /**
  63244. * On pointer over
  63245. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  63246. */
  63247. static readonly ACTION_OnPointerOverTrigger: number;
  63248. /**
  63249. * On pointer out
  63250. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  63251. */
  63252. static readonly ACTION_OnPointerOutTrigger: number;
  63253. /**
  63254. * On every frame
  63255. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  63256. */
  63257. static readonly ACTION_OnEveryFrameTrigger: number;
  63258. /**
  63259. * On intersection enter
  63260. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  63261. */
  63262. static readonly ACTION_OnIntersectionEnterTrigger: number;
  63263. /**
  63264. * On intersection exit
  63265. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  63266. */
  63267. static readonly ACTION_OnIntersectionExitTrigger: number;
  63268. /**
  63269. * On key down
  63270. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  63271. */
  63272. static readonly ACTION_OnKeyDownTrigger: number;
  63273. /**
  63274. * On key up
  63275. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  63276. */
  63277. static readonly ACTION_OnKeyUpTrigger: number;
  63278. /**
  63279. * Billboard mode will only apply to Y axis
  63280. */
  63281. static readonly PARTICLES_BILLBOARDMODE_Y: number;
  63282. /**
  63283. * Billboard mode will apply to all axes
  63284. */
  63285. static readonly PARTICLES_BILLBOARDMODE_ALL: number;
  63286. /**
  63287. * Special billboard mode where the particle will be biilboard to the camera but rotated to align with direction
  63288. */
  63289. static readonly PARTICLES_BILLBOARDMODE_STRETCHED: number;
  63290. /**
  63291. * Gets or sets base Assets URL
  63292. */
  63293. static readonly PARTICLES_BaseAssetsUrl: string;
  63294. /** Default culling strategy : this is an exclusion test and it's the more accurate.
  63295. * Test order :
  63296. * Is the bounding sphere outside the frustum ?
  63297. * If not, are the bounding box vertices outside the frustum ?
  63298. * It not, then the cullable object is in the frustum.
  63299. */
  63300. static readonly MESHES_CULLINGSTRATEGY_STANDARD: number;
  63301. /** Culling strategy : Bounding Sphere Only.
  63302. * This is an exclusion test. It's faster than the standard strategy because the bounding box is not tested.
  63303. * It's also less accurate than the standard because some not visible objects can still be selected.
  63304. * Test : is the bounding sphere outside the frustum ?
  63305. * If not, then the cullable object is in the frustum.
  63306. */
  63307. static readonly MESHES_CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY: number;
  63308. /** Culling strategy : Optimistic Inclusion.
  63309. * This in an inclusion test first, then the standard exclusion test.
  63310. * This can be faster when a cullable object is expected to be almost always in the camera frustum.
  63311. * 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.
  63312. * Anyway, it's as accurate as the standard strategy.
  63313. * Test :
  63314. * Is the cullable object bounding sphere center in the frustum ?
  63315. * If not, apply the default culling strategy.
  63316. */
  63317. static readonly MESHES_CULLINGSTRATEGY_OPTIMISTIC_INCLUSION: number;
  63318. /** Culling strategy : Optimistic Inclusion then Bounding Sphere Only.
  63319. * This in an inclusion test first, then the bounding sphere only exclusion test.
  63320. * This can be the fastest test when a cullable object is expected to be almost always in the camera frustum.
  63321. * 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.
  63322. * It's less accurate than the standard strategy and as accurate as the BoundingSphereOnly strategy.
  63323. * Test :
  63324. * Is the cullable object bounding sphere center in the frustum ?
  63325. * If not, apply the Bounding Sphere Only strategy. No Bounding Box is tested here.
  63326. */
  63327. static readonly MESHES_CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY: number;
  63328. /**
  63329. * No logging while loading
  63330. */
  63331. static readonly SCENELOADER_NO_LOGGING: number;
  63332. /**
  63333. * Minimal logging while loading
  63334. */
  63335. static readonly SCENELOADER_MINIMAL_LOGGING: number;
  63336. /**
  63337. * Summary logging while loading
  63338. */
  63339. static readonly SCENELOADER_SUMMARY_LOGGING: number;
  63340. /**
  63341. * Detailled logging while loading
  63342. */
  63343. static readonly SCENELOADER_DETAILED_LOGGING: number;
  63344. }
  63345. }
  63346. declare module BABYLON {
  63347. /**
  63348. * Sets of helpers dealing with the DOM and some of the recurrent functions needed in
  63349. * Babylon.js
  63350. */
  63351. export class DomManagement {
  63352. /**
  63353. * Checks if the window object exists
  63354. * @returns true if the window object exists
  63355. */
  63356. static IsWindowObjectExist(): boolean;
  63357. /**
  63358. * Extracts text content from a DOM element hierarchy
  63359. * @param element defines the root element
  63360. * @returns a string
  63361. */
  63362. static GetDOMTextContent(element: HTMLElement): string;
  63363. }
  63364. }
  63365. declare module BABYLON {
  63366. /**
  63367. * Logger used througouht the application to allow configuration of
  63368. * the log level required for the messages.
  63369. */
  63370. export class Logger {
  63371. /**
  63372. * No log
  63373. */
  63374. static readonly NoneLogLevel: number;
  63375. /**
  63376. * Only message logs
  63377. */
  63378. static readonly MessageLogLevel: number;
  63379. /**
  63380. * Only warning logs
  63381. */
  63382. static readonly WarningLogLevel: number;
  63383. /**
  63384. * Only error logs
  63385. */
  63386. static readonly ErrorLogLevel: number;
  63387. /**
  63388. * All logs
  63389. */
  63390. static readonly AllLogLevel: number;
  63391. private static _LogCache;
  63392. /**
  63393. * Gets a value indicating the number of loading errors
  63394. * @ignorenaming
  63395. */
  63396. static errorsCount: number;
  63397. /**
  63398. * Callback called when a new log is added
  63399. */
  63400. static OnNewCacheEntry: (entry: string) => void;
  63401. private static _AddLogEntry;
  63402. private static _FormatMessage;
  63403. private static _LogDisabled;
  63404. private static _LogEnabled;
  63405. private static _WarnDisabled;
  63406. private static _WarnEnabled;
  63407. private static _ErrorDisabled;
  63408. private static _ErrorEnabled;
  63409. /**
  63410. * Log a message to the console
  63411. */
  63412. static Log: (message: string) => void;
  63413. /**
  63414. * Write a warning message to the console
  63415. */
  63416. static Warn: (message: string) => void;
  63417. /**
  63418. * Write an error message to the console
  63419. */
  63420. static Error: (message: string) => void;
  63421. /**
  63422. * Gets current log cache (list of logs)
  63423. */
  63424. static readonly LogCache: string;
  63425. /**
  63426. * Clears the log cache
  63427. */
  63428. static ClearLogCache(): void;
  63429. /**
  63430. * Sets the current log level (MessageLogLevel / WarningLogLevel / ErrorLogLevel)
  63431. */
  63432. static LogLevels: number;
  63433. }
  63434. }
  63435. declare module BABYLON {
  63436. /** @hidden */
  63437. export class _TypeStore {
  63438. /** @hidden */
  63439. static RegisteredTypes: {
  63440. [key: string]: Object;
  63441. };
  63442. /** @hidden */
  63443. static GetClass(fqdn: string): any;
  63444. }
  63445. }
  63446. declare module BABYLON {
  63447. /**
  63448. * Class containing a set of static utilities functions for deep copy.
  63449. */
  63450. export class DeepCopier {
  63451. /**
  63452. * Tries to copy an object by duplicating every property
  63453. * @param source defines the source object
  63454. * @param destination defines the target object
  63455. * @param doNotCopyList defines a list of properties to avoid
  63456. * @param mustCopyList defines a list of properties to copy (even if they start with _)
  63457. */
  63458. static DeepCopy(source: any, destination: any, doNotCopyList?: string[], mustCopyList?: string[]): void;
  63459. }
  63460. }
  63461. declare module BABYLON {
  63462. /**
  63463. * Class containing a set of static utilities functions for precision date
  63464. */
  63465. export class PrecisionDate {
  63466. /**
  63467. * Gets either window.performance.now() if supported or Date.now() else
  63468. */
  63469. static readonly Now: number;
  63470. }
  63471. }
  63472. declare module BABYLON {
  63473. /** @hidden */
  63474. export class _DevTools {
  63475. static WarnImport(name: string): string;
  63476. }
  63477. }
  63478. declare module BABYLON {
  63479. /**
  63480. * Extended version of XMLHttpRequest with support for customizations (headers, ...)
  63481. */
  63482. export class WebRequest {
  63483. private _xhr;
  63484. /**
  63485. * Custom HTTP Request Headers to be sent with XMLHttpRequests
  63486. * i.e. when loading files, where the server/service expects an Authorization header
  63487. */
  63488. static CustomRequestHeaders: {
  63489. [key: string]: string;
  63490. };
  63491. /**
  63492. * Add callback functions in this array to update all the requests before they get sent to the network
  63493. */
  63494. static CustomRequestModifiers: ((request: XMLHttpRequest) => void)[];
  63495. private _injectCustomRequestHeaders;
  63496. /**
  63497. * Gets or sets a function to be called when loading progress changes
  63498. */
  63499. onprogress: ((this: XMLHttpRequest, ev: ProgressEvent) => any) | null;
  63500. /**
  63501. * Returns client's state
  63502. */
  63503. readonly readyState: number;
  63504. /**
  63505. * Returns client's status
  63506. */
  63507. readonly status: number;
  63508. /**
  63509. * Returns client's status as a text
  63510. */
  63511. readonly statusText: string;
  63512. /**
  63513. * Returns client's response
  63514. */
  63515. readonly response: any;
  63516. /**
  63517. * Returns client's response url
  63518. */
  63519. readonly responseURL: string;
  63520. /**
  63521. * Returns client's response as text
  63522. */
  63523. readonly responseText: string;
  63524. /**
  63525. * Gets or sets the expected response type
  63526. */
  63527. responseType: XMLHttpRequestResponseType;
  63528. /** @hidden */
  63529. addEventListener<K extends keyof XMLHttpRequestEventMap>(type: K, listener: (this: XMLHttpRequest, ev: XMLHttpRequestEventMap[K]) => any, options?: boolean | AddEventListenerOptions): void;
  63530. /** @hidden */
  63531. removeEventListener<K extends keyof XMLHttpRequestEventMap>(type: K, listener: (this: XMLHttpRequest, ev: XMLHttpRequestEventMap[K]) => any, options?: boolean | EventListenerOptions): void;
  63532. /**
  63533. * Cancels any network activity
  63534. */
  63535. abort(): void;
  63536. /**
  63537. * Initiates the request. The optional argument provides the request body. The argument is ignored if request method is GET or HEAD
  63538. * @param body defines an optional request body
  63539. */
  63540. send(body?: Document | BodyInit | null): void;
  63541. /**
  63542. * Sets the request method, request URL
  63543. * @param method defines the method to use (GET, POST, etc..)
  63544. * @param url defines the url to connect with
  63545. */
  63546. open(method: string, url: string): void;
  63547. }
  63548. }
  63549. declare module BABYLON {
  63550. /**
  63551. * Class used to evalaute queries containing `and` and `or` operators
  63552. */
  63553. export class AndOrNotEvaluator {
  63554. /**
  63555. * Evaluate a query
  63556. * @param query defines the query to evaluate
  63557. * @param evaluateCallback defines the callback used to filter result
  63558. * @returns true if the query matches
  63559. */
  63560. static Eval(query: string, evaluateCallback: (val: any) => boolean): boolean;
  63561. private static _HandleParenthesisContent;
  63562. private static _SimplifyNegation;
  63563. }
  63564. }
  63565. declare module BABYLON {
  63566. /**
  63567. * Class used to store custom tags
  63568. */
  63569. export class Tags {
  63570. /**
  63571. * Adds support for tags on the given object
  63572. * @param obj defines the object to use
  63573. */
  63574. static EnableFor(obj: any): void;
  63575. /**
  63576. * Removes tags support
  63577. * @param obj defines the object to use
  63578. */
  63579. static DisableFor(obj: any): void;
  63580. /**
  63581. * Gets a boolean indicating if the given object has tags
  63582. * @param obj defines the object to use
  63583. * @returns a boolean
  63584. */
  63585. static HasTags(obj: any): boolean;
  63586. /**
  63587. * Gets the tags available on a given object
  63588. * @param obj defines the object to use
  63589. * @param asString defines if the tags must be returned as a string instead of an array of strings
  63590. * @returns the tags
  63591. */
  63592. static GetTags(obj: any, asString?: boolean): any;
  63593. /**
  63594. * Adds tags to an object
  63595. * @param obj defines the object to use
  63596. * @param tagsString defines the tag string. The tags 'true' and 'false' are reserved and cannot be used as tags.
  63597. * A tag cannot start with '||', '&&', and '!'. It cannot contain whitespaces
  63598. */
  63599. static AddTagsTo(obj: any, tagsString: string): void;
  63600. /**
  63601. * @hidden
  63602. */
  63603. static _AddTagTo(obj: any, tag: string): void;
  63604. /**
  63605. * Removes specific tags from a specific object
  63606. * @param obj defines the object to use
  63607. * @param tagsString defines the tags to remove
  63608. */
  63609. static RemoveTagsFrom(obj: any, tagsString: string): void;
  63610. /**
  63611. * @hidden
  63612. */
  63613. static _RemoveTagFrom(obj: any, tag: string): void;
  63614. /**
  63615. * Defines if tags hosted on an object match a given query
  63616. * @param obj defines the object to use
  63617. * @param tagsQuery defines the tag query
  63618. * @returns a boolean
  63619. */
  63620. static MatchesQuery(obj: any, tagsQuery: string): boolean;
  63621. }
  63622. }
  63623. declare module BABYLON {
  63624. /**
  63625. * Manages the defines for the Material
  63626. */
  63627. export class MaterialDefines {
  63628. private _keys;
  63629. private _isDirty;
  63630. /** @hidden */
  63631. _renderId: number;
  63632. /** @hidden */
  63633. _areLightsDirty: boolean;
  63634. /** @hidden */
  63635. _areAttributesDirty: boolean;
  63636. /** @hidden */
  63637. _areTexturesDirty: boolean;
  63638. /** @hidden */
  63639. _areFresnelDirty: boolean;
  63640. /** @hidden */
  63641. _areMiscDirty: boolean;
  63642. /** @hidden */
  63643. _areImageProcessingDirty: boolean;
  63644. /** @hidden */
  63645. _normals: boolean;
  63646. /** @hidden */
  63647. _uvs: boolean;
  63648. /** @hidden */
  63649. _needNormals: boolean;
  63650. /** @hidden */
  63651. _needUVs: boolean;
  63652. /**
  63653. * Specifies if the material needs to be re-calculated
  63654. */
  63655. readonly isDirty: boolean;
  63656. /**
  63657. * Marks the material to indicate that it has been re-calculated
  63658. */
  63659. markAsProcessed(): void;
  63660. /**
  63661. * Marks the material to indicate that it needs to be re-calculated
  63662. */
  63663. markAsUnprocessed(): void;
  63664. /**
  63665. * Marks the material to indicate all of its defines need to be re-calculated
  63666. */
  63667. markAllAsDirty(): void;
  63668. /**
  63669. * Marks the material to indicate that image processing needs to be re-calculated
  63670. */
  63671. markAsImageProcessingDirty(): void;
  63672. /**
  63673. * Marks the material to indicate the lights need to be re-calculated
  63674. */
  63675. markAsLightDirty(): void;
  63676. /**
  63677. * Marks the attribute state as changed
  63678. */
  63679. markAsAttributesDirty(): void;
  63680. /**
  63681. * Marks the texture state as changed
  63682. */
  63683. markAsTexturesDirty(): void;
  63684. /**
  63685. * Marks the fresnel state as changed
  63686. */
  63687. markAsFresnelDirty(): void;
  63688. /**
  63689. * Marks the misc state as changed
  63690. */
  63691. markAsMiscDirty(): void;
  63692. /**
  63693. * Rebuilds the material defines
  63694. */
  63695. rebuild(): void;
  63696. /**
  63697. * Specifies if two material defines are equal
  63698. * @param other - A material define instance to compare to
  63699. * @returns - Boolean indicating if the material defines are equal (true) or not (false)
  63700. */
  63701. isEqual(other: MaterialDefines): boolean;
  63702. /**
  63703. * Clones this instance's defines to another instance
  63704. * @param other - material defines to clone values to
  63705. */
  63706. cloneTo(other: MaterialDefines): void;
  63707. /**
  63708. * Resets the material define values
  63709. */
  63710. reset(): void;
  63711. /**
  63712. * Converts the material define values to a string
  63713. * @returns - String of material define information
  63714. */
  63715. toString(): string;
  63716. }
  63717. }
  63718. declare module BABYLON {
  63719. /**
  63720. * Performance monitor tracks rolling average frame-time and frame-time variance over a user defined sliding-window
  63721. */
  63722. export class PerformanceMonitor {
  63723. private _enabled;
  63724. private _rollingFrameTime;
  63725. private _lastFrameTimeMs;
  63726. /**
  63727. * constructor
  63728. * @param frameSampleSize The number of samples required to saturate the sliding window
  63729. */
  63730. constructor(frameSampleSize?: number);
  63731. /**
  63732. * Samples current frame
  63733. * @param timeMs A timestamp in milliseconds of the current frame to compare with other frames
  63734. */
  63735. sampleFrame(timeMs?: number): void;
  63736. /**
  63737. * Returns the average frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  63738. */
  63739. readonly averageFrameTime: number;
  63740. /**
  63741. * Returns the variance frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  63742. */
  63743. readonly averageFrameTimeVariance: number;
  63744. /**
  63745. * Returns the frame time of the most recent frame
  63746. */
  63747. readonly instantaneousFrameTime: number;
  63748. /**
  63749. * Returns the average framerate in frames per second over the sliding window (or the subset of frames sampled so far)
  63750. */
  63751. readonly averageFPS: number;
  63752. /**
  63753. * Returns the average framerate in frames per second using the most recent frame time
  63754. */
  63755. readonly instantaneousFPS: number;
  63756. /**
  63757. * Returns true if enough samples have been taken to completely fill the sliding window
  63758. */
  63759. readonly isSaturated: boolean;
  63760. /**
  63761. * Enables contributions to the sliding window sample set
  63762. */
  63763. enable(): void;
  63764. /**
  63765. * Disables contributions to the sliding window sample set
  63766. * Samples will not be interpolated over the disabled period
  63767. */
  63768. disable(): void;
  63769. /**
  63770. * Returns true if sampling is enabled
  63771. */
  63772. readonly isEnabled: boolean;
  63773. /**
  63774. * Resets performance monitor
  63775. */
  63776. reset(): void;
  63777. }
  63778. /**
  63779. * RollingAverage
  63780. *
  63781. * Utility to efficiently compute the rolling average and variance over a sliding window of samples
  63782. */
  63783. export class RollingAverage {
  63784. /**
  63785. * Current average
  63786. */
  63787. average: number;
  63788. /**
  63789. * Current variance
  63790. */
  63791. variance: number;
  63792. protected _samples: Array<number>;
  63793. protected _sampleCount: number;
  63794. protected _pos: number;
  63795. protected _m2: number;
  63796. /**
  63797. * constructor
  63798. * @param length The number of samples required to saturate the sliding window
  63799. */
  63800. constructor(length: number);
  63801. /**
  63802. * Adds a sample to the sample set
  63803. * @param v The sample value
  63804. */
  63805. add(v: number): void;
  63806. /**
  63807. * Returns previously added values or null if outside of history or outside the sliding window domain
  63808. * @param i Index in history. For example, pass 0 for the most recent value and 1 for the value before that
  63809. * @return Value previously recorded with add() or null if outside of range
  63810. */
  63811. history(i: number): number;
  63812. /**
  63813. * Returns true if enough samples have been taken to completely fill the sliding window
  63814. * @return true if sample-set saturated
  63815. */
  63816. isSaturated(): boolean;
  63817. /**
  63818. * Resets the rolling average (equivalent to 0 samples taken so far)
  63819. */
  63820. reset(): void;
  63821. /**
  63822. * Wraps a value around the sample range boundaries
  63823. * @param i Position in sample range, for example if the sample length is 5, and i is -3, then 2 will be returned.
  63824. * @return Wrapped position in sample range
  63825. */
  63826. protected _wrapPosition(i: number): number;
  63827. }
  63828. }
  63829. declare module BABYLON {
  63830. /**
  63831. * This class implement a typical dictionary using a string as key and the generic type T as value.
  63832. * The underlying implementation relies on an associative array to ensure the best performances.
  63833. * The value can be anything including 'null' but except 'undefined'
  63834. */
  63835. export class StringDictionary<T> {
  63836. /**
  63837. * This will clear this dictionary and copy the content from the 'source' one.
  63838. * If the T value is a custom object, it won't be copied/cloned, the same object will be used
  63839. * @param source the dictionary to take the content from and copy to this dictionary
  63840. */
  63841. copyFrom(source: StringDictionary<T>): void;
  63842. /**
  63843. * Get a value based from its key
  63844. * @param key the given key to get the matching value from
  63845. * @return the value if found, otherwise undefined is returned
  63846. */
  63847. get(key: string): T | undefined;
  63848. /**
  63849. * Get a value from its key or add it if it doesn't exist.
  63850. * This method will ensure you that a given key/data will be present in the dictionary.
  63851. * @param key the given key to get the matching value from
  63852. * @param factory the factory that will create the value if the key is not present in the dictionary.
  63853. * The factory will only be invoked if there's no data for the given key.
  63854. * @return the value corresponding to the key.
  63855. */
  63856. getOrAddWithFactory(key: string, factory: (key: string) => T): T;
  63857. /**
  63858. * Get a value from its key if present in the dictionary otherwise add it
  63859. * @param key the key to get the value from
  63860. * @param val if there's no such key/value pair in the dictionary add it with this value
  63861. * @return the value corresponding to the key
  63862. */
  63863. getOrAdd(key: string, val: T): T;
  63864. /**
  63865. * Check if there's a given key in the dictionary
  63866. * @param key the key to check for
  63867. * @return true if the key is present, false otherwise
  63868. */
  63869. contains(key: string): boolean;
  63870. /**
  63871. * Add a new key and its corresponding value
  63872. * @param key the key to add
  63873. * @param value the value corresponding to the key
  63874. * @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
  63875. */
  63876. add(key: string, value: T): boolean;
  63877. /**
  63878. * Update a specific value associated to a key
  63879. * @param key defines the key to use
  63880. * @param value defines the value to store
  63881. * @returns true if the value was updated (or false if the key was not found)
  63882. */
  63883. set(key: string, value: T): boolean;
  63884. /**
  63885. * Get the element of the given key and remove it from the dictionary
  63886. * @param key defines the key to search
  63887. * @returns the value associated with the key or null if not found
  63888. */
  63889. getAndRemove(key: string): Nullable<T>;
  63890. /**
  63891. * Remove a key/value from the dictionary.
  63892. * @param key the key to remove
  63893. * @return true if the item was successfully deleted, false if no item with such key exist in the dictionary
  63894. */
  63895. remove(key: string): boolean;
  63896. /**
  63897. * Clear the whole content of the dictionary
  63898. */
  63899. clear(): void;
  63900. /**
  63901. * Gets the current count
  63902. */
  63903. readonly count: number;
  63904. /**
  63905. * Execute a callback on each key/val of the dictionary.
  63906. * Note that you can remove any element in this dictionary in the callback implementation
  63907. * @param callback the callback to execute on a given key/value pair
  63908. */
  63909. forEach(callback: (key: string, val: T) => void): void;
  63910. /**
  63911. * Execute a callback on every occurrence of the dictionary until it returns a valid TRes object.
  63912. * If the callback returns null or undefined the method will iterate to the next key/value pair
  63913. * Note that you can remove any element in this dictionary in the callback implementation
  63914. * @param callback the callback to execute, if it return a valid T instanced object the enumeration will stop and the object will be returned
  63915. * @returns the first item
  63916. */
  63917. first<TRes>(callback: (key: string, val: T) => TRes): TRes | null;
  63918. private _count;
  63919. private _data;
  63920. }
  63921. }
  63922. declare module BABYLON {
  63923. /**
  63924. * Helper class that provides a small promise polyfill
  63925. */
  63926. export class PromisePolyfill {
  63927. /**
  63928. * Static function used to check if the polyfill is required
  63929. * If this is the case then the function will inject the polyfill to window.Promise
  63930. * @param force defines a boolean used to force the injection (mostly for testing purposes)
  63931. */
  63932. static Apply(force?: boolean): void;
  63933. }
  63934. }
  63935. declare module BABYLON {
  63936. /**
  63937. * Class used to store data that will be store in GPU memory
  63938. */
  63939. export class Buffer {
  63940. private _engine;
  63941. private _buffer;
  63942. /** @hidden */
  63943. _data: Nullable<DataArray>;
  63944. private _updatable;
  63945. private _instanced;
  63946. /**
  63947. * Gets the byte stride.
  63948. */
  63949. readonly byteStride: number;
  63950. /**
  63951. * Constructor
  63952. * @param engine the engine
  63953. * @param data the data to use for this buffer
  63954. * @param updatable whether the data is updatable
  63955. * @param stride the stride (optional)
  63956. * @param postponeInternalCreation whether to postpone creating the internal WebGL buffer (optional)
  63957. * @param instanced whether the buffer is instanced (optional)
  63958. * @param useBytes set to true if the stride in in bytes (optional)
  63959. */
  63960. constructor(engine: any, data: DataArray, updatable: boolean, stride?: number, postponeInternalCreation?: boolean, instanced?: boolean, useBytes?: boolean);
  63961. /**
  63962. * Create a new VertexBuffer based on the current buffer
  63963. * @param kind defines the vertex buffer kind (position, normal, etc.)
  63964. * @param offset defines offset in the buffer (0 by default)
  63965. * @param size defines the size in floats of attributes (position is 3 for instance)
  63966. * @param stride defines the stride size in floats in the buffer (the offset to apply to reach next value when data is interleaved)
  63967. * @param instanced defines if the vertex buffer contains indexed data
  63968. * @param useBytes defines if the offset and stride are in bytes
  63969. * @returns the new vertex buffer
  63970. */
  63971. createVertexBuffer(kind: string, offset: number, size: number, stride?: number, instanced?: boolean, useBytes?: boolean): VertexBuffer;
  63972. /**
  63973. * Gets a boolean indicating if the Buffer is updatable?
  63974. * @returns true if the buffer is updatable
  63975. */
  63976. isUpdatable(): boolean;
  63977. /**
  63978. * Gets current buffer's data
  63979. * @returns a DataArray or null
  63980. */
  63981. getData(): Nullable<DataArray>;
  63982. /**
  63983. * Gets underlying native buffer
  63984. * @returns underlying native buffer
  63985. */
  63986. getBuffer(): Nullable<WebGLBuffer>;
  63987. /**
  63988. * Gets the stride in float32 units (i.e. byte stride / 4).
  63989. * May not be an integer if the byte stride is not divisible by 4.
  63990. * DEPRECATED. Use byteStride instead.
  63991. * @returns the stride in float32 units
  63992. */
  63993. getStrideSize(): number;
  63994. /**
  63995. * Store data into the buffer. If the buffer was already used it will be either recreated or updated depending on isUpdatable property
  63996. * @param data defines the data to store
  63997. */
  63998. create(data?: Nullable<DataArray>): void;
  63999. /** @hidden */
  64000. _rebuild(): void;
  64001. /**
  64002. * Update current buffer data
  64003. * @param data defines the data to store
  64004. */
  64005. update(data: DataArray): void;
  64006. /**
  64007. * Updates the data directly.
  64008. * @param data the new data
  64009. * @param offset the new offset
  64010. * @param vertexCount the vertex count (optional)
  64011. * @param useBytes set to true if the offset is in bytes
  64012. */
  64013. updateDirectly(data: DataArray, offset: number, vertexCount?: number, useBytes?: boolean): void;
  64014. /**
  64015. * Release all resources
  64016. */
  64017. dispose(): void;
  64018. }
  64019. /**
  64020. * Specialized buffer used to store vertex data
  64021. */
  64022. export class VertexBuffer {
  64023. /** @hidden */
  64024. _buffer: Buffer;
  64025. private _kind;
  64026. private _size;
  64027. private _ownsBuffer;
  64028. private _instanced;
  64029. private _instanceDivisor;
  64030. /**
  64031. * The byte type.
  64032. */
  64033. static readonly BYTE: number;
  64034. /**
  64035. * The unsigned byte type.
  64036. */
  64037. static readonly UNSIGNED_BYTE: number;
  64038. /**
  64039. * The short type.
  64040. */
  64041. static readonly SHORT: number;
  64042. /**
  64043. * The unsigned short type.
  64044. */
  64045. static readonly UNSIGNED_SHORT: number;
  64046. /**
  64047. * The integer type.
  64048. */
  64049. static readonly INT: number;
  64050. /**
  64051. * The unsigned integer type.
  64052. */
  64053. static readonly UNSIGNED_INT: number;
  64054. /**
  64055. * The float type.
  64056. */
  64057. static readonly FLOAT: number;
  64058. /**
  64059. * Gets or sets the instance divisor when in instanced mode
  64060. */
  64061. instanceDivisor: number;
  64062. /**
  64063. * Gets the byte stride.
  64064. */
  64065. readonly byteStride: number;
  64066. /**
  64067. * Gets the byte offset.
  64068. */
  64069. readonly byteOffset: number;
  64070. /**
  64071. * Gets whether integer data values should be normalized into a certain range when being casted to a float.
  64072. */
  64073. readonly normalized: boolean;
  64074. /**
  64075. * Gets the data type of each component in the array.
  64076. */
  64077. readonly type: number;
  64078. /**
  64079. * Constructor
  64080. * @param engine the engine
  64081. * @param data the data to use for this vertex buffer
  64082. * @param kind the vertex buffer kind
  64083. * @param updatable whether the data is updatable
  64084. * @param postponeInternalCreation whether to postpone creating the internal WebGL buffer (optional)
  64085. * @param stride the stride (optional)
  64086. * @param instanced whether the buffer is instanced (optional)
  64087. * @param offset the offset of the data (optional)
  64088. * @param size the number of components (optional)
  64089. * @param type the type of the component (optional)
  64090. * @param normalized whether the data contains normalized data (optional)
  64091. * @param useBytes set to true if stride and offset are in bytes (optional)
  64092. */
  64093. 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);
  64094. /** @hidden */
  64095. _rebuild(): void;
  64096. /**
  64097. * Returns the kind of the VertexBuffer (string)
  64098. * @returns a string
  64099. */
  64100. getKind(): string;
  64101. /**
  64102. * Gets a boolean indicating if the VertexBuffer is updatable?
  64103. * @returns true if the buffer is updatable
  64104. */
  64105. isUpdatable(): boolean;
  64106. /**
  64107. * Gets current buffer's data
  64108. * @returns a DataArray or null
  64109. */
  64110. getData(): Nullable<DataArray>;
  64111. /**
  64112. * Gets underlying native buffer
  64113. * @returns underlying native buffer
  64114. */
  64115. getBuffer(): Nullable<WebGLBuffer>;
  64116. /**
  64117. * Gets the stride in float32 units (i.e. byte stride / 4).
  64118. * May not be an integer if the byte stride is not divisible by 4.
  64119. * DEPRECATED. Use byteStride instead.
  64120. * @returns the stride in float32 units
  64121. */
  64122. getStrideSize(): number;
  64123. /**
  64124. * Returns the offset as a multiple of the type byte length.
  64125. * DEPRECATED. Use byteOffset instead.
  64126. * @returns the offset in bytes
  64127. */
  64128. getOffset(): number;
  64129. /**
  64130. * Returns the number of components per vertex attribute (integer)
  64131. * @returns the size in float
  64132. */
  64133. getSize(): number;
  64134. /**
  64135. * Gets a boolean indicating is the internal buffer of the VertexBuffer is instanced
  64136. * @returns true if this buffer is instanced
  64137. */
  64138. getIsInstanced(): boolean;
  64139. /**
  64140. * Returns the instancing divisor, zero for non-instanced (integer).
  64141. * @returns a number
  64142. */
  64143. getInstanceDivisor(): number;
  64144. /**
  64145. * Store data into the buffer. If the buffer was already used it will be either recreated or updated depending on isUpdatable property
  64146. * @param data defines the data to store
  64147. */
  64148. create(data?: DataArray): void;
  64149. /**
  64150. * Updates the underlying buffer according to the passed numeric array or Float32Array.
  64151. * This function will create a new buffer if the current one is not updatable
  64152. * @param data defines the data to store
  64153. */
  64154. update(data: DataArray): void;
  64155. /**
  64156. * Updates directly the underlying WebGLBuffer according to the passed numeric array or Float32Array.
  64157. * Returns the directly updated WebGLBuffer.
  64158. * @param data the new data
  64159. * @param offset the new offset
  64160. * @param useBytes set to true if the offset is in bytes
  64161. */
  64162. updateDirectly(data: DataArray, offset: number, useBytes?: boolean): void;
  64163. /**
  64164. * Disposes the VertexBuffer and the underlying WebGLBuffer.
  64165. */
  64166. dispose(): void;
  64167. /**
  64168. * Enumerates each value of this vertex buffer as numbers.
  64169. * @param count the number of values to enumerate
  64170. * @param callback the callback function called for each value
  64171. */
  64172. forEach(count: number, callback: (value: number, index: number) => void): void;
  64173. /**
  64174. * Positions
  64175. */
  64176. static readonly PositionKind: string;
  64177. /**
  64178. * Normals
  64179. */
  64180. static readonly NormalKind: string;
  64181. /**
  64182. * Tangents
  64183. */
  64184. static readonly TangentKind: string;
  64185. /**
  64186. * Texture coordinates
  64187. */
  64188. static readonly UVKind: string;
  64189. /**
  64190. * Texture coordinates 2
  64191. */
  64192. static readonly UV2Kind: string;
  64193. /**
  64194. * Texture coordinates 3
  64195. */
  64196. static readonly UV3Kind: string;
  64197. /**
  64198. * Texture coordinates 4
  64199. */
  64200. static readonly UV4Kind: string;
  64201. /**
  64202. * Texture coordinates 5
  64203. */
  64204. static readonly UV5Kind: string;
  64205. /**
  64206. * Texture coordinates 6
  64207. */
  64208. static readonly UV6Kind: string;
  64209. /**
  64210. * Colors
  64211. */
  64212. static readonly ColorKind: string;
  64213. /**
  64214. * Matrix indices (for bones)
  64215. */
  64216. static readonly MatricesIndicesKind: string;
  64217. /**
  64218. * Matrix weights (for bones)
  64219. */
  64220. static readonly MatricesWeightsKind: string;
  64221. /**
  64222. * Additional matrix indices (for bones)
  64223. */
  64224. static readonly MatricesIndicesExtraKind: string;
  64225. /**
  64226. * Additional matrix weights (for bones)
  64227. */
  64228. static readonly MatricesWeightsExtraKind: string;
  64229. /**
  64230. * Deduces the stride given a kind.
  64231. * @param kind The kind string to deduce
  64232. * @returns The deduced stride
  64233. */
  64234. static DeduceStride(kind: string): number;
  64235. /**
  64236. * Gets the byte length of the given type.
  64237. * @param type the type
  64238. * @returns the number of bytes
  64239. */
  64240. static GetTypeByteLength(type: number): number;
  64241. /**
  64242. * Enumerates each value of the given parameters as numbers.
  64243. * @param data the data to enumerate
  64244. * @param byteOffset the byte offset of the data
  64245. * @param byteStride the byte stride of the data
  64246. * @param componentCount the number of components per element
  64247. * @param componentType the type of the component
  64248. * @param count the total number of components
  64249. * @param normalized whether the data is normalized
  64250. * @param callback the callback function called for each value
  64251. */
  64252. static ForEach(data: DataArray, byteOffset: number, byteStride: number, componentCount: number, componentType: number, count: number, normalized: boolean, callback: (value: number, index: number) => void): void;
  64253. private static _GetFloatValue;
  64254. }
  64255. }
  64256. declare module BABYLON {
  64257. /**
  64258. * Class representing spherical polynomial coefficients to the 3rd degree
  64259. */
  64260. export class SphericalPolynomial {
  64261. /**
  64262. * The x coefficients of the spherical polynomial
  64263. */
  64264. x: Vector3;
  64265. /**
  64266. * The y coefficients of the spherical polynomial
  64267. */
  64268. y: Vector3;
  64269. /**
  64270. * The z coefficients of the spherical polynomial
  64271. */
  64272. z: Vector3;
  64273. /**
  64274. * The xx coefficients of the spherical polynomial
  64275. */
  64276. xx: Vector3;
  64277. /**
  64278. * The yy coefficients of the spherical polynomial
  64279. */
  64280. yy: Vector3;
  64281. /**
  64282. * The zz coefficients of the spherical polynomial
  64283. */
  64284. zz: Vector3;
  64285. /**
  64286. * The xy coefficients of the spherical polynomial
  64287. */
  64288. xy: Vector3;
  64289. /**
  64290. * The yz coefficients of the spherical polynomial
  64291. */
  64292. yz: Vector3;
  64293. /**
  64294. * The zx coefficients of the spherical polynomial
  64295. */
  64296. zx: Vector3;
  64297. /**
  64298. * Adds an ambient color to the spherical polynomial
  64299. * @param color the color to add
  64300. */
  64301. addAmbient(color: Color3): void;
  64302. /**
  64303. * Scales the spherical polynomial by the given amount
  64304. * @param scale the amount to scale
  64305. */
  64306. scale(scale: number): void;
  64307. /**
  64308. * Gets the spherical polynomial from harmonics
  64309. * @param harmonics the spherical harmonics
  64310. * @returns the spherical polynomial
  64311. */
  64312. static FromHarmonics(harmonics: SphericalHarmonics): SphericalPolynomial;
  64313. /**
  64314. * Constructs a spherical polynomial from an array.
  64315. * @param data defines the 9x3 coefficients (x, y, z, xx, yy, zz, yz, zx, xy)
  64316. * @returns the spherical polynomial
  64317. */
  64318. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalPolynomial;
  64319. }
  64320. /**
  64321. * Class representing spherical harmonics coefficients to the 3rd degree
  64322. */
  64323. export class SphericalHarmonics {
  64324. /**
  64325. * The l0,0 coefficients of the spherical harmonics
  64326. */
  64327. l00: Vector3;
  64328. /**
  64329. * The l1,-1 coefficients of the spherical harmonics
  64330. */
  64331. l1_1: Vector3;
  64332. /**
  64333. * The l1,0 coefficients of the spherical harmonics
  64334. */
  64335. l10: Vector3;
  64336. /**
  64337. * The l1,1 coefficients of the spherical harmonics
  64338. */
  64339. l11: Vector3;
  64340. /**
  64341. * The l2,-2 coefficients of the spherical harmonics
  64342. */
  64343. l2_2: Vector3;
  64344. /**
  64345. * The l2,-1 coefficients of the spherical harmonics
  64346. */
  64347. l2_1: Vector3;
  64348. /**
  64349. * The l2,0 coefficients of the spherical harmonics
  64350. */
  64351. l20: Vector3;
  64352. /**
  64353. * The l2,1 coefficients of the spherical harmonics
  64354. */
  64355. l21: Vector3;
  64356. /**
  64357. * The l2,2 coefficients of the spherical harmonics
  64358. */
  64359. lL22: Vector3;
  64360. /**
  64361. * Adds a light to the spherical harmonics
  64362. * @param direction the direction of the light
  64363. * @param color the color of the light
  64364. * @param deltaSolidAngle the delta solid angle of the light
  64365. */
  64366. addLight(direction: Vector3, color: Color3, deltaSolidAngle: number): void;
  64367. /**
  64368. * Scales the spherical harmonics by the given amount
  64369. * @param scale the amount to scale
  64370. */
  64371. scale(scale: number): void;
  64372. /**
  64373. * Convert from incident radiance (Li) to irradiance (E) by applying convolution with the cosine-weighted hemisphere.
  64374. *
  64375. * ```
  64376. * E_lm = A_l * L_lm
  64377. * ```
  64378. *
  64379. * In spherical harmonics this convolution amounts to scaling factors for each frequency band.
  64380. * This corresponds to equation 5 in "An Efficient Representation for Irradiance Environment Maps", where
  64381. * the scaling factors are given in equation 9.
  64382. */
  64383. convertIncidentRadianceToIrradiance(): void;
  64384. /**
  64385. * Convert from irradiance to outgoing radiance for Lambertian BDRF, suitable for efficient shader evaluation.
  64386. *
  64387. * ```
  64388. * L = (1/pi) * E * rho
  64389. * ```
  64390. *
  64391. * This is done by an additional scale by 1/pi, so is a fairly trivial operation but important conceptually.
  64392. */
  64393. convertIrradianceToLambertianRadiance(): void;
  64394. /**
  64395. * Gets the spherical harmonics from polynomial
  64396. * @param polynomial the spherical polynomial
  64397. * @returns the spherical harmonics
  64398. */
  64399. static FromPolynomial(polynomial: SphericalPolynomial): SphericalHarmonics;
  64400. /**
  64401. * Constructs a spherical harmonics from an array.
  64402. * @param data defines the 9x3 coefficients (l00, l1-1, l10, l11, l2-2, l2-1, l20, l21, l22)
  64403. * @returns the spherical harmonics
  64404. */
  64405. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalHarmonics;
  64406. }
  64407. }
  64408. declare module BABYLON {
  64409. /**
  64410. * CubeMap information grouping all the data for each faces as well as the cubemap size.
  64411. */
  64412. export interface CubeMapInfo {
  64413. /**
  64414. * The pixel array for the front face.
  64415. * This is stored in format, left to right, up to down format.
  64416. */
  64417. front: Nullable<ArrayBufferView>;
  64418. /**
  64419. * The pixel array for the back face.
  64420. * This is stored in format, left to right, up to down format.
  64421. */
  64422. back: Nullable<ArrayBufferView>;
  64423. /**
  64424. * The pixel array for the left face.
  64425. * This is stored in format, left to right, up to down format.
  64426. */
  64427. left: Nullable<ArrayBufferView>;
  64428. /**
  64429. * The pixel array for the right face.
  64430. * This is stored in format, left to right, up to down format.
  64431. */
  64432. right: Nullable<ArrayBufferView>;
  64433. /**
  64434. * The pixel array for the up face.
  64435. * This is stored in format, left to right, up to down format.
  64436. */
  64437. up: Nullable<ArrayBufferView>;
  64438. /**
  64439. * The pixel array for the down face.
  64440. * This is stored in format, left to right, up to down format.
  64441. */
  64442. down: Nullable<ArrayBufferView>;
  64443. /**
  64444. * The size of the cubemap stored.
  64445. *
  64446. * Each faces will be size * size pixels.
  64447. */
  64448. size: number;
  64449. /**
  64450. * The format of the texture.
  64451. *
  64452. * RGBA, RGB.
  64453. */
  64454. format: number;
  64455. /**
  64456. * The type of the texture data.
  64457. *
  64458. * UNSIGNED_INT, FLOAT.
  64459. */
  64460. type: number;
  64461. /**
  64462. * Specifies whether the texture is in gamma space.
  64463. */
  64464. gammaSpace: boolean;
  64465. }
  64466. /**
  64467. * Helper class useful to convert panorama picture to their cubemap representation in 6 faces.
  64468. */
  64469. export class PanoramaToCubeMapTools {
  64470. private static FACE_FRONT;
  64471. private static FACE_BACK;
  64472. private static FACE_RIGHT;
  64473. private static FACE_LEFT;
  64474. private static FACE_DOWN;
  64475. private static FACE_UP;
  64476. /**
  64477. * Converts a panorma stored in RGB right to left up to down format into a cubemap (6 faces).
  64478. *
  64479. * @param float32Array The source data.
  64480. * @param inputWidth The width of the input panorama.
  64481. * @param inputHeight The height of the input panorama.
  64482. * @param size The willing size of the generated cubemap (each faces will be size * size pixels)
  64483. * @return The cubemap data
  64484. */
  64485. static ConvertPanoramaToCubemap(float32Array: Float32Array, inputWidth: number, inputHeight: number, size: number): CubeMapInfo;
  64486. private static CreateCubemapTexture;
  64487. private static CalcProjectionSpherical;
  64488. }
  64489. }
  64490. declare module BABYLON {
  64491. /**
  64492. * Helper class dealing with the extraction of spherical polynomial dataArray
  64493. * from a cube map.
  64494. */
  64495. export class CubeMapToSphericalPolynomialTools {
  64496. private static FileFaces;
  64497. /**
  64498. * Converts a texture to the according Spherical Polynomial data.
  64499. * This extracts the first 3 orders only as they are the only one used in the lighting.
  64500. *
  64501. * @param texture The texture to extract the information from.
  64502. * @return The Spherical Polynomial data.
  64503. */
  64504. static ConvertCubeMapTextureToSphericalPolynomial(texture: BaseTexture): SphericalPolynomial | null;
  64505. /**
  64506. * Converts a cubemap to the according Spherical Polynomial data.
  64507. * This extracts the first 3 orders only as they are the only one used in the lighting.
  64508. *
  64509. * @param cubeInfo The Cube map to extract the information from.
  64510. * @return The Spherical Polynomial data.
  64511. */
  64512. static ConvertCubeMapToSphericalPolynomial(cubeInfo: CubeMapInfo): SphericalPolynomial;
  64513. }
  64514. }
  64515. declare module BABYLON {
  64516. /**
  64517. * The engine store class is responsible to hold all the instances of Engine and Scene created
  64518. * during the life time of the application.
  64519. */
  64520. export class EngineStore {
  64521. /** Gets the list of created engines */
  64522. static Instances: Engine[];
  64523. /**
  64524. * Gets the latest created engine
  64525. */
  64526. static readonly LastCreatedEngine: Nullable<Engine>;
  64527. /**
  64528. * Gets the latest created scene
  64529. */
  64530. static readonly LastCreatedScene: Nullable<Scene>;
  64531. }
  64532. }
  64533. declare module BABYLON {
  64534. /**
  64535. * Define options used to create a render target texture
  64536. */
  64537. export class RenderTargetCreationOptions {
  64538. /**
  64539. * Specifies is mipmaps must be generated
  64540. */
  64541. generateMipMaps?: boolean;
  64542. /** Specifies whether or not a depth should be allocated in the texture (true by default) */
  64543. generateDepthBuffer?: boolean;
  64544. /** Specifies whether or not a stencil should be allocated in the texture (false by default)*/
  64545. generateStencilBuffer?: boolean;
  64546. /** Defines texture type (int by default) */
  64547. type?: number;
  64548. /** Defines sampling mode (trilinear by default) */
  64549. samplingMode?: number;
  64550. /** Defines format (RGBA by default) */
  64551. format?: number;
  64552. }
  64553. }
  64554. declare module BABYLON {
  64555. /**
  64556. * @hidden
  64557. **/
  64558. export class _AlphaState {
  64559. private _isAlphaBlendDirty;
  64560. private _isBlendFunctionParametersDirty;
  64561. private _isBlendEquationParametersDirty;
  64562. private _isBlendConstantsDirty;
  64563. private _alphaBlend;
  64564. private _blendFunctionParameters;
  64565. private _blendEquationParameters;
  64566. private _blendConstants;
  64567. /**
  64568. * Initializes the state.
  64569. */
  64570. constructor();
  64571. readonly isDirty: boolean;
  64572. alphaBlend: boolean;
  64573. setAlphaBlendConstants(r: number, g: number, b: number, a: number): void;
  64574. setAlphaBlendFunctionParameters(value0: number, value1: number, value2: number, value3: number): void;
  64575. setAlphaEquationParameters(rgb: number, alpha: number): void;
  64576. reset(): void;
  64577. apply(gl: WebGLRenderingContext): void;
  64578. }
  64579. }
  64580. declare module BABYLON {
  64581. /**
  64582. * @hidden
  64583. **/
  64584. export class _DepthCullingState {
  64585. private _isDepthTestDirty;
  64586. private _isDepthMaskDirty;
  64587. private _isDepthFuncDirty;
  64588. private _isCullFaceDirty;
  64589. private _isCullDirty;
  64590. private _isZOffsetDirty;
  64591. private _isFrontFaceDirty;
  64592. private _depthTest;
  64593. private _depthMask;
  64594. private _depthFunc;
  64595. private _cull;
  64596. private _cullFace;
  64597. private _zOffset;
  64598. private _frontFace;
  64599. /**
  64600. * Initializes the state.
  64601. */
  64602. constructor();
  64603. readonly isDirty: boolean;
  64604. zOffset: number;
  64605. cullFace: Nullable<number>;
  64606. cull: Nullable<boolean>;
  64607. depthFunc: Nullable<number>;
  64608. depthMask: boolean;
  64609. depthTest: boolean;
  64610. frontFace: Nullable<number>;
  64611. reset(): void;
  64612. apply(gl: WebGLRenderingContext): void;
  64613. }
  64614. }
  64615. declare module BABYLON {
  64616. /**
  64617. * @hidden
  64618. **/
  64619. export class _StencilState {
  64620. /** 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 */
  64621. static readonly ALWAYS: number;
  64622. /** Passed to stencilOperation to specify that stencil value must be kept */
  64623. static readonly KEEP: number;
  64624. /** Passed to stencilOperation to specify that stencil value must be replaced */
  64625. static readonly REPLACE: number;
  64626. private _isStencilTestDirty;
  64627. private _isStencilMaskDirty;
  64628. private _isStencilFuncDirty;
  64629. private _isStencilOpDirty;
  64630. private _stencilTest;
  64631. private _stencilMask;
  64632. private _stencilFunc;
  64633. private _stencilFuncRef;
  64634. private _stencilFuncMask;
  64635. private _stencilOpStencilFail;
  64636. private _stencilOpDepthFail;
  64637. private _stencilOpStencilDepthPass;
  64638. readonly isDirty: boolean;
  64639. stencilFunc: number;
  64640. stencilFuncRef: number;
  64641. stencilFuncMask: number;
  64642. stencilOpStencilFail: number;
  64643. stencilOpDepthFail: number;
  64644. stencilOpStencilDepthPass: number;
  64645. stencilMask: number;
  64646. stencilTest: boolean;
  64647. constructor();
  64648. reset(): void;
  64649. apply(gl: WebGLRenderingContext): void;
  64650. }
  64651. }
  64652. declare module BABYLON {
  64653. /**
  64654. * @hidden
  64655. **/
  64656. export class _TimeToken {
  64657. _startTimeQuery: Nullable<WebGLQuery>;
  64658. _endTimeQuery: Nullable<WebGLQuery>;
  64659. _timeElapsedQuery: Nullable<WebGLQuery>;
  64660. _timeElapsedQueryEnded: boolean;
  64661. }
  64662. }
  64663. declare module BABYLON {
  64664. /**
  64665. * Internal interface used to track InternalTexture already bound to the GL context
  64666. */
  64667. export interface IInternalTextureTracker {
  64668. /**
  64669. * Gets or set the previous tracker in the list
  64670. */
  64671. previous: Nullable<IInternalTextureTracker>;
  64672. /**
  64673. * Gets or set the next tracker in the list
  64674. */
  64675. next: Nullable<IInternalTextureTracker>;
  64676. }
  64677. /**
  64678. * Internal class used by the engine to get list of InternalTexture already bound to the GL context
  64679. */
  64680. export class DummyInternalTextureTracker {
  64681. /**
  64682. * Gets or set the previous tracker in the list
  64683. */
  64684. previous: Nullable<IInternalTextureTracker>;
  64685. /**
  64686. * Gets or set the next tracker in the list
  64687. */
  64688. next: Nullable<IInternalTextureTracker>;
  64689. }
  64690. }
  64691. declare module BABYLON {
  64692. /**
  64693. * Class used to store data associated with WebGL texture data for the engine
  64694. * This class should not be used directly
  64695. */
  64696. export class InternalTexture implements IInternalTextureTracker {
  64697. /** hidden */
  64698. static _UpdateRGBDAsync: (internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: SphericalPolynomial | null, lodScale: number, lodOffset: number) => Promise<void>;
  64699. /**
  64700. * The source of the texture data is unknown
  64701. */
  64702. static DATASOURCE_UNKNOWN: number;
  64703. /**
  64704. * Texture data comes from an URL
  64705. */
  64706. static DATASOURCE_URL: number;
  64707. /**
  64708. * Texture data is only used for temporary storage
  64709. */
  64710. static DATASOURCE_TEMP: number;
  64711. /**
  64712. * Texture data comes from raw data (ArrayBuffer)
  64713. */
  64714. static DATASOURCE_RAW: number;
  64715. /**
  64716. * Texture content is dynamic (video or dynamic texture)
  64717. */
  64718. static DATASOURCE_DYNAMIC: number;
  64719. /**
  64720. * Texture content is generated by rendering to it
  64721. */
  64722. static DATASOURCE_RENDERTARGET: number;
  64723. /**
  64724. * Texture content is part of a multi render target process
  64725. */
  64726. static DATASOURCE_MULTIRENDERTARGET: number;
  64727. /**
  64728. * Texture data comes from a cube data file
  64729. */
  64730. static DATASOURCE_CUBE: number;
  64731. /**
  64732. * Texture data comes from a raw cube data
  64733. */
  64734. static DATASOURCE_CUBERAW: number;
  64735. /**
  64736. * Texture data come from a prefiltered cube data file
  64737. */
  64738. static DATASOURCE_CUBEPREFILTERED: number;
  64739. /**
  64740. * Texture content is raw 3D data
  64741. */
  64742. static DATASOURCE_RAW3D: number;
  64743. /**
  64744. * Texture content is a depth texture
  64745. */
  64746. static DATASOURCE_DEPTHTEXTURE: number;
  64747. /**
  64748. * Texture data comes from a raw cube data encoded with RGBD
  64749. */
  64750. static DATASOURCE_CUBERAW_RGBD: number;
  64751. /**
  64752. * Defines if the texture is ready
  64753. */
  64754. isReady: boolean;
  64755. /**
  64756. * Defines if the texture is a cube texture
  64757. */
  64758. isCube: boolean;
  64759. /**
  64760. * Defines if the texture contains 3D data
  64761. */
  64762. is3D: boolean;
  64763. /**
  64764. * Gets the URL used to load this texture
  64765. */
  64766. url: string;
  64767. /**
  64768. * Gets the sampling mode of the texture
  64769. */
  64770. samplingMode: number;
  64771. /**
  64772. * Gets a boolean indicating if the texture needs mipmaps generation
  64773. */
  64774. generateMipMaps: boolean;
  64775. /**
  64776. * Gets the number of samples used by the texture (WebGL2+ only)
  64777. */
  64778. samples: number;
  64779. /**
  64780. * Gets the type of the texture (int, float...)
  64781. */
  64782. type: number;
  64783. /**
  64784. * Gets the format of the texture (RGB, RGBA...)
  64785. */
  64786. format: number;
  64787. /**
  64788. * Observable called when the texture is loaded
  64789. */
  64790. onLoadedObservable: Observable<InternalTexture>;
  64791. /**
  64792. * Gets the width of the texture
  64793. */
  64794. width: number;
  64795. /**
  64796. * Gets the height of the texture
  64797. */
  64798. height: number;
  64799. /**
  64800. * Gets the depth of the texture
  64801. */
  64802. depth: number;
  64803. /**
  64804. * Gets the initial width of the texture (It could be rescaled if the current system does not support non power of two textures)
  64805. */
  64806. baseWidth: number;
  64807. /**
  64808. * Gets the initial height of the texture (It could be rescaled if the current system does not support non power of two textures)
  64809. */
  64810. baseHeight: number;
  64811. /**
  64812. * Gets the initial depth of the texture (It could be rescaled if the current system does not support non power of two textures)
  64813. */
  64814. baseDepth: number;
  64815. /**
  64816. * Gets a boolean indicating if the texture is inverted on Y axis
  64817. */
  64818. invertY: boolean;
  64819. /**
  64820. * Gets or set the previous tracker in the list
  64821. */
  64822. previous: Nullable<IInternalTextureTracker>;
  64823. /**
  64824. * Gets or set the next tracker in the list
  64825. */
  64826. next: Nullable<IInternalTextureTracker>;
  64827. /** @hidden */
  64828. _invertVScale: boolean;
  64829. /** @hidden */
  64830. _initialSlot: number;
  64831. /** @hidden */
  64832. _designatedSlot: number;
  64833. /** @hidden */
  64834. _dataSource: number;
  64835. /** @hidden */
  64836. _buffer: Nullable<string | ArrayBuffer | HTMLImageElement | Blob>;
  64837. /** @hidden */
  64838. _bufferView: Nullable<ArrayBufferView>;
  64839. /** @hidden */
  64840. _bufferViewArray: Nullable<ArrayBufferView[]>;
  64841. /** @hidden */
  64842. _bufferViewArrayArray: Nullable<ArrayBufferView[][]>;
  64843. /** @hidden */
  64844. _size: number;
  64845. /** @hidden */
  64846. _extension: string;
  64847. /** @hidden */
  64848. _files: Nullable<string[]>;
  64849. /** @hidden */
  64850. _workingCanvas: HTMLCanvasElement;
  64851. /** @hidden */
  64852. _workingContext: CanvasRenderingContext2D;
  64853. /** @hidden */
  64854. _framebuffer: Nullable<WebGLFramebuffer>;
  64855. /** @hidden */
  64856. _depthStencilBuffer: Nullable<WebGLRenderbuffer>;
  64857. /** @hidden */
  64858. _MSAAFramebuffer: Nullable<WebGLFramebuffer>;
  64859. /** @hidden */
  64860. _MSAARenderBuffer: Nullable<WebGLRenderbuffer>;
  64861. /** @hidden */
  64862. _attachments: Nullable<number[]>;
  64863. /** @hidden */
  64864. _cachedCoordinatesMode: Nullable<number>;
  64865. /** @hidden */
  64866. _cachedWrapU: Nullable<number>;
  64867. /** @hidden */
  64868. _cachedWrapV: Nullable<number>;
  64869. /** @hidden */
  64870. _cachedWrapR: Nullable<number>;
  64871. /** @hidden */
  64872. _cachedAnisotropicFilteringLevel: Nullable<number>;
  64873. /** @hidden */
  64874. _isDisabled: boolean;
  64875. /** @hidden */
  64876. _compression: Nullable<string>;
  64877. /** @hidden */
  64878. _generateStencilBuffer: boolean;
  64879. /** @hidden */
  64880. _generateDepthBuffer: boolean;
  64881. /** @hidden */
  64882. _comparisonFunction: number;
  64883. /** @hidden */
  64884. _sphericalPolynomial: Nullable<SphericalPolynomial>;
  64885. /** @hidden */
  64886. _lodGenerationScale: number;
  64887. /** @hidden */
  64888. _lodGenerationOffset: number;
  64889. /** @hidden */
  64890. _lodTextureHigh: BaseTexture;
  64891. /** @hidden */
  64892. _lodTextureMid: BaseTexture;
  64893. /** @hidden */
  64894. _lodTextureLow: BaseTexture;
  64895. /** @hidden */
  64896. _isRGBD: boolean;
  64897. /** @hidden */
  64898. _webGLTexture: Nullable<WebGLTexture>;
  64899. /** @hidden */
  64900. _references: number;
  64901. private _engine;
  64902. /**
  64903. * Gets the Engine the texture belongs to.
  64904. * @returns The babylon engine
  64905. */
  64906. getEngine(): Engine;
  64907. /**
  64908. * Gets the data source type of the texture (can be one of the InternalTexture.DATASOURCE_XXXX)
  64909. */
  64910. readonly dataSource: number;
  64911. /**
  64912. * Creates a new InternalTexture
  64913. * @param engine defines the engine to use
  64914. * @param dataSource defines the type of data that will be used
  64915. * @param delayAllocation if the texture allocation should be delayed (default: false)
  64916. */
  64917. constructor(engine: Engine, dataSource: number, delayAllocation?: boolean);
  64918. /**
  64919. * Increments the number of references (ie. the number of Texture that point to it)
  64920. */
  64921. incrementReferences(): void;
  64922. /**
  64923. * Change the size of the texture (not the size of the content)
  64924. * @param width defines the new width
  64925. * @param height defines the new height
  64926. * @param depth defines the new depth (1 by default)
  64927. */
  64928. updateSize(width: int, height: int, depth?: int): void;
  64929. /** @hidden */
  64930. _rebuild(): void;
  64931. /** @hidden */
  64932. _swapAndDie(target: InternalTexture): void;
  64933. /**
  64934. * Dispose the current allocated resources
  64935. */
  64936. dispose(): void;
  64937. }
  64938. }
  64939. declare module BABYLON {
  64940. /**
  64941. * This represents the main contract an easing function should follow.
  64942. * Easing functions are used throughout the animation system.
  64943. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  64944. */
  64945. export interface IEasingFunction {
  64946. /**
  64947. * Given an input gradient between 0 and 1, this returns the corrseponding value
  64948. * of the easing function.
  64949. * The link below provides some of the most common examples of easing functions.
  64950. * @see https://easings.net/
  64951. * @param gradient Defines the value between 0 and 1 we want the easing value for
  64952. * @returns the corresponding value on the curve defined by the easing function
  64953. */
  64954. ease(gradient: number): number;
  64955. }
  64956. /**
  64957. * Base class used for every default easing function.
  64958. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  64959. */
  64960. export class EasingFunction implements IEasingFunction {
  64961. /**
  64962. * Interpolation follows the mathematical formula associated with the easing function.
  64963. */
  64964. static readonly EASINGMODE_EASEIN: number;
  64965. /**
  64966. * Interpolation follows 100% interpolation minus the output of the formula associated with the easing function.
  64967. */
  64968. static readonly EASINGMODE_EASEOUT: number;
  64969. /**
  64970. * Interpolation uses EaseIn for the first half of the animation and EaseOut for the second half.
  64971. */
  64972. static readonly EASINGMODE_EASEINOUT: number;
  64973. private _easingMode;
  64974. /**
  64975. * Sets the easing mode of the current function.
  64976. * @param easingMode Defines the willing mode (EASINGMODE_EASEIN, EASINGMODE_EASEOUT or EASINGMODE_EASEINOUT)
  64977. */
  64978. setEasingMode(easingMode: number): void;
  64979. /**
  64980. * Gets the current easing mode.
  64981. * @returns the easing mode
  64982. */
  64983. getEasingMode(): number;
  64984. /**
  64985. * @hidden
  64986. */
  64987. easeInCore(gradient: number): number;
  64988. /**
  64989. * Given an input gradient between 0 and 1, this returns the corrseponding value
  64990. * of the easing function.
  64991. * @param gradient Defines the value between 0 and 1 we want the easing value for
  64992. * @returns the corresponding value on the curve defined by the easing function
  64993. */
  64994. ease(gradient: number): number;
  64995. }
  64996. /**
  64997. * Easing function with a circle shape (see link below).
  64998. * @see https://easings.net/#easeInCirc
  64999. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  65000. */
  65001. export class CircleEase extends EasingFunction implements IEasingFunction {
  65002. /** @hidden */
  65003. easeInCore(gradient: number): number;
  65004. }
  65005. /**
  65006. * Easing function with a ease back shape (see link below).
  65007. * @see https://easings.net/#easeInBack
  65008. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  65009. */
  65010. export class BackEase extends EasingFunction implements IEasingFunction {
  65011. /** Defines the amplitude of the function */
  65012. amplitude: number;
  65013. /**
  65014. * Instantiates a back ease easing
  65015. * @see https://easings.net/#easeInBack
  65016. * @param amplitude Defines the amplitude of the function
  65017. */
  65018. constructor(
  65019. /** Defines the amplitude of the function */
  65020. amplitude?: number);
  65021. /** @hidden */
  65022. easeInCore(gradient: number): number;
  65023. }
  65024. /**
  65025. * Easing function with a bouncing shape (see link below).
  65026. * @see https://easings.net/#easeInBounce
  65027. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  65028. */
  65029. export class BounceEase extends EasingFunction implements IEasingFunction {
  65030. /** Defines the number of bounces */
  65031. bounces: number;
  65032. /** Defines the amplitude of the bounce */
  65033. bounciness: number;
  65034. /**
  65035. * Instantiates a bounce easing
  65036. * @see https://easings.net/#easeInBounce
  65037. * @param bounces Defines the number of bounces
  65038. * @param bounciness Defines the amplitude of the bounce
  65039. */
  65040. constructor(
  65041. /** Defines the number of bounces */
  65042. bounces?: number,
  65043. /** Defines the amplitude of the bounce */
  65044. bounciness?: number);
  65045. /** @hidden */
  65046. easeInCore(gradient: number): number;
  65047. }
  65048. /**
  65049. * Easing function with a power of 3 shape (see link below).
  65050. * @see https://easings.net/#easeInCubic
  65051. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  65052. */
  65053. export class CubicEase extends EasingFunction implements IEasingFunction {
  65054. /** @hidden */
  65055. easeInCore(gradient: number): number;
  65056. }
  65057. /**
  65058. * Easing function with an elastic shape (see link below).
  65059. * @see https://easings.net/#easeInElastic
  65060. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  65061. */
  65062. export class ElasticEase extends EasingFunction implements IEasingFunction {
  65063. /** Defines the number of oscillations*/
  65064. oscillations: number;
  65065. /** Defines the amplitude of the oscillations*/
  65066. springiness: number;
  65067. /**
  65068. * Instantiates an elastic easing function
  65069. * @see https://easings.net/#easeInElastic
  65070. * @param oscillations Defines the number of oscillations
  65071. * @param springiness Defines the amplitude of the oscillations
  65072. */
  65073. constructor(
  65074. /** Defines the number of oscillations*/
  65075. oscillations?: number,
  65076. /** Defines the amplitude of the oscillations*/
  65077. springiness?: number);
  65078. /** @hidden */
  65079. easeInCore(gradient: number): number;
  65080. }
  65081. /**
  65082. * Easing function with an exponential shape (see link below).
  65083. * @see https://easings.net/#easeInExpo
  65084. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  65085. */
  65086. export class ExponentialEase extends EasingFunction implements IEasingFunction {
  65087. /** Defines the exponent of the function */
  65088. exponent: number;
  65089. /**
  65090. * Instantiates an exponential easing function
  65091. * @see https://easings.net/#easeInExpo
  65092. * @param exponent Defines the exponent of the function
  65093. */
  65094. constructor(
  65095. /** Defines the exponent of the function */
  65096. exponent?: number);
  65097. /** @hidden */
  65098. easeInCore(gradient: number): number;
  65099. }
  65100. /**
  65101. * Easing function with a power shape (see link below).
  65102. * @see https://easings.net/#easeInQuad
  65103. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  65104. */
  65105. export class PowerEase extends EasingFunction implements IEasingFunction {
  65106. /** Defines the power of the function */
  65107. power: number;
  65108. /**
  65109. * Instantiates an power base easing function
  65110. * @see https://easings.net/#easeInQuad
  65111. * @param power Defines the power of the function
  65112. */
  65113. constructor(
  65114. /** Defines the power of the function */
  65115. power?: number);
  65116. /** @hidden */
  65117. easeInCore(gradient: number): number;
  65118. }
  65119. /**
  65120. * Easing function with a power of 2 shape (see link below).
  65121. * @see https://easings.net/#easeInQuad
  65122. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  65123. */
  65124. export class QuadraticEase extends EasingFunction implements IEasingFunction {
  65125. /** @hidden */
  65126. easeInCore(gradient: number): number;
  65127. }
  65128. /**
  65129. * Easing function with a power of 4 shape (see link below).
  65130. * @see https://easings.net/#easeInQuart
  65131. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  65132. */
  65133. export class QuarticEase extends EasingFunction implements IEasingFunction {
  65134. /** @hidden */
  65135. easeInCore(gradient: number): number;
  65136. }
  65137. /**
  65138. * Easing function with a power of 5 shape (see link below).
  65139. * @see https://easings.net/#easeInQuint
  65140. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  65141. */
  65142. export class QuinticEase extends EasingFunction implements IEasingFunction {
  65143. /** @hidden */
  65144. easeInCore(gradient: number): number;
  65145. }
  65146. /**
  65147. * Easing function with a sin shape (see link below).
  65148. * @see https://easings.net/#easeInSine
  65149. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  65150. */
  65151. export class SineEase extends EasingFunction implements IEasingFunction {
  65152. /** @hidden */
  65153. easeInCore(gradient: number): number;
  65154. }
  65155. /**
  65156. * Easing function with a bezier shape (see link below).
  65157. * @see http://cubic-bezier.com/#.17,.67,.83,.67
  65158. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  65159. */
  65160. export class BezierCurveEase extends EasingFunction implements IEasingFunction {
  65161. /** Defines the x component of the start tangent in the bezier curve */
  65162. x1: number;
  65163. /** Defines the y component of the start tangent in the bezier curve */
  65164. y1: number;
  65165. /** Defines the x component of the end tangent in the bezier curve */
  65166. x2: number;
  65167. /** Defines the y component of the end tangent in the bezier curve */
  65168. y2: number;
  65169. /**
  65170. * Instantiates a bezier function
  65171. * @see http://cubic-bezier.com/#.17,.67,.83,.67
  65172. * @param x1 Defines the x component of the start tangent in the bezier curve
  65173. * @param y1 Defines the y component of the start tangent in the bezier curve
  65174. * @param x2 Defines the x component of the end tangent in the bezier curve
  65175. * @param y2 Defines the y component of the end tangent in the bezier curve
  65176. */
  65177. constructor(
  65178. /** Defines the x component of the start tangent in the bezier curve */
  65179. x1?: number,
  65180. /** Defines the y component of the start tangent in the bezier curve */
  65181. y1?: number,
  65182. /** Defines the x component of the end tangent in the bezier curve */
  65183. x2?: number,
  65184. /** Defines the y component of the end tangent in the bezier curve */
  65185. y2?: number);
  65186. /** @hidden */
  65187. easeInCore(gradient: number): number;
  65188. }
  65189. }
  65190. declare module BABYLON {
  65191. /**
  65192. * Defines an interface which represents an animation key frame
  65193. */
  65194. export interface IAnimationKey {
  65195. /**
  65196. * Frame of the key frame
  65197. */
  65198. frame: number;
  65199. /**
  65200. * Value at the specifies key frame
  65201. */
  65202. value: any;
  65203. /**
  65204. * The input tangent for the cubic hermite spline
  65205. */
  65206. inTangent?: any;
  65207. /**
  65208. * The output tangent for the cubic hermite spline
  65209. */
  65210. outTangent?: any;
  65211. /**
  65212. * The animation interpolation type
  65213. */
  65214. interpolation?: AnimationKeyInterpolation;
  65215. }
  65216. /**
  65217. * Enum for the animation key frame interpolation type
  65218. */
  65219. export enum AnimationKeyInterpolation {
  65220. /**
  65221. * Do not interpolate between keys and use the start key value only. Tangents are ignored
  65222. */
  65223. STEP = 1
  65224. }
  65225. }
  65226. declare module BABYLON {
  65227. /**
  65228. * Represents the range of an animation
  65229. */
  65230. export class AnimationRange {
  65231. /**The name of the animation range**/
  65232. name: string;
  65233. /**The starting frame of the animation */
  65234. from: number;
  65235. /**The ending frame of the animation*/
  65236. to: number;
  65237. /**
  65238. * Initializes the range of an animation
  65239. * @param name The name of the animation range
  65240. * @param from The starting frame of the animation
  65241. * @param to The ending frame of the animation
  65242. */
  65243. constructor(
  65244. /**The name of the animation range**/
  65245. name: string,
  65246. /**The starting frame of the animation */
  65247. from: number,
  65248. /**The ending frame of the animation*/
  65249. to: number);
  65250. /**
  65251. * Makes a copy of the animation range
  65252. * @returns A copy of the animation range
  65253. */
  65254. clone(): AnimationRange;
  65255. }
  65256. }
  65257. declare module BABYLON {
  65258. /**
  65259. * Composed of a frame, and an action function
  65260. */
  65261. export class AnimationEvent {
  65262. /** The frame for which the event is triggered **/
  65263. frame: number;
  65264. /** The event to perform when triggered **/
  65265. action: (currentFrame: number) => void;
  65266. /** Specifies if the event should be triggered only once**/
  65267. onlyOnce?: boolean | undefined;
  65268. /**
  65269. * Specifies if the animation event is done
  65270. */
  65271. isDone: boolean;
  65272. /**
  65273. * Initializes the animation event
  65274. * @param frame The frame for which the event is triggered
  65275. * @param action The event to perform when triggered
  65276. * @param onlyOnce Specifies if the event should be triggered only once
  65277. */
  65278. constructor(
  65279. /** The frame for which the event is triggered **/
  65280. frame: number,
  65281. /** The event to perform when triggered **/
  65282. action: (currentFrame: number) => void,
  65283. /** Specifies if the event should be triggered only once**/
  65284. onlyOnce?: boolean | undefined);
  65285. /** @hidden */
  65286. _clone(): AnimationEvent;
  65287. }
  65288. }
  65289. declare module BABYLON {
  65290. /**
  65291. * Interface used to define a behavior
  65292. */
  65293. export interface Behavior<T> {
  65294. /** gets or sets behavior's name */
  65295. name: string;
  65296. /**
  65297. * Function called when the behavior needs to be initialized (after attaching it to a target)
  65298. */
  65299. init(): void;
  65300. /**
  65301. * Called when the behavior is attached to a target
  65302. * @param target defines the target where the behavior is attached to
  65303. */
  65304. attach(target: T): void;
  65305. /**
  65306. * Called when the behavior is detached from its target
  65307. */
  65308. detach(): void;
  65309. }
  65310. /**
  65311. * Interface implemented by classes supporting behaviors
  65312. */
  65313. export interface IBehaviorAware<T> {
  65314. /**
  65315. * Attach a behavior
  65316. * @param behavior defines the behavior to attach
  65317. * @returns the current host
  65318. */
  65319. addBehavior(behavior: Behavior<T>): T;
  65320. /**
  65321. * Remove a behavior from the current object
  65322. * @param behavior defines the behavior to detach
  65323. * @returns the current host
  65324. */
  65325. removeBehavior(behavior: Behavior<T>): T;
  65326. /**
  65327. * Gets a behavior using its name to search
  65328. * @param name defines the name to search
  65329. * @returns the behavior or null if not found
  65330. */
  65331. getBehaviorByName(name: string): Nullable<Behavior<T>>;
  65332. }
  65333. }
  65334. declare module BABYLON {
  65335. /**
  65336. * @hidden
  65337. */
  65338. export class IntersectionInfo {
  65339. bu: Nullable<number>;
  65340. bv: Nullable<number>;
  65341. distance: number;
  65342. faceId: number;
  65343. subMeshId: number;
  65344. constructor(bu: Nullable<number>, bv: Nullable<number>, distance: number);
  65345. }
  65346. }
  65347. declare module BABYLON {
  65348. /**
  65349. * Class used to store bounding sphere information
  65350. */
  65351. export class BoundingSphere {
  65352. /**
  65353. * Gets the center of the bounding sphere in local space
  65354. */
  65355. readonly center: Vector3;
  65356. /**
  65357. * Radius of the bounding sphere in local space
  65358. */
  65359. radius: number;
  65360. /**
  65361. * Gets the center of the bounding sphere in world space
  65362. */
  65363. readonly centerWorld: Vector3;
  65364. /**
  65365. * Radius of the bounding sphere in world space
  65366. */
  65367. radiusWorld: number;
  65368. /**
  65369. * Gets the minimum vector in local space
  65370. */
  65371. readonly minimum: Vector3;
  65372. /**
  65373. * Gets the maximum vector in local space
  65374. */
  65375. readonly maximum: Vector3;
  65376. private _worldMatrix;
  65377. private static readonly TmpVector3;
  65378. /**
  65379. * Creates a new bounding sphere
  65380. * @param min defines the minimum vector (in local space)
  65381. * @param max defines the maximum vector (in local space)
  65382. * @param worldMatrix defines the new world matrix
  65383. */
  65384. constructor(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  65385. /**
  65386. * Recreates the entire bounding sphere from scratch as if we call the constructor in place
  65387. * @param min defines the new minimum vector (in local space)
  65388. * @param max defines the new maximum vector (in local space)
  65389. * @param worldMatrix defines the new world matrix
  65390. */
  65391. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  65392. /**
  65393. * Scale the current bounding sphere by applying a scale factor
  65394. * @param factor defines the scale factor to apply
  65395. * @returns the current bounding box
  65396. */
  65397. scale(factor: number): BoundingSphere;
  65398. /**
  65399. * Gets the world matrix of the bounding box
  65400. * @returns a matrix
  65401. */
  65402. getWorldMatrix(): DeepImmutable<Matrix>;
  65403. /** @hidden */
  65404. _update(worldMatrix: DeepImmutable<Matrix>): void;
  65405. /**
  65406. * Tests if the bounding sphere is intersecting the frustum planes
  65407. * @param frustumPlanes defines the frustum planes to test
  65408. * @returns true if there is an intersection
  65409. */
  65410. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  65411. /**
  65412. * Tests if the bounding sphere center is in between the frustum planes.
  65413. * Used for optimistic fast inclusion.
  65414. * @param frustumPlanes defines the frustum planes to test
  65415. * @returns true if the sphere center is in between the frustum planes
  65416. */
  65417. isCenterInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  65418. /**
  65419. * Tests if a point is inside the bounding sphere
  65420. * @param point defines the point to test
  65421. * @returns true if the point is inside the bounding sphere
  65422. */
  65423. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  65424. /**
  65425. * Checks if two sphere intersct
  65426. * @param sphere0 sphere 0
  65427. * @param sphere1 sphere 1
  65428. * @returns true if the speres intersect
  65429. */
  65430. static Intersects(sphere0: DeepImmutable<BoundingSphere>, sphere1: DeepImmutable<BoundingSphere>): boolean;
  65431. }
  65432. }
  65433. declare module BABYLON {
  65434. /**
  65435. * Class used to store bounding box information
  65436. */
  65437. export class BoundingBox implements ICullable {
  65438. /**
  65439. * Gets the 8 vectors representing the bounding box in local space
  65440. */
  65441. readonly vectors: Vector3[];
  65442. /**
  65443. * Gets the center of the bounding box in local space
  65444. */
  65445. readonly center: Vector3;
  65446. /**
  65447. * Gets the center of the bounding box in world space
  65448. */
  65449. readonly centerWorld: Vector3;
  65450. /**
  65451. * Gets the extend size in local space
  65452. */
  65453. readonly extendSize: Vector3;
  65454. /**
  65455. * Gets the extend size in world space
  65456. */
  65457. readonly extendSizeWorld: Vector3;
  65458. /**
  65459. * Gets the OBB (object bounding box) directions
  65460. */
  65461. readonly directions: Vector3[];
  65462. /**
  65463. * Gets the 8 vectors representing the bounding box in world space
  65464. */
  65465. readonly vectorsWorld: Vector3[];
  65466. /**
  65467. * Gets the minimum vector in world space
  65468. */
  65469. readonly minimumWorld: Vector3;
  65470. /**
  65471. * Gets the maximum vector in world space
  65472. */
  65473. readonly maximumWorld: Vector3;
  65474. /**
  65475. * Gets the minimum vector in local space
  65476. */
  65477. readonly minimum: Vector3;
  65478. /**
  65479. * Gets the maximum vector in local space
  65480. */
  65481. readonly maximum: Vector3;
  65482. private _worldMatrix;
  65483. private static readonly TmpVector3;
  65484. /**
  65485. * @hidden
  65486. */
  65487. _tag: number;
  65488. /**
  65489. * Creates a new bounding box
  65490. * @param min defines the minimum vector (in local space)
  65491. * @param max defines the maximum vector (in local space)
  65492. * @param worldMatrix defines the new world matrix
  65493. */
  65494. constructor(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  65495. /**
  65496. * Recreates the entire bounding box from scratch as if we call the constructor in place
  65497. * @param min defines the new minimum vector (in local space)
  65498. * @param max defines the new maximum vector (in local space)
  65499. * @param worldMatrix defines the new world matrix
  65500. */
  65501. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  65502. /**
  65503. * Scale the current bounding box by applying a scale factor
  65504. * @param factor defines the scale factor to apply
  65505. * @returns the current bounding box
  65506. */
  65507. scale(factor: number): BoundingBox;
  65508. /**
  65509. * Gets the world matrix of the bounding box
  65510. * @returns a matrix
  65511. */
  65512. getWorldMatrix(): DeepImmutable<Matrix>;
  65513. /** @hidden */
  65514. _update(world: DeepImmutable<Matrix>): void;
  65515. /**
  65516. * Tests if the bounding box is intersecting the frustum planes
  65517. * @param frustumPlanes defines the frustum planes to test
  65518. * @returns true if there is an intersection
  65519. */
  65520. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  65521. /**
  65522. * Tests if the bounding box is entirely inside the frustum planes
  65523. * @param frustumPlanes defines the frustum planes to test
  65524. * @returns true if there is an inclusion
  65525. */
  65526. isCompletelyInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  65527. /**
  65528. * Tests if a point is inside the bounding box
  65529. * @param point defines the point to test
  65530. * @returns true if the point is inside the bounding box
  65531. */
  65532. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  65533. /**
  65534. * Tests if the bounding box intersects with a bounding sphere
  65535. * @param sphere defines the sphere to test
  65536. * @returns true if there is an intersection
  65537. */
  65538. intersectsSphere(sphere: DeepImmutable<BoundingSphere>): boolean;
  65539. /**
  65540. * Tests if the bounding box intersects with a box defined by a min and max vectors
  65541. * @param min defines the min vector to use
  65542. * @param max defines the max vector to use
  65543. * @returns true if there is an intersection
  65544. */
  65545. intersectsMinMax(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>): boolean;
  65546. /**
  65547. * Tests if two bounding boxes are intersections
  65548. * @param box0 defines the first box to test
  65549. * @param box1 defines the second box to test
  65550. * @returns true if there is an intersection
  65551. */
  65552. static Intersects(box0: DeepImmutable<BoundingBox>, box1: DeepImmutable<BoundingBox>): boolean;
  65553. /**
  65554. * Tests if a bounding box defines by a min/max vectors intersects a sphere
  65555. * @param minPoint defines the minimum vector of the bounding box
  65556. * @param maxPoint defines the maximum vector of the bounding box
  65557. * @param sphereCenter defines the sphere center
  65558. * @param sphereRadius defines the sphere radius
  65559. * @returns true if there is an intersection
  65560. */
  65561. static IntersectsSphere(minPoint: DeepImmutable<Vector3>, maxPoint: DeepImmutable<Vector3>, sphereCenter: DeepImmutable<Vector3>, sphereRadius: number): boolean;
  65562. /**
  65563. * Tests if a bounding box defined with 8 vectors is entirely inside frustum planes
  65564. * @param boundingVectors defines an array of 8 vectors representing a bounding box
  65565. * @param frustumPlanes defines the frustum planes to test
  65566. * @return true if there is an inclusion
  65567. */
  65568. static IsCompletelyInFrustum(boundingVectors: Array<DeepImmutable<Vector3>>, frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  65569. /**
  65570. * Tests if a bounding box defined with 8 vectors intersects frustum planes
  65571. * @param boundingVectors defines an array of 8 vectors representing a bounding box
  65572. * @param frustumPlanes defines the frustum planes to test
  65573. * @return true if there is an intersection
  65574. */
  65575. static IsInFrustum(boundingVectors: Array<DeepImmutable<Vector3>>, frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  65576. }
  65577. }
  65578. declare module BABYLON {
  65579. /** @hidden */
  65580. export class Collider {
  65581. /** Define if a collision was found */
  65582. collisionFound: boolean;
  65583. /**
  65584. * Define last intersection point in local space
  65585. */
  65586. intersectionPoint: Vector3;
  65587. /**
  65588. * Define last collided mesh
  65589. */
  65590. collidedMesh: Nullable<AbstractMesh>;
  65591. private _collisionPoint;
  65592. private _planeIntersectionPoint;
  65593. private _tempVector;
  65594. private _tempVector2;
  65595. private _tempVector3;
  65596. private _tempVector4;
  65597. private _edge;
  65598. private _baseToVertex;
  65599. private _destinationPoint;
  65600. private _slidePlaneNormal;
  65601. private _displacementVector;
  65602. /** @hidden */
  65603. _radius: Vector3;
  65604. /** @hidden */
  65605. _retry: number;
  65606. private _velocity;
  65607. private _basePoint;
  65608. private _epsilon;
  65609. /** @hidden */
  65610. _velocityWorldLength: number;
  65611. /** @hidden */
  65612. _basePointWorld: Vector3;
  65613. private _velocityWorld;
  65614. private _normalizedVelocity;
  65615. /** @hidden */
  65616. _initialVelocity: Vector3;
  65617. /** @hidden */
  65618. _initialPosition: Vector3;
  65619. private _nearestDistance;
  65620. private _collisionMask;
  65621. collisionMask: number;
  65622. /**
  65623. * Gets the plane normal used to compute the sliding response (in local space)
  65624. */
  65625. readonly slidePlaneNormal: Vector3;
  65626. /** @hidden */
  65627. _initialize(source: Vector3, dir: Vector3, e: number): void;
  65628. /** @hidden */
  65629. _checkPointInTriangle(point: Vector3, pa: Vector3, pb: Vector3, pc: Vector3, n: Vector3): boolean;
  65630. /** @hidden */
  65631. _canDoCollision(sphereCenter: Vector3, sphereRadius: number, vecMin: Vector3, vecMax: Vector3): boolean;
  65632. /** @hidden */
  65633. _testTriangle(faceIndex: number, trianglePlaneArray: Array<Plane>, p1: Vector3, p2: Vector3, p3: Vector3, hasMaterial: boolean): void;
  65634. /** @hidden */
  65635. _collide(trianglePlaneArray: Array<Plane>, pts: Vector3[], indices: IndicesArray, indexStart: number, indexEnd: number, decal: number, hasMaterial: boolean): void;
  65636. /** @hidden */
  65637. _getResponse(pos: Vector3, vel: Vector3): void;
  65638. }
  65639. }
  65640. declare module BABYLON {
  65641. /**
  65642. * Interface for cullable objects
  65643. * @see https://doc.babylonjs.com/babylon101/materials#back-face-culling
  65644. */
  65645. export interface ICullable {
  65646. /**
  65647. * Checks if the object or part of the object is in the frustum
  65648. * @param frustumPlanes Camera near/planes
  65649. * @returns true if the object is in frustum otherwise false
  65650. */
  65651. isInFrustum(frustumPlanes: Plane[]): boolean;
  65652. /**
  65653. * Checks if a cullable object (mesh...) is in the camera frustum
  65654. * Unlike isInFrustum this cheks the full bounding box
  65655. * @param frustumPlanes Camera near/planes
  65656. * @returns true if the object is in frustum otherwise false
  65657. */
  65658. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  65659. }
  65660. /**
  65661. * Info for a bounding data of a mesh
  65662. */
  65663. export class BoundingInfo implements ICullable {
  65664. /**
  65665. * Bounding box for the mesh
  65666. */
  65667. readonly boundingBox: BoundingBox;
  65668. /**
  65669. * Bounding sphere for the mesh
  65670. */
  65671. readonly boundingSphere: BoundingSphere;
  65672. private _isLocked;
  65673. private static readonly TmpVector3;
  65674. /**
  65675. * Constructs bounding info
  65676. * @param minimum min vector of the bounding box/sphere
  65677. * @param maximum max vector of the bounding box/sphere
  65678. * @param worldMatrix defines the new world matrix
  65679. */
  65680. constructor(minimum: DeepImmutable<Vector3>, maximum: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  65681. /**
  65682. * Recreates the entire bounding info from scratch as if we call the constructor in place
  65683. * @param min defines the new minimum vector (in local space)
  65684. * @param max defines the new maximum vector (in local space)
  65685. * @param worldMatrix defines the new world matrix
  65686. */
  65687. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  65688. /**
  65689. * min vector of the bounding box/sphere
  65690. */
  65691. readonly minimum: Vector3;
  65692. /**
  65693. * max vector of the bounding box/sphere
  65694. */
  65695. readonly maximum: Vector3;
  65696. /**
  65697. * If the info is locked and won't be updated to avoid perf overhead
  65698. */
  65699. isLocked: boolean;
  65700. /**
  65701. * Updates the bounding sphere and box
  65702. * @param world world matrix to be used to update
  65703. */
  65704. update(world: DeepImmutable<Matrix>): void;
  65705. /**
  65706. * Recreate the bounding info to be centered around a specific point given a specific extend.
  65707. * @param center New center of the bounding info
  65708. * @param extend New extend of the bounding info
  65709. * @returns the current bounding info
  65710. */
  65711. centerOn(center: DeepImmutable<Vector3>, extend: DeepImmutable<Vector3>): BoundingInfo;
  65712. /**
  65713. * Scale the current bounding info by applying a scale factor
  65714. * @param factor defines the scale factor to apply
  65715. * @returns the current bounding info
  65716. */
  65717. scale(factor: number): BoundingInfo;
  65718. /**
  65719. * Returns `true` if the bounding info is within the frustum defined by the passed array of planes.
  65720. * @param frustumPlanes defines the frustum to test
  65721. * @param strategy defines the strategy to use for the culling (default is BABYLON.AbstractMesh.CULLINGSTRATEGY_STANDARD)
  65722. * @returns true if the bounding info is in the frustum planes
  65723. */
  65724. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>, strategy?: number): boolean;
  65725. /**
  65726. * Gets the world distance between the min and max points of the bounding box
  65727. */
  65728. readonly diagonalLength: number;
  65729. /**
  65730. * Checks if a cullable object (mesh...) is in the camera frustum
  65731. * Unlike isInFrustum this cheks the full bounding box
  65732. * @param frustumPlanes Camera near/planes
  65733. * @returns true if the object is in frustum otherwise false
  65734. */
  65735. isCompletelyInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  65736. /** @hidden */
  65737. _checkCollision(collider: Collider): boolean;
  65738. /**
  65739. * Checks if a point is inside the bounding box and bounding sphere or the mesh
  65740. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  65741. * @param point the point to check intersection with
  65742. * @returns if the point intersects
  65743. */
  65744. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  65745. /**
  65746. * Checks if another bounding info intersects the bounding box and bounding sphere or the mesh
  65747. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  65748. * @param boundingInfo the bounding info to check intersection with
  65749. * @param precise if the intersection should be done using OBB
  65750. * @returns if the bounding info intersects
  65751. */
  65752. intersects(boundingInfo: DeepImmutable<BoundingInfo>, precise: boolean): boolean;
  65753. }
  65754. }
  65755. declare module BABYLON {
  65756. /**
  65757. * Defines an array and its length.
  65758. * It can be helpfull to group result from both Arrays and smart arrays in one structure.
  65759. */
  65760. export interface ISmartArrayLike<T> {
  65761. /**
  65762. * The data of the array.
  65763. */
  65764. data: Array<T>;
  65765. /**
  65766. * The active length of the array.
  65767. */
  65768. length: number;
  65769. }
  65770. /**
  65771. * Defines an GC Friendly array where the backfield array do not shrink to prevent over allocations.
  65772. */
  65773. export class SmartArray<T> implements ISmartArrayLike<T> {
  65774. /**
  65775. * The full set of data from the array.
  65776. */
  65777. data: Array<T>;
  65778. /**
  65779. * The active length of the array.
  65780. */
  65781. length: number;
  65782. protected _id: number;
  65783. /**
  65784. * Instantiates a Smart Array.
  65785. * @param capacity defines the default capacity of the array.
  65786. */
  65787. constructor(capacity: number);
  65788. /**
  65789. * Pushes a value at the end of the active data.
  65790. * @param value defines the object to push in the array.
  65791. */
  65792. push(value: T): void;
  65793. /**
  65794. * Iterates over the active data and apply the lambda to them.
  65795. * @param func defines the action to apply on each value.
  65796. */
  65797. forEach(func: (content: T) => void): void;
  65798. /**
  65799. * Sorts the full sets of data.
  65800. * @param compareFn defines the comparison function to apply.
  65801. */
  65802. sort(compareFn: (a: T, b: T) => number): void;
  65803. /**
  65804. * Resets the active data to an empty array.
  65805. */
  65806. reset(): void;
  65807. /**
  65808. * Releases all the data from the array as well as the array.
  65809. */
  65810. dispose(): void;
  65811. /**
  65812. * Concats the active data with a given array.
  65813. * @param array defines the data to concatenate with.
  65814. */
  65815. concat(array: any): void;
  65816. /**
  65817. * Returns the position of a value in the active data.
  65818. * @param value defines the value to find the index for
  65819. * @returns the index if found in the active data otherwise -1
  65820. */
  65821. indexOf(value: T): number;
  65822. /**
  65823. * Returns whether an element is part of the active data.
  65824. * @param value defines the value to look for
  65825. * @returns true if found in the active data otherwise false
  65826. */
  65827. contains(value: T): boolean;
  65828. private static _GlobalId;
  65829. }
  65830. /**
  65831. * Defines an GC Friendly array where the backfield array do not shrink to prevent over allocations.
  65832. * The data in this array can only be present once
  65833. */
  65834. export class SmartArrayNoDuplicate<T> extends SmartArray<T> {
  65835. private _duplicateId;
  65836. /**
  65837. * Pushes a value at the end of the active data.
  65838. * THIS DOES NOT PREVENT DUPPLICATE DATA
  65839. * @param value defines the object to push in the array.
  65840. */
  65841. push(value: T): void;
  65842. /**
  65843. * Pushes a value at the end of the active data.
  65844. * If the data is already present, it won t be added again
  65845. * @param value defines the object to push in the array.
  65846. * @returns true if added false if it was already present
  65847. */
  65848. pushNoDuplicate(value: T): boolean;
  65849. /**
  65850. * Resets the active data to an empty array.
  65851. */
  65852. reset(): void;
  65853. /**
  65854. * Concats the active data with a given array.
  65855. * This ensures no dupplicate will be present in the result.
  65856. * @param array defines the data to concatenate with.
  65857. */
  65858. concatWithNoDuplicate(array: any): void;
  65859. }
  65860. }
  65861. declare module BABYLON {
  65862. /**
  65863. * A multi-material is used to apply different materials to different parts of the same object without the need of
  65864. * separate meshes. This can be use to improve performances.
  65865. * @see http://doc.babylonjs.com/how_to/multi_materials
  65866. */
  65867. export class MultiMaterial extends Material {
  65868. private _subMaterials;
  65869. /**
  65870. * Gets or Sets the list of Materials used within the multi material.
  65871. * They need to be ordered according to the submeshes order in the associated mesh
  65872. */
  65873. subMaterials: Nullable<Material>[];
  65874. /**
  65875. * Function used to align with Node.getChildren()
  65876. * @returns the list of Materials used within the multi material
  65877. */
  65878. getChildren(): Nullable<Material>[];
  65879. /**
  65880. * Instantiates a new Multi Material
  65881. * A multi-material is used to apply different materials to different parts of the same object without the need of
  65882. * separate meshes. This can be use to improve performances.
  65883. * @see http://doc.babylonjs.com/how_to/multi_materials
  65884. * @param name Define the name in the scene
  65885. * @param scene Define the scene the material belongs to
  65886. */
  65887. constructor(name: string, scene: Scene);
  65888. private _hookArray;
  65889. /**
  65890. * Get one of the submaterial by its index in the submaterials array
  65891. * @param index The index to look the sub material at
  65892. * @returns The Material if the index has been defined
  65893. */
  65894. getSubMaterial(index: number): Nullable<Material>;
  65895. /**
  65896. * Get the list of active textures for the whole sub materials list.
  65897. * @returns All the textures that will be used during the rendering
  65898. */
  65899. getActiveTextures(): BaseTexture[];
  65900. /**
  65901. * Gets the current class name of the material e.g. "MultiMaterial"
  65902. * Mainly use in serialization.
  65903. * @returns the class name
  65904. */
  65905. getClassName(): string;
  65906. /**
  65907. * Checks if the material is ready to render the requested sub mesh
  65908. * @param mesh Define the mesh the submesh belongs to
  65909. * @param subMesh Define the sub mesh to look readyness for
  65910. * @param useInstances Define whether or not the material is used with instances
  65911. * @returns true if ready, otherwise false
  65912. */
  65913. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  65914. /**
  65915. * Clones the current material and its related sub materials
  65916. * @param name Define the name of the newly cloned material
  65917. * @param cloneChildren Define if submaterial will be cloned or shared with the parent instance
  65918. * @returns the cloned material
  65919. */
  65920. clone(name: string, cloneChildren?: boolean): MultiMaterial;
  65921. /**
  65922. * Serializes the materials into a JSON representation.
  65923. * @returns the JSON representation
  65924. */
  65925. serialize(): any;
  65926. /**
  65927. * Dispose the material and release its associated resources
  65928. * @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)
  65929. * @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)
  65930. * @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)
  65931. */
  65932. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, forceDisposeChildren?: boolean): void;
  65933. /**
  65934. * Creates a MultiMaterial from parsed MultiMaterial data.
  65935. * @param parsedMultiMaterial defines parsed MultiMaterial data.
  65936. * @param scene defines the hosting scene
  65937. * @returns a new MultiMaterial
  65938. */
  65939. static ParseMultiMaterial(parsedMultiMaterial: any, scene: Scene): MultiMaterial;
  65940. }
  65941. }
  65942. declare module BABYLON {
  65943. /**
  65944. * Class used to represent data loading progression
  65945. */
  65946. export class SceneLoaderFlags {
  65947. private static _ForceFullSceneLoadingForIncremental;
  65948. private static _ShowLoadingScreen;
  65949. private static _CleanBoneMatrixWeights;
  65950. private static _loggingLevel;
  65951. /**
  65952. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  65953. */
  65954. static ForceFullSceneLoadingForIncremental: boolean;
  65955. /**
  65956. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  65957. */
  65958. static ShowLoadingScreen: boolean;
  65959. /**
  65960. * Defines the current logging level (while loading the scene)
  65961. * @ignorenaming
  65962. */
  65963. static loggingLevel: number;
  65964. /**
  65965. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  65966. */
  65967. static CleanBoneMatrixWeights: boolean;
  65968. }
  65969. }
  65970. declare module BABYLON {
  65971. /**
  65972. * 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.
  65973. * @see https://doc.babylonjs.com/how_to/transformnode
  65974. */
  65975. export class TransformNode extends Node {
  65976. /**
  65977. * Object will not rotate to face the camera
  65978. */
  65979. static BILLBOARDMODE_NONE: number;
  65980. /**
  65981. * Object will rotate to face the camera but only on the x axis
  65982. */
  65983. static BILLBOARDMODE_X: number;
  65984. /**
  65985. * Object will rotate to face the camera but only on the y axis
  65986. */
  65987. static BILLBOARDMODE_Y: number;
  65988. /**
  65989. * Object will rotate to face the camera but only on the z axis
  65990. */
  65991. static BILLBOARDMODE_Z: number;
  65992. /**
  65993. * Object will rotate to face the camera
  65994. */
  65995. static BILLBOARDMODE_ALL: number;
  65996. private _forward;
  65997. private _forwardInverted;
  65998. private _up;
  65999. private _right;
  66000. private _rightInverted;
  66001. private _position;
  66002. private _rotation;
  66003. private _rotationQuaternion;
  66004. protected _scaling: Vector3;
  66005. protected _isDirty: boolean;
  66006. private _transformToBoneReferal;
  66007. /**
  66008. * Set the billboard mode. Default is 0.
  66009. *
  66010. * | Value | Type | Description |
  66011. * | --- | --- | --- |
  66012. * | 0 | BILLBOARDMODE_NONE | |
  66013. * | 1 | BILLBOARDMODE_X | |
  66014. * | 2 | BILLBOARDMODE_Y | |
  66015. * | 4 | BILLBOARDMODE_Z | |
  66016. * | 7 | BILLBOARDMODE_ALL | |
  66017. *
  66018. */
  66019. billboardMode: number;
  66020. /**
  66021. * 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
  66022. */
  66023. scalingDeterminant: number;
  66024. /**
  66025. * Sets the distance of the object to max, often used by skybox
  66026. */
  66027. infiniteDistance: boolean;
  66028. /**
  66029. * Gets or sets a boolean indicating that non uniform scaling (when at least one component is different from others) should be ignored.
  66030. * By default the system will update normals to compensate
  66031. */
  66032. ignoreNonUniformScaling: boolean;
  66033. /** @hidden */
  66034. _poseMatrix: Matrix;
  66035. /** @hidden */
  66036. _localMatrix: Matrix;
  66037. private _absolutePosition;
  66038. private _pivotMatrix;
  66039. private _pivotMatrixInverse;
  66040. protected _postMultiplyPivotMatrix: boolean;
  66041. private _tempMatrix;
  66042. private _tempMatrix2;
  66043. protected _isWorldMatrixFrozen: boolean;
  66044. /** @hidden */
  66045. _indexInSceneTransformNodesArray: number;
  66046. /**
  66047. * An event triggered after the world matrix is updated
  66048. */
  66049. onAfterWorldMatrixUpdateObservable: Observable<TransformNode>;
  66050. constructor(name: string, scene?: Nullable<Scene>, isPure?: boolean);
  66051. /**
  66052. * Gets a string identifying the name of the class
  66053. * @returns "TransformNode" string
  66054. */
  66055. getClassName(): string;
  66056. /**
  66057. * Gets or set the node position (default is (0.0, 0.0, 0.0))
  66058. */
  66059. position: Vector3;
  66060. /**
  66061. * 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)).
  66062. * If rotation quaternion is set, this Vector3 will be ignored and copy from the quaternion
  66063. */
  66064. rotation: Vector3;
  66065. /**
  66066. * 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)).
  66067. */
  66068. scaling: Vector3;
  66069. /**
  66070. * 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).
  66071. * If set, only the rotationQuaternion is then used to compute the node rotation (ie. node.rotation will be ignored)
  66072. */
  66073. rotationQuaternion: Nullable<Quaternion>;
  66074. /**
  66075. * The forward direction of that transform in world space.
  66076. */
  66077. readonly forward: Vector3;
  66078. /**
  66079. * The up direction of that transform in world space.
  66080. */
  66081. readonly up: Vector3;
  66082. /**
  66083. * The right direction of that transform in world space.
  66084. */
  66085. readonly right: Vector3;
  66086. /**
  66087. * Copies the parameter passed Matrix into the mesh Pose matrix.
  66088. * @param matrix the matrix to copy the pose from
  66089. * @returns this TransformNode.
  66090. */
  66091. updatePoseMatrix(matrix: Matrix): TransformNode;
  66092. /**
  66093. * Returns the mesh Pose matrix.
  66094. * @returns the pose matrix
  66095. */
  66096. getPoseMatrix(): Matrix;
  66097. /** @hidden */
  66098. _isSynchronized(): boolean;
  66099. /** @hidden */
  66100. _initCache(): void;
  66101. /**
  66102. * Flag the transform node as dirty (Forcing it to update everything)
  66103. * @param property if set to "rotation" the objects rotationQuaternion will be set to null
  66104. * @returns this transform node
  66105. */
  66106. markAsDirty(property: string): TransformNode;
  66107. /**
  66108. * Returns the current mesh absolute position.
  66109. * Returns a Vector3.
  66110. */
  66111. readonly absolutePosition: Vector3;
  66112. /**
  66113. * Sets a new matrix to apply before all other transformation
  66114. * @param matrix defines the transform matrix
  66115. * @returns the current TransformNode
  66116. */
  66117. setPreTransformMatrix(matrix: Matrix): TransformNode;
  66118. /**
  66119. * Sets a new pivot matrix to the current node
  66120. * @param matrix defines the new pivot matrix to use
  66121. * @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
  66122. * @returns the current TransformNode
  66123. */
  66124. setPivotMatrix(matrix: DeepImmutable<Matrix>, postMultiplyPivotMatrix?: boolean): TransformNode;
  66125. /**
  66126. * Returns the mesh pivot matrix.
  66127. * Default : Identity.
  66128. * @returns the matrix
  66129. */
  66130. getPivotMatrix(): Matrix;
  66131. /**
  66132. * Prevents the World matrix to be computed any longer.
  66133. * @returns the TransformNode.
  66134. */
  66135. freezeWorldMatrix(): TransformNode;
  66136. /**
  66137. * Allows back the World matrix computation.
  66138. * @returns the TransformNode.
  66139. */
  66140. unfreezeWorldMatrix(): this;
  66141. /**
  66142. * True if the World matrix has been frozen.
  66143. */
  66144. readonly isWorldMatrixFrozen: boolean;
  66145. /**
  66146. * Retuns the mesh absolute position in the World.
  66147. * @returns a Vector3.
  66148. */
  66149. getAbsolutePosition(): Vector3;
  66150. /**
  66151. * Sets the mesh absolute position in the World from a Vector3 or an Array(3).
  66152. * @param absolutePosition the absolute position to set
  66153. * @returns the TransformNode.
  66154. */
  66155. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  66156. /**
  66157. * Sets the mesh position in its local space.
  66158. * @param vector3 the position to set in localspace
  66159. * @returns the TransformNode.
  66160. */
  66161. setPositionWithLocalVector(vector3: Vector3): TransformNode;
  66162. /**
  66163. * Returns the mesh position in the local space from the current World matrix values.
  66164. * @returns a new Vector3.
  66165. */
  66166. getPositionExpressedInLocalSpace(): Vector3;
  66167. /**
  66168. * Translates the mesh along the passed Vector3 in its local space.
  66169. * @param vector3 the distance to translate in localspace
  66170. * @returns the TransformNode.
  66171. */
  66172. locallyTranslate(vector3: Vector3): TransformNode;
  66173. private static _lookAtVectorCache;
  66174. /**
  66175. * Orients a mesh towards a target point. Mesh must be drawn facing user.
  66176. * @param targetPoint the position (must be in same space as current mesh) to look at
  66177. * @param yawCor optional yaw (y-axis) correction in radians
  66178. * @param pitchCor optional pitch (x-axis) correction in radians
  66179. * @param rollCor optional roll (z-axis) correction in radians
  66180. * @param space the choosen space of the target
  66181. * @returns the TransformNode.
  66182. */
  66183. lookAt(targetPoint: Vector3, yawCor?: number, pitchCor?: number, rollCor?: number, space?: Space): TransformNode;
  66184. /**
  66185. * Returns a new Vector3 that is the localAxis, expressed in the mesh local space, rotated like the mesh.
  66186. * This Vector3 is expressed in the World space.
  66187. * @param localAxis axis to rotate
  66188. * @returns a new Vector3 that is the localAxis, expressed in the mesh local space, rotated like the mesh.
  66189. */
  66190. getDirection(localAxis: Vector3): Vector3;
  66191. /**
  66192. * Sets the Vector3 "result" as the rotated Vector3 "localAxis" in the same rotation than the mesh.
  66193. * localAxis is expressed in the mesh local space.
  66194. * result is computed in the Wordl space from the mesh World matrix.
  66195. * @param localAxis axis to rotate
  66196. * @param result the resulting transformnode
  66197. * @returns this TransformNode.
  66198. */
  66199. getDirectionToRef(localAxis: Vector3, result: Vector3): TransformNode;
  66200. /**
  66201. * Sets this transform node rotation to the given local axis.
  66202. * @param localAxis the axis in local space
  66203. * @param yawCor optional yaw (y-axis) correction in radians
  66204. * @param pitchCor optional pitch (x-axis) correction in radians
  66205. * @param rollCor optional roll (z-axis) correction in radians
  66206. * @returns this TransformNode
  66207. */
  66208. setDirection(localAxis: Vector3, yawCor?: number, pitchCor?: number, rollCor?: number): TransformNode;
  66209. /**
  66210. * Sets a new pivot point to the current node
  66211. * @param point defines the new pivot point to use
  66212. * @param space defines if the point is in world or local space (local by default)
  66213. * @returns the current TransformNode
  66214. */
  66215. setPivotPoint(point: Vector3, space?: Space): TransformNode;
  66216. /**
  66217. * Returns a new Vector3 set with the mesh pivot point coordinates in the local space.
  66218. * @returns the pivot point
  66219. */
  66220. getPivotPoint(): Vector3;
  66221. /**
  66222. * Sets the passed Vector3 "result" with the coordinates of the mesh pivot point in the local space.
  66223. * @param result the vector3 to store the result
  66224. * @returns this TransformNode.
  66225. */
  66226. getPivotPointToRef(result: Vector3): TransformNode;
  66227. /**
  66228. * Returns a new Vector3 set with the mesh pivot point World coordinates.
  66229. * @returns a new Vector3 set with the mesh pivot point World coordinates.
  66230. */
  66231. getAbsolutePivotPoint(): Vector3;
  66232. /**
  66233. * Sets the Vector3 "result" coordinates with the mesh pivot point World coordinates.
  66234. * @param result vector3 to store the result
  66235. * @returns this TransformNode.
  66236. */
  66237. getAbsolutePivotPointToRef(result: Vector3): TransformNode;
  66238. /**
  66239. * Defines the passed node as the parent of the current node.
  66240. * The node will remain exactly where it is and its position / rotation will be updated accordingly
  66241. * @see https://doc.babylonjs.com/how_to/parenting
  66242. * @param node the node ot set as the parent
  66243. * @returns this TransformNode.
  66244. */
  66245. setParent(node: Nullable<Node>): TransformNode;
  66246. private _nonUniformScaling;
  66247. /**
  66248. * True if the scaling property of this object is non uniform eg. (1,2,1)
  66249. */
  66250. readonly nonUniformScaling: boolean;
  66251. /** @hidden */
  66252. _updateNonUniformScalingState(value: boolean): boolean;
  66253. /**
  66254. * Attach the current TransformNode to another TransformNode associated with a bone
  66255. * @param bone Bone affecting the TransformNode
  66256. * @param affectedTransformNode TransformNode associated with the bone
  66257. * @returns this object
  66258. */
  66259. attachToBone(bone: Bone, affectedTransformNode: TransformNode): TransformNode;
  66260. /**
  66261. * Detach the transform node if its associated with a bone
  66262. * @returns this object
  66263. */
  66264. detachFromBone(): TransformNode;
  66265. private static _rotationAxisCache;
  66266. /**
  66267. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in the given space.
  66268. * space (default LOCAL) can be either Space.LOCAL, either Space.WORLD.
  66269. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  66270. * The passed axis is also normalized.
  66271. * @param axis the axis to rotate around
  66272. * @param amount the amount to rotate in radians
  66273. * @param space Space to rotate in (Default: local)
  66274. * @returns the TransformNode.
  66275. */
  66276. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  66277. /**
  66278. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in world space.
  66279. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  66280. * The passed axis is also normalized. .
  66281. * Method is based on http://www.euclideanspace.com/maths/geometry/affine/aroundPoint/index.htm
  66282. * @param point the point to rotate around
  66283. * @param axis the axis to rotate around
  66284. * @param amount the amount to rotate in radians
  66285. * @returns the TransformNode
  66286. */
  66287. rotateAround(point: Vector3, axis: Vector3, amount: number): TransformNode;
  66288. /**
  66289. * Translates the mesh along the axis vector for the passed distance in the given space.
  66290. * space (default LOCAL) can be either Space.LOCAL, either Space.WORLD.
  66291. * @param axis the axis to translate in
  66292. * @param distance the distance to translate
  66293. * @param space Space to rotate in (Default: local)
  66294. * @returns the TransformNode.
  66295. */
  66296. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  66297. /**
  66298. * Adds a rotation step to the mesh current rotation.
  66299. * x, y, z are Euler angles expressed in radians.
  66300. * This methods updates the current mesh rotation, either mesh.rotation, either mesh.rotationQuaternion if it's set.
  66301. * This means this rotation is made in the mesh local space only.
  66302. * It's useful to set a custom rotation order different from the BJS standard one YXZ.
  66303. * Example : this rotates the mesh first around its local X axis, then around its local Z axis, finally around its local Y axis.
  66304. * ```javascript
  66305. * mesh.addRotation(x1, 0, 0).addRotation(0, 0, z2).addRotation(0, 0, y3);
  66306. * ```
  66307. * Note that `addRotation()` accumulates the passed rotation values to the current ones and computes the .rotation or .rotationQuaternion updated values.
  66308. * 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.
  66309. * @param x Rotation to add
  66310. * @param y Rotation to add
  66311. * @param z Rotation to add
  66312. * @returns the TransformNode.
  66313. */
  66314. addRotation(x: number, y: number, z: number): TransformNode;
  66315. /**
  66316. * Computes the world matrix of the node
  66317. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  66318. * @returns the world matrix
  66319. */
  66320. computeWorldMatrix(force?: boolean): Matrix;
  66321. protected _afterComputeWorldMatrix(): void;
  66322. /**
  66323. * If you'd like to be called back after the mesh position, rotation or scaling has been updated.
  66324. * @param func callback function to add
  66325. *
  66326. * @returns the TransformNode.
  66327. */
  66328. registerAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  66329. /**
  66330. * Removes a registered callback function.
  66331. * @param func callback function to remove
  66332. * @returns the TransformNode.
  66333. */
  66334. unregisterAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  66335. /**
  66336. * Gets the position of the current mesh in camera space
  66337. * @param camera defines the camera to use
  66338. * @returns a position
  66339. */
  66340. getPositionInCameraSpace(camera?: Nullable<Camera>): Vector3;
  66341. /**
  66342. * Returns the distance from the mesh to the active camera
  66343. * @param camera defines the camera to use
  66344. * @returns the distance
  66345. */
  66346. getDistanceToCamera(camera?: Nullable<Camera>): number;
  66347. /**
  66348. * Clone the current transform node
  66349. * @param name Name of the new clone
  66350. * @param newParent New parent for the clone
  66351. * @param doNotCloneChildren Do not clone children hierarchy
  66352. * @returns the new transform node
  66353. */
  66354. clone(name: string, newParent: Node, doNotCloneChildren?: boolean): Nullable<TransformNode>;
  66355. /**
  66356. * Serializes the objects information.
  66357. * @param currentSerializationObject defines the object to serialize in
  66358. * @returns the serialized object
  66359. */
  66360. serialize(currentSerializationObject?: any): any;
  66361. /**
  66362. * Returns a new TransformNode object parsed from the source provided.
  66363. * @param parsedTransformNode is the source.
  66364. * @param scene the scne the object belongs to
  66365. * @param rootUrl is a string, it's the root URL to prefix the `delayLoadingFile` property with
  66366. * @returns a new TransformNode object parsed from the source provided.
  66367. */
  66368. static Parse(parsedTransformNode: any, scene: Scene, rootUrl: string): TransformNode;
  66369. /**
  66370. * Get all child-transformNodes of this node
  66371. * @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
  66372. * @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
  66373. * @returns an array of TransformNode
  66374. */
  66375. getChildTransformNodes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): TransformNode[];
  66376. /**
  66377. * Releases resources associated with this transform node.
  66378. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  66379. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  66380. */
  66381. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  66382. }
  66383. }
  66384. declare module BABYLON {
  66385. /**
  66386. * Class used to override all child animations of a given target
  66387. */
  66388. export class AnimationPropertiesOverride {
  66389. /**
  66390. * Gets or sets a value indicating if animation blending must be used
  66391. */
  66392. enableBlending: boolean;
  66393. /**
  66394. * Gets or sets the blending speed to use when enableBlending is true
  66395. */
  66396. blendingSpeed: number;
  66397. /**
  66398. * Gets or sets the default loop mode to use
  66399. */
  66400. loopMode: number;
  66401. }
  66402. }
  66403. declare module BABYLON {
  66404. /**
  66405. * Class used to store bone information
  66406. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  66407. */
  66408. export class Bone extends Node {
  66409. /**
  66410. * defines the bone name
  66411. */
  66412. name: string;
  66413. private static _tmpVecs;
  66414. private static _tmpQuat;
  66415. private static _tmpMats;
  66416. /**
  66417. * Gets the list of child bones
  66418. */
  66419. children: Bone[];
  66420. /** Gets the animations associated with this bone */
  66421. animations: Animation[];
  66422. /**
  66423. * Gets or sets bone length
  66424. */
  66425. length: number;
  66426. /**
  66427. * @hidden Internal only
  66428. * Set this value to map this bone to a different index in the transform matrices
  66429. * Set this value to -1 to exclude the bone from the transform matrices
  66430. */
  66431. _index: Nullable<number>;
  66432. private _skeleton;
  66433. private _localMatrix;
  66434. private _restPose;
  66435. private _baseMatrix;
  66436. private _absoluteTransform;
  66437. private _invertedAbsoluteTransform;
  66438. private _parent;
  66439. private _scalingDeterminant;
  66440. private _worldTransform;
  66441. private _localScaling;
  66442. private _localRotation;
  66443. private _localPosition;
  66444. private _needToDecompose;
  66445. private _needToCompose;
  66446. /** @hidden */
  66447. _linkedTransformNode: Nullable<TransformNode>;
  66448. /** @hidden */
  66449. /** @hidden */
  66450. _matrix: Matrix;
  66451. /**
  66452. * Create a new bone
  66453. * @param name defines the bone name
  66454. * @param skeleton defines the parent skeleton
  66455. * @param parentBone defines the parent (can be null if the bone is the root)
  66456. * @param localMatrix defines the local matrix
  66457. * @param restPose defines the rest pose matrix
  66458. * @param baseMatrix defines the base matrix
  66459. * @param index defines index of the bone in the hiearchy
  66460. */
  66461. constructor(
  66462. /**
  66463. * defines the bone name
  66464. */
  66465. name: string, skeleton: Skeleton, parentBone?: Nullable<Bone>, localMatrix?: Nullable<Matrix>, restPose?: Nullable<Matrix>, baseMatrix?: Nullable<Matrix>, index?: Nullable<number>);
  66466. /**
  66467. * Gets the current object class name.
  66468. * @return the class name
  66469. */
  66470. getClassName(): string;
  66471. /**
  66472. * Gets the parent skeleton
  66473. * @returns a skeleton
  66474. */
  66475. getSkeleton(): Skeleton;
  66476. /**
  66477. * Gets parent bone
  66478. * @returns a bone or null if the bone is the root of the bone hierarchy
  66479. */
  66480. getParent(): Nullable<Bone>;
  66481. /**
  66482. * Returns an array containing the root bones
  66483. * @returns an array containing the root bones
  66484. */
  66485. getChildren(): Array<Bone>;
  66486. /**
  66487. * Sets the parent bone
  66488. * @param parent defines the parent (can be null if the bone is the root)
  66489. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  66490. */
  66491. setParent(parent: Nullable<Bone>, updateDifferenceMatrix?: boolean): void;
  66492. /**
  66493. * Gets the local matrix
  66494. * @returns a matrix
  66495. */
  66496. getLocalMatrix(): Matrix;
  66497. /**
  66498. * Gets the base matrix (initial matrix which remains unchanged)
  66499. * @returns a matrix
  66500. */
  66501. getBaseMatrix(): Matrix;
  66502. /**
  66503. * Gets the rest pose matrix
  66504. * @returns a matrix
  66505. */
  66506. getRestPose(): Matrix;
  66507. /**
  66508. * Gets a matrix used to store world matrix (ie. the matrix sent to shaders)
  66509. */
  66510. getWorldMatrix(): Matrix;
  66511. /**
  66512. * Sets the local matrix to rest pose matrix
  66513. */
  66514. returnToRest(): void;
  66515. /**
  66516. * Gets the inverse of the absolute transform matrix.
  66517. * This matrix will be multiplied by local matrix to get the difference matrix (ie. the difference between original state and current state)
  66518. * @returns a matrix
  66519. */
  66520. getInvertedAbsoluteTransform(): Matrix;
  66521. /**
  66522. * Gets the absolute transform matrix (ie base matrix * parent world matrix)
  66523. * @returns a matrix
  66524. */
  66525. getAbsoluteTransform(): Matrix;
  66526. /**
  66527. * Links with the given transform node.
  66528. * The local matrix of this bone is copied from the transform node every frame.
  66529. * @param transformNode defines the transform node to link to
  66530. */
  66531. linkTransformNode(transformNode: Nullable<TransformNode>): void;
  66532. /** Gets or sets current position (in local space) */
  66533. position: Vector3;
  66534. /** Gets or sets current rotation (in local space) */
  66535. rotation: Vector3;
  66536. /** Gets or sets current rotation quaternion (in local space) */
  66537. rotationQuaternion: Quaternion;
  66538. /** Gets or sets current scaling (in local space) */
  66539. scaling: Vector3;
  66540. /**
  66541. * Gets the animation properties override
  66542. */
  66543. readonly animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  66544. private _decompose;
  66545. private _compose;
  66546. /**
  66547. * Update the base and local matrices
  66548. * @param matrix defines the new base or local matrix
  66549. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  66550. * @param updateLocalMatrix defines if the local matrix should be updated
  66551. */
  66552. updateMatrix(matrix: Matrix, updateDifferenceMatrix?: boolean, updateLocalMatrix?: boolean): void;
  66553. /** @hidden */
  66554. _updateDifferenceMatrix(rootMatrix?: Matrix, updateChildren?: boolean): void;
  66555. /**
  66556. * Flag the bone as dirty (Forcing it to update everything)
  66557. */
  66558. markAsDirty(): void;
  66559. private _markAsDirtyAndCompose;
  66560. private _markAsDirtyAndDecompose;
  66561. /**
  66562. * Translate the bone in local or world space
  66563. * @param vec The amount to translate the bone
  66564. * @param space The space that the translation is in
  66565. * @param mesh The mesh that this bone is attached to. This is only used in world space
  66566. */
  66567. translate(vec: Vector3, space?: Space, mesh?: AbstractMesh): void;
  66568. /**
  66569. * Set the postion of the bone in local or world space
  66570. * @param position The position to set the bone
  66571. * @param space The space that the position is in
  66572. * @param mesh The mesh that this bone is attached to. This is only used in world space
  66573. */
  66574. setPosition(position: Vector3, space?: Space, mesh?: AbstractMesh): void;
  66575. /**
  66576. * Set the absolute position of the bone (world space)
  66577. * @param position The position to set the bone
  66578. * @param mesh The mesh that this bone is attached to
  66579. */
  66580. setAbsolutePosition(position: Vector3, mesh?: AbstractMesh): void;
  66581. /**
  66582. * Scale the bone on the x, y and z axes (in local space)
  66583. * @param x The amount to scale the bone on the x axis
  66584. * @param y The amount to scale the bone on the y axis
  66585. * @param z The amount to scale the bone on the z axis
  66586. * @param scaleChildren sets this to true if children of the bone should be scaled as well (false by default)
  66587. */
  66588. scale(x: number, y: number, z: number, scaleChildren?: boolean): void;
  66589. /**
  66590. * Set the bone scaling in local space
  66591. * @param scale defines the scaling vector
  66592. */
  66593. setScale(scale: Vector3): void;
  66594. /**
  66595. * Gets the current scaling in local space
  66596. * @returns the current scaling vector
  66597. */
  66598. getScale(): Vector3;
  66599. /**
  66600. * Gets the current scaling in local space and stores it in a target vector
  66601. * @param result defines the target vector
  66602. */
  66603. getScaleToRef(result: Vector3): void;
  66604. /**
  66605. * Set the yaw, pitch, and roll of the bone in local or world space
  66606. * @param yaw The rotation of the bone on the y axis
  66607. * @param pitch The rotation of the bone on the x axis
  66608. * @param roll The rotation of the bone on the z axis
  66609. * @param space The space that the axes of rotation are in
  66610. * @param mesh The mesh that this bone is attached to. This is only used in world space
  66611. */
  66612. setYawPitchRoll(yaw: number, pitch: number, roll: number, space?: Space, mesh?: AbstractMesh): void;
  66613. /**
  66614. * Add a rotation to the bone on an axis in local or world space
  66615. * @param axis The axis to rotate the bone on
  66616. * @param amount The amount to rotate the bone
  66617. * @param space The space that the axis is in
  66618. * @param mesh The mesh that this bone is attached to. This is only used in world space
  66619. */
  66620. rotate(axis: Vector3, amount: number, space?: Space, mesh?: AbstractMesh): void;
  66621. /**
  66622. * Set the rotation of the bone to a particular axis angle in local or world space
  66623. * @param axis The axis to rotate the bone on
  66624. * @param angle The angle that the bone should be rotated to
  66625. * @param space The space that the axis is in
  66626. * @param mesh The mesh that this bone is attached to. This is only used in world space
  66627. */
  66628. setAxisAngle(axis: Vector3, angle: number, space?: Space, mesh?: AbstractMesh): void;
  66629. /**
  66630. * Set the euler rotation of the bone in local of world space
  66631. * @param rotation The euler rotation that the bone should be set to
  66632. * @param space The space that the rotation is in
  66633. * @param mesh The mesh that this bone is attached to. This is only used in world space
  66634. */
  66635. setRotation(rotation: Vector3, space?: Space, mesh?: AbstractMesh): void;
  66636. /**
  66637. * Set the quaternion rotation of the bone in local of world space
  66638. * @param quat The quaternion rotation that the bone should be set to
  66639. * @param space The space that the rotation is in
  66640. * @param mesh The mesh that this bone is attached to. This is only used in world space
  66641. */
  66642. setRotationQuaternion(quat: Quaternion, space?: Space, mesh?: AbstractMesh): void;
  66643. /**
  66644. * Set the rotation matrix of the bone in local of world space
  66645. * @param rotMat The rotation matrix that the bone should be set to
  66646. * @param space The space that the rotation is in
  66647. * @param mesh The mesh that this bone is attached to. This is only used in world space
  66648. */
  66649. setRotationMatrix(rotMat: Matrix, space?: Space, mesh?: AbstractMesh): void;
  66650. private _rotateWithMatrix;
  66651. private _getNegativeRotationToRef;
  66652. /**
  66653. * Get the position of the bone in local or world space
  66654. * @param space The space that the returned position is in
  66655. * @param mesh The mesh that this bone is attached to. This is only used in world space
  66656. * @returns The position of the bone
  66657. */
  66658. getPosition(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  66659. /**
  66660. * Copy the position of the bone to a vector3 in local or world space
  66661. * @param space The space that the returned position is in
  66662. * @param mesh The mesh that this bone is attached to. This is only used in world space
  66663. * @param result The vector3 to copy the position to
  66664. */
  66665. getPositionToRef(space: Space | undefined, mesh: Nullable<AbstractMesh>, result: Vector3): void;
  66666. /**
  66667. * Get the absolute position of the bone (world space)
  66668. * @param mesh The mesh that this bone is attached to
  66669. * @returns The absolute position of the bone
  66670. */
  66671. getAbsolutePosition(mesh?: Nullable<AbstractMesh>): Vector3;
  66672. /**
  66673. * Copy the absolute position of the bone (world space) to the result param
  66674. * @param mesh The mesh that this bone is attached to
  66675. * @param result The vector3 to copy the absolute position to
  66676. */
  66677. getAbsolutePositionToRef(mesh: AbstractMesh, result: Vector3): void;
  66678. /**
  66679. * Compute the absolute transforms of this bone and its children
  66680. */
  66681. computeAbsoluteTransforms(): void;
  66682. /**
  66683. * Get the world direction from an axis that is in the local space of the bone
  66684. * @param localAxis The local direction that is used to compute the world direction
  66685. * @param mesh The mesh that this bone is attached to
  66686. * @returns The world direction
  66687. */
  66688. getDirection(localAxis: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  66689. /**
  66690. * Copy the world direction to a vector3 from an axis that is in the local space of the bone
  66691. * @param localAxis The local direction that is used to compute the world direction
  66692. * @param mesh The mesh that this bone is attached to
  66693. * @param result The vector3 that the world direction will be copied to
  66694. */
  66695. getDirectionToRef(localAxis: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  66696. /**
  66697. * Get the euler rotation of the bone in local or world space
  66698. * @param space The space that the rotation should be in
  66699. * @param mesh The mesh that this bone is attached to. This is only used in world space
  66700. * @returns The euler rotation
  66701. */
  66702. getRotation(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  66703. /**
  66704. * Copy the euler rotation of the bone to a vector3. The rotation can be in either local or world space
  66705. * @param space The space that the rotation should be in
  66706. * @param mesh The mesh that this bone is attached to. This is only used in world space
  66707. * @param result The vector3 that the rotation should be copied to
  66708. */
  66709. getRotationToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  66710. /**
  66711. * Get the quaternion rotation of the bone in either local or world space
  66712. * @param space The space that the rotation should be in
  66713. * @param mesh The mesh that this bone is attached to. This is only used in world space
  66714. * @returns The quaternion rotation
  66715. */
  66716. getRotationQuaternion(space?: Space, mesh?: Nullable<AbstractMesh>): Quaternion;
  66717. /**
  66718. * Copy the quaternion rotation of the bone to a quaternion. The rotation can be in either local or world space
  66719. * @param space The space that the rotation should be in
  66720. * @param mesh The mesh that this bone is attached to. This is only used in world space
  66721. * @param result The quaternion that the rotation should be copied to
  66722. */
  66723. getRotationQuaternionToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Quaternion): void;
  66724. /**
  66725. * Get the rotation matrix of the bone in local or world space
  66726. * @param space The space that the rotation should be in
  66727. * @param mesh The mesh that this bone is attached to. This is only used in world space
  66728. * @returns The rotation matrix
  66729. */
  66730. getRotationMatrix(space: Space | undefined, mesh: AbstractMesh): Matrix;
  66731. /**
  66732. * Copy the rotation matrix of the bone to a matrix. The rotation can be in either local or world space
  66733. * @param space The space that the rotation should be in
  66734. * @param mesh The mesh that this bone is attached to. This is only used in world space
  66735. * @param result The quaternion that the rotation should be copied to
  66736. */
  66737. getRotationMatrixToRef(space: Space | undefined, mesh: AbstractMesh, result: Matrix): void;
  66738. /**
  66739. * Get the world position of a point that is in the local space of the bone
  66740. * @param position The local position
  66741. * @param mesh The mesh that this bone is attached to
  66742. * @returns The world position
  66743. */
  66744. getAbsolutePositionFromLocal(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  66745. /**
  66746. * Get the world position of a point that is in the local space of the bone and copy it to the result param
  66747. * @param position The local position
  66748. * @param mesh The mesh that this bone is attached to
  66749. * @param result The vector3 that the world position should be copied to
  66750. */
  66751. getAbsolutePositionFromLocalToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  66752. /**
  66753. * Get the local position of a point that is in world space
  66754. * @param position The world position
  66755. * @param mesh The mesh that this bone is attached to
  66756. * @returns The local position
  66757. */
  66758. getLocalPositionFromAbsolute(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  66759. /**
  66760. * Get the local position of a point that is in world space and copy it to the result param
  66761. * @param position The world position
  66762. * @param mesh The mesh that this bone is attached to
  66763. * @param result The vector3 that the local position should be copied to
  66764. */
  66765. getLocalPositionFromAbsoluteToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  66766. }
  66767. }
  66768. declare module BABYLON {
  66769. /**
  66770. * Enum that determines the text-wrapping mode to use.
  66771. */
  66772. export enum InspectableType {
  66773. /**
  66774. * Checkbox for booleans
  66775. */
  66776. Checkbox = 0,
  66777. /**
  66778. * Sliders for numbers
  66779. */
  66780. Slider = 1,
  66781. /**
  66782. * Vector3
  66783. */
  66784. Vector3 = 2,
  66785. /**
  66786. * Quaternions
  66787. */
  66788. Quaternion = 3,
  66789. /**
  66790. * Color3
  66791. */
  66792. Color3 = 4
  66793. }
  66794. /**
  66795. * Interface used to define custom inspectable properties.
  66796. * This interface is used by the inspector to display custom property grids
  66797. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  66798. */
  66799. export interface IInspectable {
  66800. /**
  66801. * Gets the label to display
  66802. */
  66803. label: string;
  66804. /**
  66805. * Gets the name of the property to edit
  66806. */
  66807. propertyName: string;
  66808. /**
  66809. * Gets the type of the editor to use
  66810. */
  66811. type: InspectableType;
  66812. /**
  66813. * Gets the minimum value of the property when using in "slider" mode
  66814. */
  66815. min?: number;
  66816. /**
  66817. * Gets the maximum value of the property when using in "slider" mode
  66818. */
  66819. max?: number;
  66820. /**
  66821. * Gets the setp to use when using in "slider" mode
  66822. */
  66823. step?: number;
  66824. }
  66825. }
  66826. declare module BABYLON {
  66827. /**
  66828. * Class for creating a cube texture
  66829. */
  66830. export class CubeTexture extends BaseTexture {
  66831. private _delayedOnLoad;
  66832. /**
  66833. * The url of the texture
  66834. */
  66835. url: string;
  66836. /**
  66837. * Gets or sets the center of the bounding box associated with the cube texture.
  66838. * It must define where the camera used to render the texture was set
  66839. * @see http://doc.babylonjs.com/how_to/reflect#using-local-cubemap-mode
  66840. */
  66841. boundingBoxPosition: Vector3;
  66842. private _boundingBoxSize;
  66843. /**
  66844. * Gets or sets the size of the bounding box associated with the cube texture
  66845. * When defined, the cubemap will switch to local mode
  66846. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  66847. * @example https://www.babylonjs-playground.com/#RNASML
  66848. */
  66849. /**
  66850. * Returns the bounding box size
  66851. * @see http://doc.babylonjs.com/how_to/reflect#using-local-cubemap-mode
  66852. */
  66853. boundingBoxSize: Vector3;
  66854. protected _rotationY: number;
  66855. /**
  66856. * Sets texture matrix rotation angle around Y axis in radians.
  66857. */
  66858. /**
  66859. * Gets texture matrix rotation angle around Y axis radians.
  66860. */
  66861. rotationY: number;
  66862. /**
  66863. * Are mip maps generated for this texture or not.
  66864. */
  66865. readonly noMipmap: boolean;
  66866. private _noMipmap;
  66867. private _files;
  66868. private _extensions;
  66869. private _textureMatrix;
  66870. private _format;
  66871. private _createPolynomials;
  66872. /** @hidden */
  66873. _prefiltered: boolean;
  66874. /**
  66875. * Creates a cube texture from an array of image urls
  66876. * @param files defines an array of image urls
  66877. * @param scene defines the hosting scene
  66878. * @param noMipmap specifies if mip maps are not used
  66879. * @returns a cube texture
  66880. */
  66881. static CreateFromImages(files: string[], scene: Scene, noMipmap?: boolean): CubeTexture;
  66882. /**
  66883. * Creates and return a texture created from prefilterd data by tools like IBL Baker or Lys.
  66884. * @param url defines the url of the prefiltered texture
  66885. * @param scene defines the scene the texture is attached to
  66886. * @param forcedExtension defines the extension of the file if different from the url
  66887. * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
  66888. * @return the prefiltered texture
  66889. */
  66890. static CreateFromPrefilteredData(url: string, scene: Scene, forcedExtension?: any, createPolynomials?: boolean): CubeTexture;
  66891. /**
  66892. * Creates a cube texture to use with reflection for instance. It can be based upon dds or six images as well
  66893. * as prefiltered data.
  66894. * @param rootUrl defines the url of the texture or the root name of the six images
  66895. * @param scene defines the scene the texture is attached to
  66896. * @param extensions defines the suffixes add to the picture name in case six images are in use like _px.jpg...
  66897. * @param noMipmap defines if mipmaps should be created or not
  66898. * @param files defines the six files to load for the different faces in that order: px, py, pz, nx, ny, nz
  66899. * @param onLoad defines a callback triggered at the end of the file load if no errors occured
  66900. * @param onError defines a callback triggered in case of error during load
  66901. * @param format defines the internal format to use for the texture once loaded
  66902. * @param prefiltered defines whether or not the texture is created from prefiltered data
  66903. * @param forcedExtension defines the extensions to use (force a special type of file to load) in case it is different from the file name
  66904. * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
  66905. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  66906. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  66907. * @return the cube texture
  66908. */
  66909. 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);
  66910. /**
  66911. * Get the current class name of the texture useful for serialization or dynamic coding.
  66912. * @returns "CubeTexture"
  66913. */
  66914. getClassName(): string;
  66915. /**
  66916. * Update the url (and optional buffer) of this texture if url was null during construction.
  66917. * @param url the url of the texture
  66918. * @param forcedExtension defines the extension to use
  66919. * @param onLoad callback called when the texture is loaded (defaults to null)
  66920. */
  66921. updateURL(url: string, forcedExtension?: string, onLoad?: () => void): void;
  66922. /**
  66923. * Delays loading of the cube texture
  66924. * @param forcedExtension defines the extension to use
  66925. */
  66926. delayLoad(forcedExtension?: string): void;
  66927. /**
  66928. * Returns the reflection texture matrix
  66929. * @returns the reflection texture matrix
  66930. */
  66931. getReflectionTextureMatrix(): Matrix;
  66932. /**
  66933. * Sets the reflection texture matrix
  66934. * @param value Reflection texture matrix
  66935. */
  66936. setReflectionTextureMatrix(value: Matrix): void;
  66937. /**
  66938. * Parses text to create a cube texture
  66939. * @param parsedTexture define the serialized text to read from
  66940. * @param scene defines the hosting scene
  66941. * @param rootUrl defines the root url of the cube texture
  66942. * @returns a cube texture
  66943. */
  66944. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): CubeTexture;
  66945. /**
  66946. * Makes a clone, or deep copy, of the cube texture
  66947. * @returns a new cube texture
  66948. */
  66949. clone(): CubeTexture;
  66950. }
  66951. }
  66952. declare module BABYLON {
  66953. /** @hidden */
  66954. export var postprocessVertexShader: {
  66955. name: string;
  66956. shader: string;
  66957. };
  66958. }
  66959. declare module BABYLON {
  66960. /**
  66961. * A target camera takes a mesh or position as a target and continues to look at it while it moves.
  66962. * This is the base of the follow, arc rotate cameras and Free camera
  66963. * @see http://doc.babylonjs.com/features/cameras
  66964. */
  66965. export class TargetCamera extends Camera {
  66966. private static _RigCamTransformMatrix;
  66967. private static _TargetTransformMatrix;
  66968. private static _TargetFocalPoint;
  66969. /**
  66970. * Define the current direction the camera is moving to
  66971. */
  66972. cameraDirection: Vector3;
  66973. /**
  66974. * Define the current rotation the camera is rotating to
  66975. */
  66976. cameraRotation: Vector2;
  66977. /**
  66978. * When set, the up vector of the camera will be updated by the rotation of the camera
  66979. */
  66980. updateUpVectorFromRotation: boolean;
  66981. private _tmpQuaternion;
  66982. /**
  66983. * Define the current rotation of the camera
  66984. */
  66985. rotation: Vector3;
  66986. /**
  66987. * Define the current rotation of the camera as a quaternion to prevent Gimbal lock
  66988. */
  66989. rotationQuaternion: Quaternion;
  66990. /**
  66991. * Define the current speed of the camera
  66992. */
  66993. speed: number;
  66994. /**
  66995. * Add cconstraint to the camera to prevent it to move freely in all directions and
  66996. * around all axis.
  66997. */
  66998. noRotationConstraint: boolean;
  66999. /**
  67000. * Define the current target of the camera as an object or a position.
  67001. */
  67002. lockedTarget: any;
  67003. /** @hidden */
  67004. _currentTarget: Vector3;
  67005. /** @hidden */
  67006. _initialFocalDistance: number;
  67007. /** @hidden */
  67008. _viewMatrix: Matrix;
  67009. /** @hidden */
  67010. _camMatrix: Matrix;
  67011. /** @hidden */
  67012. _cameraTransformMatrix: Matrix;
  67013. /** @hidden */
  67014. _cameraRotationMatrix: Matrix;
  67015. /** @hidden */
  67016. _referencePoint: Vector3;
  67017. /** @hidden */
  67018. _transformedReferencePoint: Vector3;
  67019. protected _globalCurrentTarget: Vector3;
  67020. protected _globalCurrentUpVector: Vector3;
  67021. /** @hidden */
  67022. _reset: () => void;
  67023. private _defaultUp;
  67024. /**
  67025. * Instantiates a target camera that takes a meshor position as a target and continues to look at it while it moves.
  67026. * This is the base of the follow, arc rotate cameras and Free camera
  67027. * @see http://doc.babylonjs.com/features/cameras
  67028. * @param name Defines the name of the camera in the scene
  67029. * @param position Defines the start position of the camera in the scene
  67030. * @param scene Defines the scene the camera belongs to
  67031. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  67032. */
  67033. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  67034. /**
  67035. * Gets the position in front of the camera at a given distance.
  67036. * @param distance The distance from the camera we want the position to be
  67037. * @returns the position
  67038. */
  67039. getFrontPosition(distance: number): Vector3;
  67040. /** @hidden */
  67041. _getLockedTargetPosition(): Nullable<Vector3>;
  67042. private _storedPosition;
  67043. private _storedRotation;
  67044. private _storedRotationQuaternion;
  67045. /**
  67046. * Store current camera state of the camera (fov, position, rotation, etc..)
  67047. * @returns the camera
  67048. */
  67049. storeState(): Camera;
  67050. /**
  67051. * Restored camera state. You must call storeState() first
  67052. * @returns whether it was successful or not
  67053. * @hidden
  67054. */
  67055. _restoreStateValues(): boolean;
  67056. /** @hidden */
  67057. _initCache(): void;
  67058. /** @hidden */
  67059. _updateCache(ignoreParentClass?: boolean): void;
  67060. /** @hidden */
  67061. _isSynchronizedViewMatrix(): boolean;
  67062. /** @hidden */
  67063. _computeLocalCameraSpeed(): number;
  67064. /**
  67065. * Defines the target the camera should look at.
  67066. * This will automatically adapt alpha beta and radius to fit within the new target.
  67067. * @param target Defines the new target as a Vector or a mesh
  67068. */
  67069. setTarget(target: Vector3): void;
  67070. /**
  67071. * Return the current target position of the camera. This value is expressed in local space.
  67072. * @returns the target position
  67073. */
  67074. getTarget(): Vector3;
  67075. /** @hidden */
  67076. _decideIfNeedsToMove(): boolean;
  67077. /** @hidden */
  67078. _updatePosition(): void;
  67079. /** @hidden */
  67080. _checkInputs(): void;
  67081. protected _updateCameraRotationMatrix(): void;
  67082. /**
  67083. * 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)
  67084. * @returns the current camera
  67085. */
  67086. private _rotateUpVectorWithCameraRotationMatrix;
  67087. private _cachedRotationZ;
  67088. private _cachedQuaternionRotationZ;
  67089. /** @hidden */
  67090. _getViewMatrix(): Matrix;
  67091. protected _computeViewMatrix(position: Vector3, target: Vector3, up: Vector3): void;
  67092. /**
  67093. * @hidden
  67094. */
  67095. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  67096. /**
  67097. * @hidden
  67098. */
  67099. _updateRigCameras(): void;
  67100. private _getRigCamPositionAndTarget;
  67101. /**
  67102. * Gets the current object class name.
  67103. * @return the class name
  67104. */
  67105. getClassName(): string;
  67106. }
  67107. }
  67108. declare module BABYLON {
  67109. /**
  67110. * @ignore
  67111. * This is a list of all the different input types that are available in the application.
  67112. * Fo instance: ArcRotateCameraGamepadInput...
  67113. */
  67114. export var CameraInputTypes: {};
  67115. /**
  67116. * This is the contract to implement in order to create a new input class.
  67117. * Inputs are dealing with listening to user actions and moving the camera accordingly.
  67118. */
  67119. export interface ICameraInput<TCamera extends Camera> {
  67120. /**
  67121. * Defines the camera the input is attached to.
  67122. */
  67123. camera: Nullable<TCamera>;
  67124. /**
  67125. * Gets the class name of the current intput.
  67126. * @returns the class name
  67127. */
  67128. getClassName(): string;
  67129. /**
  67130. * Get the friendly name associated with the input class.
  67131. * @returns the input friendly name
  67132. */
  67133. getSimpleName(): string;
  67134. /**
  67135. * Attach the input controls to a specific dom element to get the input from.
  67136. * @param element Defines the element the controls should be listened from
  67137. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  67138. */
  67139. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  67140. /**
  67141. * Detach the current controls from the specified dom element.
  67142. * @param element Defines the element to stop listening the inputs from
  67143. */
  67144. detachControl(element: Nullable<HTMLElement>): void;
  67145. /**
  67146. * Update the current camera state depending on the inputs that have been used this frame.
  67147. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  67148. */
  67149. checkInputs?: () => void;
  67150. }
  67151. /**
  67152. * Represents a map of input types to input instance or input index to input instance.
  67153. */
  67154. export interface CameraInputsMap<TCamera extends Camera> {
  67155. /**
  67156. * Accessor to the input by input type.
  67157. */
  67158. [name: string]: ICameraInput<TCamera>;
  67159. /**
  67160. * Accessor to the input by input index.
  67161. */
  67162. [idx: number]: ICameraInput<TCamera>;
  67163. }
  67164. /**
  67165. * This represents the input manager used within a camera.
  67166. * It helps dealing with all the different kind of input attached to a camera.
  67167. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  67168. */
  67169. export class CameraInputsManager<TCamera extends Camera> {
  67170. /**
  67171. * Defines the list of inputs attahed to the camera.
  67172. */
  67173. attached: CameraInputsMap<TCamera>;
  67174. /**
  67175. * Defines the dom element the camera is collecting inputs from.
  67176. * This is null if the controls have not been attached.
  67177. */
  67178. attachedElement: Nullable<HTMLElement>;
  67179. /**
  67180. * Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  67181. */
  67182. noPreventDefault: boolean;
  67183. /**
  67184. * Defined the camera the input manager belongs to.
  67185. */
  67186. camera: TCamera;
  67187. /**
  67188. * Update the current camera state depending on the inputs that have been used this frame.
  67189. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  67190. */
  67191. checkInputs: () => void;
  67192. /**
  67193. * Instantiate a new Camera Input Manager.
  67194. * @param camera Defines the camera the input manager blongs to
  67195. */
  67196. constructor(camera: TCamera);
  67197. /**
  67198. * Add an input method to a camera
  67199. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  67200. * @param input camera input method
  67201. */
  67202. add(input: ICameraInput<TCamera>): void;
  67203. /**
  67204. * Remove a specific input method from a camera
  67205. * example: camera.inputs.remove(camera.inputs.attached.mouse);
  67206. * @param inputToRemove camera input method
  67207. */
  67208. remove(inputToRemove: ICameraInput<TCamera>): void;
  67209. /**
  67210. * Remove a specific input type from a camera
  67211. * example: camera.inputs.remove("ArcRotateCameraGamepadInput");
  67212. * @param inputType the type of the input to remove
  67213. */
  67214. removeByType(inputType: string): void;
  67215. private _addCheckInputs;
  67216. /**
  67217. * Attach the input controls to the currently attached dom element to listen the events from.
  67218. * @param input Defines the input to attach
  67219. */
  67220. attachInput(input: ICameraInput<TCamera>): void;
  67221. /**
  67222. * Attach the current manager inputs controls to a specific dom element to listen the events from.
  67223. * @param element Defines the dom element to collect the events from
  67224. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  67225. */
  67226. attachElement(element: HTMLElement, noPreventDefault?: boolean): void;
  67227. /**
  67228. * Detach the current manager inputs controls from a specific dom element.
  67229. * @param element Defines the dom element to collect the events from
  67230. * @param disconnect Defines whether the input should be removed from the current list of attached inputs
  67231. */
  67232. detachElement(element: HTMLElement, disconnect?: boolean): void;
  67233. /**
  67234. * Rebuild the dynamic inputCheck function from the current list of
  67235. * defined inputs in the manager.
  67236. */
  67237. rebuildInputCheck(): void;
  67238. /**
  67239. * Remove all attached input methods from a camera
  67240. */
  67241. clear(): void;
  67242. /**
  67243. * Serialize the current input manager attached to a camera.
  67244. * This ensures than once parsed,
  67245. * the input associated to the camera will be identical to the current ones
  67246. * @param serializedCamera Defines the camera serialization JSON the input serialization should write to
  67247. */
  67248. serialize(serializedCamera: any): void;
  67249. /**
  67250. * Parses an input manager serialized JSON to restore the previous list of inputs
  67251. * and states associated to a camera.
  67252. * @param parsedCamera Defines the JSON to parse
  67253. */
  67254. parse(parsedCamera: any): void;
  67255. }
  67256. }
  67257. declare module BABYLON {
  67258. /**
  67259. * Gather the list of keyboard event types as constants.
  67260. */
  67261. export class KeyboardEventTypes {
  67262. /**
  67263. * The keydown event is fired when a key becomes active (pressed).
  67264. */
  67265. static readonly KEYDOWN: number;
  67266. /**
  67267. * The keyup event is fired when a key has been released.
  67268. */
  67269. static readonly KEYUP: number;
  67270. }
  67271. /**
  67272. * This class is used to store keyboard related info for the onKeyboardObservable event.
  67273. */
  67274. export class KeyboardInfo {
  67275. /**
  67276. * Defines the type of event (KeyboardEventTypes)
  67277. */
  67278. type: number;
  67279. /**
  67280. * Defines the related dom event
  67281. */
  67282. event: KeyboardEvent;
  67283. /**
  67284. * Instantiates a new keyboard info.
  67285. * This class is used to store keyboard related info for the onKeyboardObservable event.
  67286. * @param type Defines the type of event (KeyboardEventTypes)
  67287. * @param event Defines the related dom event
  67288. */
  67289. constructor(
  67290. /**
  67291. * Defines the type of event (KeyboardEventTypes)
  67292. */
  67293. type: number,
  67294. /**
  67295. * Defines the related dom event
  67296. */
  67297. event: KeyboardEvent);
  67298. }
  67299. /**
  67300. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  67301. * Set the skipOnKeyboardObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onKeyboardObservable
  67302. */
  67303. export class KeyboardInfoPre extends KeyboardInfo {
  67304. /**
  67305. * Defines the type of event (KeyboardEventTypes)
  67306. */
  67307. type: number;
  67308. /**
  67309. * Defines the related dom event
  67310. */
  67311. event: KeyboardEvent;
  67312. /**
  67313. * Defines whether the engine should skip the next onKeyboardObservable associated to this pre.
  67314. */
  67315. skipOnPointerObservable: boolean;
  67316. /**
  67317. * Instantiates a new keyboard pre info.
  67318. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  67319. * @param type Defines the type of event (KeyboardEventTypes)
  67320. * @param event Defines the related dom event
  67321. */
  67322. constructor(
  67323. /**
  67324. * Defines the type of event (KeyboardEventTypes)
  67325. */
  67326. type: number,
  67327. /**
  67328. * Defines the related dom event
  67329. */
  67330. event: KeyboardEvent);
  67331. }
  67332. }
  67333. declare module BABYLON {
  67334. /**
  67335. * Manage the keyboard inputs to control the movement of a free camera.
  67336. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  67337. */
  67338. export class FreeCameraKeyboardMoveInput implements ICameraInput<FreeCamera> {
  67339. /**
  67340. * Defines the camera the input is attached to.
  67341. */
  67342. camera: FreeCamera;
  67343. /**
  67344. * Gets or Set the list of keyboard keys used to control the forward move of the camera.
  67345. */
  67346. keysUp: number[];
  67347. /**
  67348. * Gets or Set the list of keyboard keys used to control the backward move of the camera.
  67349. */
  67350. keysDown: number[];
  67351. /**
  67352. * Gets or Set the list of keyboard keys used to control the left strafe move of the camera.
  67353. */
  67354. keysLeft: number[];
  67355. /**
  67356. * Gets or Set the list of keyboard keys used to control the right strafe move of the camera.
  67357. */
  67358. keysRight: number[];
  67359. private _keys;
  67360. private _onCanvasBlurObserver;
  67361. private _onKeyboardObserver;
  67362. private _engine;
  67363. private _scene;
  67364. /**
  67365. * Attach the input controls to a specific dom element to get the input from.
  67366. * @param element Defines the element the controls should be listened from
  67367. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  67368. */
  67369. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  67370. /**
  67371. * Detach the current controls from the specified dom element.
  67372. * @param element Defines the element to stop listening the inputs from
  67373. */
  67374. detachControl(element: Nullable<HTMLElement>): void;
  67375. /**
  67376. * Update the current camera state depending on the inputs that have been used this frame.
  67377. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  67378. */
  67379. checkInputs(): void;
  67380. /**
  67381. * Gets the class name of the current intput.
  67382. * @returns the class name
  67383. */
  67384. getClassName(): string;
  67385. /** @hidden */
  67386. _onLostFocus(): void;
  67387. /**
  67388. * Get the friendly name associated with the input class.
  67389. * @returns the input friendly name
  67390. */
  67391. getSimpleName(): string;
  67392. }
  67393. }
  67394. declare module BABYLON {
  67395. /**
  67396. * Interface describing all the common properties and methods a shadow light needs to implement.
  67397. * This helps both the shadow generator and materials to genrate the corresponding shadow maps
  67398. * as well as binding the different shadow properties to the effects.
  67399. */
  67400. export interface IShadowLight extends Light {
  67401. /**
  67402. * The light id in the scene (used in scene.findLighById for instance)
  67403. */
  67404. id: string;
  67405. /**
  67406. * The position the shdow will be casted from.
  67407. */
  67408. position: Vector3;
  67409. /**
  67410. * In 2d mode (needCube being false), the direction used to cast the shadow.
  67411. */
  67412. direction: Vector3;
  67413. /**
  67414. * The transformed position. Position of the light in world space taking parenting in account.
  67415. */
  67416. transformedPosition: Vector3;
  67417. /**
  67418. * The transformed direction. Direction of the light in world space taking parenting in account.
  67419. */
  67420. transformedDirection: Vector3;
  67421. /**
  67422. * The friendly name of the light in the scene.
  67423. */
  67424. name: string;
  67425. /**
  67426. * Defines the shadow projection clipping minimum z value.
  67427. */
  67428. shadowMinZ: number;
  67429. /**
  67430. * Defines the shadow projection clipping maximum z value.
  67431. */
  67432. shadowMaxZ: number;
  67433. /**
  67434. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  67435. * @returns true if the information has been computed, false if it does not need to (no parenting)
  67436. */
  67437. computeTransformedInformation(): boolean;
  67438. /**
  67439. * Gets the scene the light belongs to.
  67440. * @returns The scene
  67441. */
  67442. getScene(): Scene;
  67443. /**
  67444. * Callback defining a custom Projection Matrix Builder.
  67445. * This can be used to override the default projection matrix computation.
  67446. */
  67447. customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
  67448. /**
  67449. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  67450. * @param matrix The materix to updated with the projection information
  67451. * @param viewMatrix The transform matrix of the light
  67452. * @param renderList The list of mesh to render in the map
  67453. * @returns The current light
  67454. */
  67455. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight;
  67456. /**
  67457. * Gets the current depth scale used in ESM.
  67458. * @returns The scale
  67459. */
  67460. getDepthScale(): number;
  67461. /**
  67462. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  67463. * @returns true if a cube texture needs to be use
  67464. */
  67465. needCube(): boolean;
  67466. /**
  67467. * Detects if the projection matrix requires to be recomputed this frame.
  67468. * @returns true if it requires to be recomputed otherwise, false.
  67469. */
  67470. needProjectionMatrixCompute(): boolean;
  67471. /**
  67472. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  67473. */
  67474. forceProjectionMatrixCompute(): void;
  67475. /**
  67476. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  67477. * @param faceIndex The index of the face we are computed the direction to generate shadow
  67478. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  67479. */
  67480. getShadowDirection(faceIndex?: number): Vector3;
  67481. /**
  67482. * Gets the minZ used for shadow according to both the scene and the light.
  67483. * @param activeCamera The camera we are returning the min for
  67484. * @returns the depth min z
  67485. */
  67486. getDepthMinZ(activeCamera: Camera): number;
  67487. /**
  67488. * Gets the maxZ used for shadow according to both the scene and the light.
  67489. * @param activeCamera The camera we are returning the max for
  67490. * @returns the depth max z
  67491. */
  67492. getDepthMaxZ(activeCamera: Camera): number;
  67493. }
  67494. /**
  67495. * Base implementation IShadowLight
  67496. * It groups all the common behaviour in order to reduce dupplication and better follow the DRY pattern.
  67497. */
  67498. export abstract class ShadowLight extends Light implements IShadowLight {
  67499. protected abstract _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  67500. protected _position: Vector3;
  67501. protected _setPosition(value: Vector3): void;
  67502. /**
  67503. * Sets the position the shadow will be casted from. Also use as the light position for both
  67504. * point and spot lights.
  67505. */
  67506. /**
  67507. * Sets the position the shadow will be casted from. Also use as the light position for both
  67508. * point and spot lights.
  67509. */
  67510. position: Vector3;
  67511. protected _direction: Vector3;
  67512. protected _setDirection(value: Vector3): void;
  67513. /**
  67514. * In 2d mode (needCube being false), gets the direction used to cast the shadow.
  67515. * Also use as the light direction on spot and directional lights.
  67516. */
  67517. /**
  67518. * In 2d mode (needCube being false), sets the direction used to cast the shadow.
  67519. * Also use as the light direction on spot and directional lights.
  67520. */
  67521. direction: Vector3;
  67522. private _shadowMinZ;
  67523. /**
  67524. * Gets the shadow projection clipping minimum z value.
  67525. */
  67526. /**
  67527. * Sets the shadow projection clipping minimum z value.
  67528. */
  67529. shadowMinZ: number;
  67530. private _shadowMaxZ;
  67531. /**
  67532. * Sets the shadow projection clipping maximum z value.
  67533. */
  67534. /**
  67535. * Gets the shadow projection clipping maximum z value.
  67536. */
  67537. shadowMaxZ: number;
  67538. /**
  67539. * Callback defining a custom Projection Matrix Builder.
  67540. * This can be used to override the default projection matrix computation.
  67541. */
  67542. customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
  67543. /**
  67544. * The transformed position. Position of the light in world space taking parenting in account.
  67545. */
  67546. transformedPosition: Vector3;
  67547. /**
  67548. * The transformed direction. Direction of the light in world space taking parenting in account.
  67549. */
  67550. transformedDirection: Vector3;
  67551. private _needProjectionMatrixCompute;
  67552. /**
  67553. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  67554. * @returns true if the information has been computed, false if it does not need to (no parenting)
  67555. */
  67556. computeTransformedInformation(): boolean;
  67557. /**
  67558. * Return the depth scale used for the shadow map.
  67559. * @returns the depth scale.
  67560. */
  67561. getDepthScale(): number;
  67562. /**
  67563. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  67564. * @param faceIndex The index of the face we are computed the direction to generate shadow
  67565. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  67566. */
  67567. getShadowDirection(faceIndex?: number): Vector3;
  67568. /**
  67569. * Returns the ShadowLight absolute position in the World.
  67570. * @returns the position vector in world space
  67571. */
  67572. getAbsolutePosition(): Vector3;
  67573. /**
  67574. * Sets the ShadowLight direction toward the passed target.
  67575. * @param target The point to target in local space
  67576. * @returns the updated ShadowLight direction
  67577. */
  67578. setDirectionToTarget(target: Vector3): Vector3;
  67579. /**
  67580. * Returns the light rotation in euler definition.
  67581. * @returns the x y z rotation in local space.
  67582. */
  67583. getRotation(): Vector3;
  67584. /**
  67585. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  67586. * @returns true if a cube texture needs to be use
  67587. */
  67588. needCube(): boolean;
  67589. /**
  67590. * Detects if the projection matrix requires to be recomputed this frame.
  67591. * @returns true if it requires to be recomputed otherwise, false.
  67592. */
  67593. needProjectionMatrixCompute(): boolean;
  67594. /**
  67595. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  67596. */
  67597. forceProjectionMatrixCompute(): void;
  67598. /** @hidden */
  67599. _initCache(): void;
  67600. /** @hidden */
  67601. _isSynchronized(): boolean;
  67602. /**
  67603. * Computes the world matrix of the node
  67604. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  67605. * @returns the world matrix
  67606. */
  67607. computeWorldMatrix(force?: boolean): Matrix;
  67608. /**
  67609. * Gets the minZ used for shadow according to both the scene and the light.
  67610. * @param activeCamera The camera we are returning the min for
  67611. * @returns the depth min z
  67612. */
  67613. getDepthMinZ(activeCamera: Camera): number;
  67614. /**
  67615. * Gets the maxZ used for shadow according to both the scene and the light.
  67616. * @param activeCamera The camera we are returning the max for
  67617. * @returns the depth max z
  67618. */
  67619. getDepthMaxZ(activeCamera: Camera): number;
  67620. /**
  67621. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  67622. * @param matrix The materix to updated with the projection information
  67623. * @param viewMatrix The transform matrix of the light
  67624. * @param renderList The list of mesh to render in the map
  67625. * @returns The current light
  67626. */
  67627. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight;
  67628. }
  67629. }
  67630. declare module BABYLON {
  67631. /**
  67632. * "Static Class" containing the most commonly used helper while dealing with material for
  67633. * rendering purpose.
  67634. *
  67635. * It contains the basic tools to help defining defines, binding uniform for the common part of the materials.
  67636. *
  67637. * This works by convention in BabylonJS but is meant to be use only with shader following the in place naming rules and conventions.
  67638. */
  67639. export class MaterialHelper {
  67640. /**
  67641. * Bind the current view position to an effect.
  67642. * @param effect The effect to be bound
  67643. * @param scene The scene the eyes position is used from
  67644. */
  67645. static BindEyePosition(effect: Effect, scene: Scene): void;
  67646. /**
  67647. * Helps preparing the defines values about the UVs in used in the effect.
  67648. * UVs are shared as much as we can accross channels in the shaders.
  67649. * @param texture The texture we are preparing the UVs for
  67650. * @param defines The defines to update
  67651. * @param key The channel key "diffuse", "specular"... used in the shader
  67652. */
  67653. static PrepareDefinesForMergedUV(texture: BaseTexture, defines: any, key: string): void;
  67654. /**
  67655. * Binds a texture matrix value to its corrsponding uniform
  67656. * @param texture The texture to bind the matrix for
  67657. * @param uniformBuffer The uniform buffer receivin the data
  67658. * @param key The channel key "diffuse", "specular"... used in the shader
  67659. */
  67660. static BindTextureMatrix(texture: BaseTexture, uniformBuffer: UniformBuffer, key: string): void;
  67661. /**
  67662. * Helper used to prepare the list of defines associated with misc. values for shader compilation
  67663. * @param mesh defines the current mesh
  67664. * @param scene defines the current scene
  67665. * @param useLogarithmicDepth defines if logarithmic depth has to be turned on
  67666. * @param pointsCloud defines if point cloud rendering has to be turned on
  67667. * @param fogEnabled defines if fog has to be turned on
  67668. * @param alphaTest defines if alpha testing has to be turned on
  67669. * @param defines defines the current list of defines
  67670. */
  67671. static PrepareDefinesForMisc(mesh: AbstractMesh, scene: Scene, useLogarithmicDepth: boolean, pointsCloud: boolean, fogEnabled: boolean, alphaTest: boolean, defines: any): void;
  67672. /**
  67673. * Helper used to prepare the list of defines associated with frame values for shader compilation
  67674. * @param scene defines the current scene
  67675. * @param engine defines the current engine
  67676. * @param defines specifies the list of active defines
  67677. * @param useInstances defines if instances have to be turned on
  67678. * @param useClipPlane defines if clip plane have to be turned on
  67679. */
  67680. static PrepareDefinesForFrameBoundValues(scene: Scene, engine: Engine, defines: any, useInstances: boolean, useClipPlane?: Nullable<boolean>): void;
  67681. /**
  67682. * Prepares the defines used in the shader depending on the attributes data available in the mesh
  67683. * @param mesh The mesh containing the geometry data we will draw
  67684. * @param defines The defines to update
  67685. * @param useVertexColor Precise whether vertex colors should be used or not (override mesh info)
  67686. * @param useBones Precise whether bones should be used or not (override mesh info)
  67687. * @param useMorphTargets Precise whether morph targets should be used or not (override mesh info)
  67688. * @param useVertexAlpha Precise whether vertex alpha should be used or not (override mesh info)
  67689. * @returns false if defines are considered not dirty and have not been checked
  67690. */
  67691. static PrepareDefinesForAttributes(mesh: AbstractMesh, defines: any, useVertexColor: boolean, useBones: boolean, useMorphTargets?: boolean, useVertexAlpha?: boolean): boolean;
  67692. /**
  67693. * Prepares the defines related to the light information passed in parameter
  67694. * @param scene The scene we are intending to draw
  67695. * @param mesh The mesh the effect is compiling for
  67696. * @param defines The defines to update
  67697. * @param specularSupported Specifies whether specular is supported or not (override lights data)
  67698. * @param maxSimultaneousLights Specfies how manuy lights can be added to the effect at max
  67699. * @param disableLighting Specifies whether the lighting is disabled (override scene and light)
  67700. * @returns true if normals will be required for the rest of the effect
  67701. */
  67702. static PrepareDefinesForLights(scene: Scene, mesh: AbstractMesh, defines: any, specularSupported: boolean, maxSimultaneousLights?: number, disableLighting?: boolean): boolean;
  67703. /**
  67704. * Prepares the uniforms and samplers list to be used in the effect. This can automatically remove from the list uniforms
  67705. * that won t be acctive due to defines being turned off.
  67706. * @param uniformsListOrOptions The uniform names to prepare or an EffectCreationOptions containing the liist and extra information
  67707. * @param samplersList The samplers list
  67708. * @param defines The defines helping in the list generation
  67709. * @param maxSimultaneousLights The maximum number of simultanous light allowed in the effect
  67710. */
  67711. static PrepareUniformsAndSamplersList(uniformsListOrOptions: string[] | EffectCreationOptions, samplersList?: string[], defines?: any, maxSimultaneousLights?: number): void;
  67712. /**
  67713. * This helps decreasing rank by rank the shadow quality (0 being the highest rank and quality)
  67714. * @param defines The defines to update while falling back
  67715. * @param fallbacks The authorized effect fallbacks
  67716. * @param maxSimultaneousLights The maximum number of lights allowed
  67717. * @param rank the current rank of the Effect
  67718. * @returns The newly affected rank
  67719. */
  67720. static HandleFallbacksForShadows(defines: any, fallbacks: EffectFallbacks, maxSimultaneousLights?: number, rank?: number): number;
  67721. /**
  67722. * Prepares the list of attributes required for morph targets according to the effect defines.
  67723. * @param attribs The current list of supported attribs
  67724. * @param mesh The mesh to prepare the morph targets attributes for
  67725. * @param defines The current Defines of the effect
  67726. */
  67727. static PrepareAttributesForMorphTargets(attribs: string[], mesh: AbstractMesh, defines: any): void;
  67728. /**
  67729. * Prepares the list of attributes required for bones according to the effect defines.
  67730. * @param attribs The current list of supported attribs
  67731. * @param mesh The mesh to prepare the bones attributes for
  67732. * @param defines The current Defines of the effect
  67733. * @param fallbacks The current efffect fallback strategy
  67734. */
  67735. static PrepareAttributesForBones(attribs: string[], mesh: AbstractMesh, defines: any, fallbacks: EffectFallbacks): void;
  67736. /**
  67737. * Prepares the list of attributes required for instances according to the effect defines.
  67738. * @param attribs The current list of supported attribs
  67739. * @param defines The current Defines of the effect
  67740. */
  67741. static PrepareAttributesForInstances(attribs: string[], defines: any): void;
  67742. /**
  67743. * Binds the light shadow information to the effect for the given mesh.
  67744. * @param light The light containing the generator
  67745. * @param scene The scene the lights belongs to
  67746. * @param mesh The mesh we are binding the information to render
  67747. * @param lightIndex The light index in the effect used to render the mesh
  67748. * @param effect The effect we are binding the data to
  67749. */
  67750. static BindLightShadow(light: Light, mesh: AbstractMesh, lightIndex: string, effect: Effect): void;
  67751. /**
  67752. * Binds the light information to the effect.
  67753. * @param light The light containing the generator
  67754. * @param effect The effect we are binding the data to
  67755. * @param lightIndex The light index in the effect used to render
  67756. */
  67757. static BindLightProperties(light: Light, effect: Effect, lightIndex: number): void;
  67758. /**
  67759. * Binds the lights information from the scene to the effect for the given mesh.
  67760. * @param scene The scene the lights belongs to
  67761. * @param mesh The mesh we are binding the information to render
  67762. * @param effect The effect we are binding the data to
  67763. * @param defines The generated defines for the effect
  67764. * @param maxSimultaneousLights The maximum number of light that can be bound to the effect
  67765. * @param usePhysicalLightFalloff Specifies whether the light falloff is defined physically or not
  67766. */
  67767. static BindLights(scene: Scene, mesh: AbstractMesh, effect: Effect, defines: any, maxSimultaneousLights?: number, usePhysicalLightFalloff?: boolean): void;
  67768. private static _tempFogColor;
  67769. /**
  67770. * Binds the fog information from the scene to the effect for the given mesh.
  67771. * @param scene The scene the lights belongs to
  67772. * @param mesh The mesh we are binding the information to render
  67773. * @param effect The effect we are binding the data to
  67774. * @param linearSpace Defines if the fog effect is applied in linear space
  67775. */
  67776. static BindFogParameters(scene: Scene, mesh: AbstractMesh, effect: Effect, linearSpace?: boolean): void;
  67777. /**
  67778. * Binds the bones information from the mesh to the effect.
  67779. * @param mesh The mesh we are binding the information to render
  67780. * @param effect The effect we are binding the data to
  67781. */
  67782. static BindBonesParameters(mesh?: AbstractMesh, effect?: Effect): void;
  67783. /**
  67784. * Binds the morph targets information from the mesh to the effect.
  67785. * @param abstractMesh The mesh we are binding the information to render
  67786. * @param effect The effect we are binding the data to
  67787. */
  67788. static BindMorphTargetParameters(abstractMesh: AbstractMesh, effect: Effect): void;
  67789. /**
  67790. * Binds the logarithmic depth information from the scene to the effect for the given defines.
  67791. * @param defines The generated defines used in the effect
  67792. * @param effect The effect we are binding the data to
  67793. * @param scene The scene we are willing to render with logarithmic scale for
  67794. */
  67795. static BindLogDepth(defines: any, effect: Effect, scene: Scene): void;
  67796. /**
  67797. * Binds the clip plane information from the scene to the effect.
  67798. * @param scene The scene the clip plane information are extracted from
  67799. * @param effect The effect we are binding the data to
  67800. */
  67801. static BindClipPlane(effect: Effect, scene: Scene): void;
  67802. }
  67803. }
  67804. declare module BABYLON {
  67805. /** @hidden */
  67806. export var kernelBlurVaryingDeclaration: {
  67807. name: string;
  67808. shader: string;
  67809. };
  67810. }
  67811. declare module BABYLON {
  67812. /** @hidden */
  67813. export var kernelBlurFragment: {
  67814. name: string;
  67815. shader: string;
  67816. };
  67817. }
  67818. declare module BABYLON {
  67819. /** @hidden */
  67820. export var kernelBlurFragment2: {
  67821. name: string;
  67822. shader: string;
  67823. };
  67824. }
  67825. declare module BABYLON {
  67826. /** @hidden */
  67827. export var kernelBlurPixelShader: {
  67828. name: string;
  67829. shader: string;
  67830. };
  67831. }
  67832. declare module BABYLON {
  67833. /** @hidden */
  67834. export var kernelBlurVertex: {
  67835. name: string;
  67836. shader: string;
  67837. };
  67838. }
  67839. declare module BABYLON {
  67840. /** @hidden */
  67841. export var kernelBlurVertexShader: {
  67842. name: string;
  67843. shader: string;
  67844. };
  67845. }
  67846. declare module BABYLON {
  67847. /**
  67848. * The Blur Post Process which blurs an image based on a kernel and direction.
  67849. * Can be used twice in x and y directions to perform a guassian blur in two passes.
  67850. */
  67851. export class BlurPostProcess extends PostProcess {
  67852. /** The direction in which to blur the image. */
  67853. direction: Vector2;
  67854. private blockCompilation;
  67855. protected _kernel: number;
  67856. protected _idealKernel: number;
  67857. protected _packedFloat: boolean;
  67858. private _staticDefines;
  67859. /**
  67860. * Sets the length in pixels of the blur sample region
  67861. */
  67862. /**
  67863. * Gets the length in pixels of the blur sample region
  67864. */
  67865. kernel: number;
  67866. /**
  67867. * Sets wether or not the blur needs to unpack/repack floats
  67868. */
  67869. /**
  67870. * Gets wether or not the blur is unpacking/repacking floats
  67871. */
  67872. packedFloat: boolean;
  67873. /**
  67874. * Creates a new instance BlurPostProcess
  67875. * @param name The name of the effect.
  67876. * @param direction The direction in which to blur the image.
  67877. * @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.
  67878. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  67879. * @param camera The camera to apply the render pass to.
  67880. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  67881. * @param engine The engine which the post process will be applied. (default: current engine)
  67882. * @param reusable If the post process can be reused on the same frame. (default: false)
  67883. * @param textureType Type of textures used when performing the post process. (default: 0)
  67884. * @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)
  67885. */
  67886. constructor(name: string,
  67887. /** The direction in which to blur the image. */
  67888. direction: Vector2, kernel: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, defines?: string, blockCompilation?: boolean);
  67889. /**
  67890. * Updates the effect with the current post process compile time values and recompiles the shader.
  67891. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  67892. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  67893. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  67894. * @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
  67895. * @param onCompiled Called when the shader has been compiled.
  67896. * @param onError Called if there is an error when compiling a shader.
  67897. */
  67898. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  67899. protected _updateParameters(onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  67900. /**
  67901. * Best kernels are odd numbers that when divided by 2, their integer part is even, so 5, 9 or 13.
  67902. * Other odd kernels optimize correctly but require proportionally more samples, even kernels are
  67903. * possible but will produce minor visual artifacts. Since each new kernel requires a new shader we
  67904. * want to minimize kernel changes, having gaps between physical kernels is helpful in that regard.
  67905. * The gaps between physical kernels are compensated for in the weighting of the samples
  67906. * @param idealKernel Ideal blur kernel.
  67907. * @return Nearest best kernel.
  67908. */
  67909. protected _nearestBestKernel(idealKernel: number): number;
  67910. /**
  67911. * Calculates the value of a Gaussian distribution with sigma 3 at a given point.
  67912. * @param x The point on the Gaussian distribution to sample.
  67913. * @return the value of the Gaussian function at x.
  67914. */
  67915. protected _gaussianWeight(x: number): number;
  67916. /**
  67917. * Generates a string that can be used as a floating point number in GLSL.
  67918. * @param x Value to print.
  67919. * @param decimalFigures Number of decimal places to print the number to (excluding trailing 0s).
  67920. * @return GLSL float string.
  67921. */
  67922. protected _glslFloat(x: number, decimalFigures?: number): string;
  67923. }
  67924. }
  67925. declare module BABYLON {
  67926. /** @hidden */
  67927. export var shadowMapPixelShader: {
  67928. name: string;
  67929. shader: string;
  67930. };
  67931. }
  67932. declare module BABYLON {
  67933. /** @hidden */
  67934. export var bonesDeclaration: {
  67935. name: string;
  67936. shader: string;
  67937. };
  67938. }
  67939. declare module BABYLON {
  67940. /** @hidden */
  67941. export var morphTargetsVertexGlobalDeclaration: {
  67942. name: string;
  67943. shader: string;
  67944. };
  67945. }
  67946. declare module BABYLON {
  67947. /** @hidden */
  67948. export var morphTargetsVertexDeclaration: {
  67949. name: string;
  67950. shader: string;
  67951. };
  67952. }
  67953. declare module BABYLON {
  67954. /** @hidden */
  67955. export var instancesDeclaration: {
  67956. name: string;
  67957. shader: string;
  67958. };
  67959. }
  67960. declare module BABYLON {
  67961. /** @hidden */
  67962. export var helperFunctions: {
  67963. name: string;
  67964. shader: string;
  67965. };
  67966. }
  67967. declare module BABYLON {
  67968. /** @hidden */
  67969. export var morphTargetsVertex: {
  67970. name: string;
  67971. shader: string;
  67972. };
  67973. }
  67974. declare module BABYLON {
  67975. /** @hidden */
  67976. export var instancesVertex: {
  67977. name: string;
  67978. shader: string;
  67979. };
  67980. }
  67981. declare module BABYLON {
  67982. /** @hidden */
  67983. export var bonesVertex: {
  67984. name: string;
  67985. shader: string;
  67986. };
  67987. }
  67988. declare module BABYLON {
  67989. /** @hidden */
  67990. export var shadowMapVertexShader: {
  67991. name: string;
  67992. shader: string;
  67993. };
  67994. }
  67995. declare module BABYLON {
  67996. /** @hidden */
  67997. export var depthBoxBlurPixelShader: {
  67998. name: string;
  67999. shader: string;
  68000. };
  68001. }
  68002. declare module BABYLON {
  68003. /**
  68004. * Defines the options associated with the creation of a custom shader for a shadow generator.
  68005. */
  68006. export interface ICustomShaderOptions {
  68007. /**
  68008. * Gets or sets the custom shader name to use
  68009. */
  68010. shaderName: string;
  68011. /**
  68012. * The list of attribute names used in the shader
  68013. */
  68014. attributes?: string[];
  68015. /**
  68016. * The list of unifrom names used in the shader
  68017. */
  68018. uniforms?: string[];
  68019. /**
  68020. * The list of sampler names used in the shader
  68021. */
  68022. samplers?: string[];
  68023. /**
  68024. * The list of defines used in the shader
  68025. */
  68026. defines?: string[];
  68027. }
  68028. /**
  68029. * Interface to implement to create a shadow generator compatible with BJS.
  68030. */
  68031. export interface IShadowGenerator {
  68032. /**
  68033. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  68034. * @returns The render target texture if present otherwise, null
  68035. */
  68036. getShadowMap(): Nullable<RenderTargetTexture>;
  68037. /**
  68038. * Gets the RTT used during rendering (can be a blurred version of the shadow map or the shadow map itself).
  68039. * @returns The render target texture if the shadow map is present otherwise, null
  68040. */
  68041. getShadowMapForRendering(): Nullable<RenderTargetTexture>;
  68042. /**
  68043. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  68044. * @param subMesh The submesh we want to render in the shadow map
  68045. * @param useInstances Defines wether will draw in the map using instances
  68046. * @returns true if ready otherwise, false
  68047. */
  68048. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  68049. /**
  68050. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  68051. * @param defines Defines of the material we want to update
  68052. * @param lightIndex Index of the light in the enabled light list of the material
  68053. */
  68054. prepareDefines(defines: MaterialDefines, lightIndex: number): void;
  68055. /**
  68056. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  68057. * defined in the generator but impacting the effect).
  68058. * It implies the unifroms available on the materials are the standard BJS ones.
  68059. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  68060. * @param effect The effect we are binfing the information for
  68061. */
  68062. bindShadowLight(lightIndex: string, effect: Effect): void;
  68063. /**
  68064. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  68065. * (eq to shadow prjection matrix * light transform matrix)
  68066. * @returns The transform matrix used to create the shadow map
  68067. */
  68068. getTransformMatrix(): Matrix;
  68069. /**
  68070. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  68071. * Cube and 2D textures for instance.
  68072. */
  68073. recreateShadowMap(): void;
  68074. /**
  68075. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  68076. * @param onCompiled Callback triggered at the and of the effects compilation
  68077. * @param options Sets of optional options forcing the compilation with different modes
  68078. */
  68079. forceCompilation(onCompiled?: (generator: ShadowGenerator) => void, options?: Partial<{
  68080. useInstances: boolean;
  68081. }>): void;
  68082. /**
  68083. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  68084. * @param options Sets of optional options forcing the compilation with different modes
  68085. * @returns A promise that resolves when the compilation completes
  68086. */
  68087. forceCompilationAsync(options?: Partial<{
  68088. useInstances: boolean;
  68089. }>): Promise<void>;
  68090. /**
  68091. * Serializes the shadow generator setup to a json object.
  68092. * @returns The serialized JSON object
  68093. */
  68094. serialize(): any;
  68095. /**
  68096. * Disposes the Shadow map and related Textures and effects.
  68097. */
  68098. dispose(): void;
  68099. }
  68100. /**
  68101. * Default implementation IShadowGenerator.
  68102. * This is the main object responsible of generating shadows in the framework.
  68103. * Documentation: https://doc.babylonjs.com/babylon101/shadows
  68104. */
  68105. export class ShadowGenerator implements IShadowGenerator {
  68106. /**
  68107. * Shadow generator mode None: no filtering applied.
  68108. */
  68109. static readonly FILTER_NONE: number;
  68110. /**
  68111. * Shadow generator mode ESM: Exponential Shadow Mapping.
  68112. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  68113. */
  68114. static readonly FILTER_EXPONENTIALSHADOWMAP: number;
  68115. /**
  68116. * Shadow generator mode Poisson Sampling: Percentage Closer Filtering.
  68117. * (Multiple Tap around evenly distributed around the pixel are used to evaluate the shadow strength)
  68118. */
  68119. static readonly FILTER_POISSONSAMPLING: number;
  68120. /**
  68121. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping.
  68122. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  68123. */
  68124. static readonly FILTER_BLUREXPONENTIALSHADOWMAP: number;
  68125. /**
  68126. * Shadow generator mode ESM: Exponential Shadow Mapping using the inverse of the exponential preventing
  68127. * edge artifacts on steep falloff.
  68128. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  68129. */
  68130. static readonly FILTER_CLOSEEXPONENTIALSHADOWMAP: number;
  68131. /**
  68132. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping using the inverse of the exponential preventing
  68133. * edge artifacts on steep falloff.
  68134. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  68135. */
  68136. static readonly FILTER_BLURCLOSEEXPONENTIALSHADOWMAP: number;
  68137. /**
  68138. * Shadow generator mode PCF: Percentage Closer Filtering
  68139. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  68140. * (https://developer.nvidia.com/gpugems/GPUGems/gpugems_ch11.html)
  68141. */
  68142. static readonly FILTER_PCF: number;
  68143. /**
  68144. * Shadow generator mode PCSS: Percentage Closering Soft Shadow.
  68145. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  68146. * Contact Hardening
  68147. */
  68148. static readonly FILTER_PCSS: number;
  68149. /**
  68150. * Reserved for PCF and PCSS
  68151. * Highest Quality.
  68152. *
  68153. * Execute PCF on a 5*5 kernel improving a lot the shadow aliasing artifacts.
  68154. *
  68155. * Execute PCSS with 32 taps blocker search and 64 taps PCF.
  68156. */
  68157. static readonly QUALITY_HIGH: number;
  68158. /**
  68159. * Reserved for PCF and PCSS
  68160. * Good tradeoff for quality/perf cross devices
  68161. *
  68162. * Execute PCF on a 3*3 kernel.
  68163. *
  68164. * Execute PCSS with 16 taps blocker search and 32 taps PCF.
  68165. */
  68166. static readonly QUALITY_MEDIUM: number;
  68167. /**
  68168. * Reserved for PCF and PCSS
  68169. * The lowest quality but the fastest.
  68170. *
  68171. * Execute PCF on a 1*1 kernel.
  68172. *
  68173. * Execute PCSS with 16 taps blocker search and 16 taps PCF.
  68174. */
  68175. static readonly QUALITY_LOW: number;
  68176. /** Gets or sets the custom shader name to use */
  68177. customShaderOptions: ICustomShaderOptions;
  68178. /**
  68179. * Observable triggered before the shadow is rendered. Can be used to update internal effect state
  68180. */
  68181. onBeforeShadowMapRenderObservable: Observable<Effect>;
  68182. /**
  68183. * Observable triggered before a mesh is rendered in the shadow map.
  68184. * Can be used to update internal effect state (that you can get from the onBeforeShadowMapRenderObservable)
  68185. */
  68186. onBeforeShadowMapRenderMeshObservable: Observable<Mesh>;
  68187. private _bias;
  68188. /**
  68189. * Gets the bias: offset applied on the depth preventing acnea (in light direction).
  68190. */
  68191. /**
  68192. * Sets the bias: offset applied on the depth preventing acnea (in light direction).
  68193. */
  68194. bias: number;
  68195. private _normalBias;
  68196. /**
  68197. * Gets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  68198. */
  68199. /**
  68200. * Sets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  68201. */
  68202. normalBias: number;
  68203. private _blurBoxOffset;
  68204. /**
  68205. * Gets the blur box offset: offset applied during the blur pass.
  68206. * Only useful if useKernelBlur = false
  68207. */
  68208. /**
  68209. * Sets the blur box offset: offset applied during the blur pass.
  68210. * Only useful if useKernelBlur = false
  68211. */
  68212. blurBoxOffset: number;
  68213. private _blurScale;
  68214. /**
  68215. * Gets the blur scale: scale of the blurred texture compared to the main shadow map.
  68216. * 2 means half of the size.
  68217. */
  68218. /**
  68219. * Sets the blur scale: scale of the blurred texture compared to the main shadow map.
  68220. * 2 means half of the size.
  68221. */
  68222. blurScale: number;
  68223. private _blurKernel;
  68224. /**
  68225. * Gets the blur kernel: kernel size of the blur pass.
  68226. * Only useful if useKernelBlur = true
  68227. */
  68228. /**
  68229. * Sets the blur kernel: kernel size of the blur pass.
  68230. * Only useful if useKernelBlur = true
  68231. */
  68232. blurKernel: number;
  68233. private _useKernelBlur;
  68234. /**
  68235. * Gets whether the blur pass is a kernel blur (if true) or box blur.
  68236. * Only useful in filtered mode (useBlurExponentialShadowMap...)
  68237. */
  68238. /**
  68239. * Sets whether the blur pass is a kernel blur (if true) or box blur.
  68240. * Only useful in filtered mode (useBlurExponentialShadowMap...)
  68241. */
  68242. useKernelBlur: boolean;
  68243. private _depthScale;
  68244. /**
  68245. * Gets the depth scale used in ESM mode.
  68246. */
  68247. /**
  68248. * Sets the depth scale used in ESM mode.
  68249. * This can override the scale stored on the light.
  68250. */
  68251. depthScale: number;
  68252. private _filter;
  68253. /**
  68254. * Gets the current mode of the shadow generator (normal, PCF, ESM...).
  68255. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  68256. */
  68257. /**
  68258. * Sets the current mode of the shadow generator (normal, PCF, ESM...).
  68259. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  68260. */
  68261. filter: number;
  68262. /**
  68263. * Gets if the current filter is set to Poisson Sampling.
  68264. */
  68265. /**
  68266. * Sets the current filter to Poisson Sampling.
  68267. */
  68268. usePoissonSampling: boolean;
  68269. /**
  68270. * Gets if the current filter is set to ESM.
  68271. */
  68272. /**
  68273. * Sets the current filter is to ESM.
  68274. */
  68275. useExponentialShadowMap: boolean;
  68276. /**
  68277. * Gets if the current filter is set to filtered ESM.
  68278. */
  68279. /**
  68280. * Gets if the current filter is set to filtered ESM.
  68281. */
  68282. useBlurExponentialShadowMap: boolean;
  68283. /**
  68284. * Gets if the current filter is set to "close ESM" (using the inverse of the
  68285. * exponential to prevent steep falloff artifacts).
  68286. */
  68287. /**
  68288. * Sets the current filter to "close ESM" (using the inverse of the
  68289. * exponential to prevent steep falloff artifacts).
  68290. */
  68291. useCloseExponentialShadowMap: boolean;
  68292. /**
  68293. * Gets if the current filter is set to filtered "close ESM" (using the inverse of the
  68294. * exponential to prevent steep falloff artifacts).
  68295. */
  68296. /**
  68297. * Sets the current filter to filtered "close ESM" (using the inverse of the
  68298. * exponential to prevent steep falloff artifacts).
  68299. */
  68300. useBlurCloseExponentialShadowMap: boolean;
  68301. /**
  68302. * Gets if the current filter is set to "PCF" (percentage closer filtering).
  68303. */
  68304. /**
  68305. * Sets the current filter to "PCF" (percentage closer filtering).
  68306. */
  68307. usePercentageCloserFiltering: boolean;
  68308. private _filteringQuality;
  68309. /**
  68310. * Gets the PCF or PCSS Quality.
  68311. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  68312. */
  68313. /**
  68314. * Sets the PCF or PCSS Quality.
  68315. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  68316. */
  68317. filteringQuality: number;
  68318. /**
  68319. * Gets if the current filter is set to "PCSS" (contact hardening).
  68320. */
  68321. /**
  68322. * Sets the current filter to "PCSS" (contact hardening).
  68323. */
  68324. useContactHardeningShadow: boolean;
  68325. private _contactHardeningLightSizeUVRatio;
  68326. /**
  68327. * Gets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  68328. * Using a ratio helps keeping shape stability independently of the map size.
  68329. *
  68330. * It does not account for the light projection as it was having too much
  68331. * instability during the light setup or during light position changes.
  68332. *
  68333. * Only valid if useContactHardeningShadow is true.
  68334. */
  68335. /**
  68336. * Sets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  68337. * Using a ratio helps keeping shape stability independently of the map size.
  68338. *
  68339. * It does not account for the light projection as it was having too much
  68340. * instability during the light setup or during light position changes.
  68341. *
  68342. * Only valid if useContactHardeningShadow is true.
  68343. */
  68344. contactHardeningLightSizeUVRatio: number;
  68345. private _darkness;
  68346. /**
  68347. * Returns the darkness value (float). This can only decrease the actual darkness of a shadow.
  68348. * 0 means strongest and 1 would means no shadow.
  68349. * @returns the darkness.
  68350. */
  68351. getDarkness(): number;
  68352. /**
  68353. * Sets the darkness value (float). This can only decrease the actual darkness of a shadow.
  68354. * @param darkness The darkness value 0 means strongest and 1 would means no shadow.
  68355. * @returns the shadow generator allowing fluent coding.
  68356. */
  68357. setDarkness(darkness: number): ShadowGenerator;
  68358. private _transparencyShadow;
  68359. /**
  68360. * Sets the ability to have transparent shadow (boolean).
  68361. * @param transparent True if transparent else False
  68362. * @returns the shadow generator allowing fluent coding
  68363. */
  68364. setTransparencyShadow(transparent: boolean): ShadowGenerator;
  68365. private _shadowMap;
  68366. private _shadowMap2;
  68367. /**
  68368. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  68369. * @returns The render target texture if present otherwise, null
  68370. */
  68371. getShadowMap(): Nullable<RenderTargetTexture>;
  68372. /**
  68373. * Gets the RTT used during rendering (can be a blurred version of the shadow map or the shadow map itself).
  68374. * @returns The render target texture if the shadow map is present otherwise, null
  68375. */
  68376. getShadowMapForRendering(): Nullable<RenderTargetTexture>;
  68377. /**
  68378. * Helper function to add a mesh and its descendants to the list of shadow casters.
  68379. * @param mesh Mesh to add
  68380. * @param includeDescendants boolean indicating if the descendants should be added. Default to true
  68381. * @returns the Shadow Generator itself
  68382. */
  68383. addShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  68384. /**
  68385. * Helper function to remove a mesh and its descendants from the list of shadow casters
  68386. * @param mesh Mesh to remove
  68387. * @param includeDescendants boolean indicating if the descendants should be removed. Default to true
  68388. * @returns the Shadow Generator itself
  68389. */
  68390. removeShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  68391. /**
  68392. * Controls the extent to which the shadows fade out at the edge of the frustum
  68393. * Used only by directionals and spots
  68394. */
  68395. frustumEdgeFalloff: number;
  68396. private _light;
  68397. /**
  68398. * Returns the associated light object.
  68399. * @returns the light generating the shadow
  68400. */
  68401. getLight(): IShadowLight;
  68402. /**
  68403. * If true the shadow map is generated by rendering the back face of the mesh instead of the front face.
  68404. * This can help with self-shadowing as the geometry making up the back of objects is slightly offset.
  68405. * It might on the other hand introduce peter panning.
  68406. */
  68407. forceBackFacesOnly: boolean;
  68408. private _scene;
  68409. private _lightDirection;
  68410. private _effect;
  68411. private _viewMatrix;
  68412. private _projectionMatrix;
  68413. private _transformMatrix;
  68414. private _cachedPosition;
  68415. private _cachedDirection;
  68416. private _cachedDefines;
  68417. private _currentRenderID;
  68418. private _boxBlurPostprocess;
  68419. private _kernelBlurXPostprocess;
  68420. private _kernelBlurYPostprocess;
  68421. private _blurPostProcesses;
  68422. private _mapSize;
  68423. private _currentFaceIndex;
  68424. private _currentFaceIndexCache;
  68425. private _textureType;
  68426. private _defaultTextureMatrix;
  68427. /** @hidden */
  68428. static _SceneComponentInitialization: (scene: Scene) => void;
  68429. /**
  68430. * Creates a ShadowGenerator object.
  68431. * A ShadowGenerator is the required tool to use the shadows.
  68432. * Each light casting shadows needs to use its own ShadowGenerator.
  68433. * Documentation : https://doc.babylonjs.com/babylon101/shadows
  68434. * @param mapSize The size of the texture what stores the shadows. Example : 1024.
  68435. * @param light The light object generating the shadows.
  68436. * @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.
  68437. */
  68438. constructor(mapSize: number, light: IShadowLight, usefulFloatFirst?: boolean);
  68439. private _initializeGenerator;
  68440. private _initializeShadowMap;
  68441. private _initializeBlurRTTAndPostProcesses;
  68442. private _renderForShadowMap;
  68443. private _renderSubMeshForShadowMap;
  68444. private _applyFilterValues;
  68445. /**
  68446. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  68447. * @param onCompiled Callback triggered at the and of the effects compilation
  68448. * @param options Sets of optional options forcing the compilation with different modes
  68449. */
  68450. forceCompilation(onCompiled?: (generator: ShadowGenerator) => void, options?: Partial<{
  68451. useInstances: boolean;
  68452. }>): void;
  68453. /**
  68454. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  68455. * @param options Sets of optional options forcing the compilation with different modes
  68456. * @returns A promise that resolves when the compilation completes
  68457. */
  68458. forceCompilationAsync(options?: Partial<{
  68459. useInstances: boolean;
  68460. }>): Promise<void>;
  68461. /**
  68462. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  68463. * @param subMesh The submesh we want to render in the shadow map
  68464. * @param useInstances Defines wether will draw in the map using instances
  68465. * @returns true if ready otherwise, false
  68466. */
  68467. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  68468. /**
  68469. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  68470. * @param defines Defines of the material we want to update
  68471. * @param lightIndex Index of the light in the enabled light list of the material
  68472. */
  68473. prepareDefines(defines: any, lightIndex: number): void;
  68474. /**
  68475. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  68476. * defined in the generator but impacting the effect).
  68477. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  68478. * @param effect The effect we are binfing the information for
  68479. */
  68480. bindShadowLight(lightIndex: string, effect: Effect): void;
  68481. /**
  68482. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  68483. * (eq to shadow prjection matrix * light transform matrix)
  68484. * @returns The transform matrix used to create the shadow map
  68485. */
  68486. getTransformMatrix(): Matrix;
  68487. /**
  68488. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  68489. * Cube and 2D textures for instance.
  68490. */
  68491. recreateShadowMap(): void;
  68492. private _disposeBlurPostProcesses;
  68493. private _disposeRTTandPostProcesses;
  68494. /**
  68495. * Disposes the ShadowGenerator.
  68496. * Returns nothing.
  68497. */
  68498. dispose(): void;
  68499. /**
  68500. * Serializes the shadow generator setup to a json object.
  68501. * @returns The serialized JSON object
  68502. */
  68503. serialize(): any;
  68504. /**
  68505. * Parses a serialized ShadowGenerator and returns a new ShadowGenerator.
  68506. * @param parsedShadowGenerator The JSON object to parse
  68507. * @param scene The scene to create the shadow map for
  68508. * @returns The parsed shadow generator
  68509. */
  68510. static Parse(parsedShadowGenerator: any, scene: Scene): ShadowGenerator;
  68511. }
  68512. }
  68513. declare module BABYLON {
  68514. /**
  68515. * Base class of all the lights in Babylon. It groups all the generic information about lights.
  68516. * Lights are used, as you would expect, to affect how meshes are seen, in terms of both illumination and colour.
  68517. * 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.
  68518. */
  68519. export abstract class Light extends Node {
  68520. /**
  68521. * Falloff Default: light is falling off following the material specification:
  68522. * standard material is using standard falloff whereas pbr material can request special falloff per materials.
  68523. */
  68524. static readonly FALLOFF_DEFAULT: number;
  68525. /**
  68526. * Falloff Physical: light is falling off following the inverse squared distance law.
  68527. */
  68528. static readonly FALLOFF_PHYSICAL: number;
  68529. /**
  68530. * Falloff gltf: light is falling off as described in the gltf moving to PBR document
  68531. * to enhance interoperability with other engines.
  68532. */
  68533. static readonly FALLOFF_GLTF: number;
  68534. /**
  68535. * Falloff Standard: light is falling off like in the standard material
  68536. * to enhance interoperability with other materials.
  68537. */
  68538. static readonly FALLOFF_STANDARD: number;
  68539. /**
  68540. * If every light affecting the material is in this lightmapMode,
  68541. * material.lightmapTexture adds or multiplies
  68542. * (depends on material.useLightmapAsShadowmap)
  68543. * after every other light calculations.
  68544. */
  68545. static readonly LIGHTMAP_DEFAULT: number;
  68546. /**
  68547. * material.lightmapTexture as only diffuse lighting from this light
  68548. * adds only specular lighting from this light
  68549. * adds dynamic shadows
  68550. */
  68551. static readonly LIGHTMAP_SPECULAR: number;
  68552. /**
  68553. * material.lightmapTexture as only lighting
  68554. * no light calculation from this light
  68555. * only adds dynamic shadows from this light
  68556. */
  68557. static readonly LIGHTMAP_SHADOWSONLY: number;
  68558. /**
  68559. * Each light type uses the default quantity according to its type:
  68560. * point/spot lights use luminous intensity
  68561. * directional lights use illuminance
  68562. */
  68563. static readonly INTENSITYMODE_AUTOMATIC: number;
  68564. /**
  68565. * lumen (lm)
  68566. */
  68567. static readonly INTENSITYMODE_LUMINOUSPOWER: number;
  68568. /**
  68569. * candela (lm/sr)
  68570. */
  68571. static readonly INTENSITYMODE_LUMINOUSINTENSITY: number;
  68572. /**
  68573. * lux (lm/m^2)
  68574. */
  68575. static readonly INTENSITYMODE_ILLUMINANCE: number;
  68576. /**
  68577. * nit (cd/m^2)
  68578. */
  68579. static readonly INTENSITYMODE_LUMINANCE: number;
  68580. /**
  68581. * Light type const id of the point light.
  68582. */
  68583. static readonly LIGHTTYPEID_POINTLIGHT: number;
  68584. /**
  68585. * Light type const id of the directional light.
  68586. */
  68587. static readonly LIGHTTYPEID_DIRECTIONALLIGHT: number;
  68588. /**
  68589. * Light type const id of the spot light.
  68590. */
  68591. static readonly LIGHTTYPEID_SPOTLIGHT: number;
  68592. /**
  68593. * Light type const id of the hemispheric light.
  68594. */
  68595. static readonly LIGHTTYPEID_HEMISPHERICLIGHT: number;
  68596. /**
  68597. * Diffuse gives the basic color to an object.
  68598. */
  68599. diffuse: Color3;
  68600. /**
  68601. * Specular produces a highlight color on an object.
  68602. * Note: This is note affecting PBR materials.
  68603. */
  68604. specular: Color3;
  68605. /**
  68606. * Defines the falloff type for this light. This lets overrriding how punctual light are
  68607. * falling off base on range or angle.
  68608. * This can be set to any values in Light.FALLOFF_x.
  68609. *
  68610. * Note: This is only useful for PBR Materials at the moment. This could be extended if required to
  68611. * other types of materials.
  68612. */
  68613. falloffType: number;
  68614. /**
  68615. * Strength of the light.
  68616. * Note: By default it is define in the framework own unit.
  68617. * Note: In PBR materials the intensityMode can be use to chose what unit the intensity is defined in.
  68618. */
  68619. intensity: number;
  68620. private _range;
  68621. protected _inverseSquaredRange: number;
  68622. /**
  68623. * Defines how far from the source the light is impacting in scene units.
  68624. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  68625. */
  68626. /**
  68627. * Defines how far from the source the light is impacting in scene units.
  68628. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  68629. */
  68630. range: number;
  68631. /**
  68632. * Cached photometric scale default to 1.0 as the automatic intensity mode defaults to 1.0 for every type
  68633. * of light.
  68634. */
  68635. private _photometricScale;
  68636. private _intensityMode;
  68637. /**
  68638. * Gets the photometric scale used to interpret the intensity.
  68639. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  68640. */
  68641. /**
  68642. * Sets the photometric scale used to interpret the intensity.
  68643. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  68644. */
  68645. intensityMode: number;
  68646. private _radius;
  68647. /**
  68648. * Gets the light radius used by PBR Materials to simulate soft area lights.
  68649. */
  68650. /**
  68651. * sets the light radius used by PBR Materials to simulate soft area lights.
  68652. */
  68653. radius: number;
  68654. private _renderPriority;
  68655. /**
  68656. * Defines the rendering priority of the lights. It can help in case of fallback or number of lights
  68657. * exceeding the number allowed of the materials.
  68658. */
  68659. renderPriority: number;
  68660. private _shadowEnabled;
  68661. /**
  68662. * Gets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  68663. * the current shadow generator.
  68664. */
  68665. /**
  68666. * Sets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  68667. * the current shadow generator.
  68668. */
  68669. shadowEnabled: boolean;
  68670. private _includedOnlyMeshes;
  68671. /**
  68672. * Gets the only meshes impacted by this light.
  68673. */
  68674. /**
  68675. * Sets the only meshes impacted by this light.
  68676. */
  68677. includedOnlyMeshes: AbstractMesh[];
  68678. private _excludedMeshes;
  68679. /**
  68680. * Gets the meshes not impacted by this light.
  68681. */
  68682. /**
  68683. * Sets the meshes not impacted by this light.
  68684. */
  68685. excludedMeshes: AbstractMesh[];
  68686. private _excludeWithLayerMask;
  68687. /**
  68688. * Gets the layer id use to find what meshes are not impacted by the light.
  68689. * Inactive if 0
  68690. */
  68691. /**
  68692. * Sets the layer id use to find what meshes are not impacted by the light.
  68693. * Inactive if 0
  68694. */
  68695. excludeWithLayerMask: number;
  68696. private _includeOnlyWithLayerMask;
  68697. /**
  68698. * Gets the layer id use to find what meshes are impacted by the light.
  68699. * Inactive if 0
  68700. */
  68701. /**
  68702. * Sets the layer id use to find what meshes are impacted by the light.
  68703. * Inactive if 0
  68704. */
  68705. includeOnlyWithLayerMask: number;
  68706. private _lightmapMode;
  68707. /**
  68708. * Gets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  68709. */
  68710. /**
  68711. * Sets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  68712. */
  68713. lightmapMode: number;
  68714. /**
  68715. * Shadow generator associted to the light.
  68716. * @hidden Internal use only.
  68717. */
  68718. _shadowGenerator: Nullable<IShadowGenerator>;
  68719. /**
  68720. * @hidden Internal use only.
  68721. */
  68722. _excludedMeshesIds: string[];
  68723. /**
  68724. * @hidden Internal use only.
  68725. */
  68726. _includedOnlyMeshesIds: string[];
  68727. /**
  68728. * The current light unifom buffer.
  68729. * @hidden Internal use only.
  68730. */
  68731. _uniformBuffer: UniformBuffer;
  68732. /**
  68733. * Creates a Light object in the scene.
  68734. * Documentation : https://doc.babylonjs.com/babylon101/lights
  68735. * @param name The firendly name of the light
  68736. * @param scene The scene the light belongs too
  68737. */
  68738. constructor(name: string, scene: Scene);
  68739. protected abstract _buildUniformLayout(): void;
  68740. /**
  68741. * Sets the passed Effect "effect" with the Light information.
  68742. * @param effect The effect to update
  68743. * @param lightIndex The index of the light in the effect to update
  68744. * @returns The light
  68745. */
  68746. abstract transferToEffect(effect: Effect, lightIndex: string): Light;
  68747. /**
  68748. * Returns the string "Light".
  68749. * @returns the class name
  68750. */
  68751. getClassName(): string;
  68752. /** @hidden */
  68753. readonly _isLight: boolean;
  68754. /**
  68755. * Converts the light information to a readable string for debug purpose.
  68756. * @param fullDetails Supports for multiple levels of logging within scene loading
  68757. * @returns the human readable light info
  68758. */
  68759. toString(fullDetails?: boolean): string;
  68760. /** @hidden */
  68761. protected _syncParentEnabledState(): void;
  68762. /**
  68763. * Set the enabled state of this node.
  68764. * @param value - the new enabled state
  68765. */
  68766. setEnabled(value: boolean): void;
  68767. /**
  68768. * Returns the Light associated shadow generator if any.
  68769. * @return the associated shadow generator.
  68770. */
  68771. getShadowGenerator(): Nullable<IShadowGenerator>;
  68772. /**
  68773. * Returns a Vector3, the absolute light position in the World.
  68774. * @returns the world space position of the light
  68775. */
  68776. getAbsolutePosition(): Vector3;
  68777. /**
  68778. * Specifies if the light will affect the passed mesh.
  68779. * @param mesh The mesh to test against the light
  68780. * @return true the mesh is affected otherwise, false.
  68781. */
  68782. canAffectMesh(mesh: AbstractMesh): boolean;
  68783. /**
  68784. * Sort function to order lights for rendering.
  68785. * @param a First Light object to compare to second.
  68786. * @param b Second Light object to compare first.
  68787. * @return -1 to reduce's a's index relative to be, 0 for no change, 1 to increase a's index relative to b.
  68788. */
  68789. static CompareLightsPriority(a: Light, b: Light): number;
  68790. /**
  68791. * Releases resources associated with this node.
  68792. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  68793. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  68794. */
  68795. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  68796. /**
  68797. * Returns the light type ID (integer).
  68798. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  68799. */
  68800. getTypeID(): number;
  68801. /**
  68802. * Returns the intensity scaled by the Photometric Scale according to the light type and intensity mode.
  68803. * @returns the scaled intensity in intensity mode unit
  68804. */
  68805. getScaledIntensity(): number;
  68806. /**
  68807. * Returns a new Light object, named "name", from the current one.
  68808. * @param name The name of the cloned light
  68809. * @returns the new created light
  68810. */
  68811. clone(name: string): Nullable<Light>;
  68812. /**
  68813. * Serializes the current light into a Serialization object.
  68814. * @returns the serialized object.
  68815. */
  68816. serialize(): any;
  68817. /**
  68818. * Creates a new typed light from the passed type (integer) : point light = 0, directional light = 1, spot light = 2, hemispheric light = 3.
  68819. * This new light is named "name" and added to the passed scene.
  68820. * @param type Type according to the types available in Light.LIGHTTYPEID_x
  68821. * @param name The friendly name of the light
  68822. * @param scene The scene the new light will belong to
  68823. * @returns the constructor function
  68824. */
  68825. static GetConstructorFromName(type: number, name: string, scene: Scene): Nullable<() => Light>;
  68826. /**
  68827. * Parses the passed "parsedLight" and returns a new instanced Light from this parsing.
  68828. * @param parsedLight The JSON representation of the light
  68829. * @param scene The scene to create the parsed light in
  68830. * @returns the created light after parsing
  68831. */
  68832. static Parse(parsedLight: any, scene: Scene): Nullable<Light>;
  68833. private _hookArrayForExcluded;
  68834. private _hookArrayForIncludedOnly;
  68835. private _resyncMeshes;
  68836. /**
  68837. * Forces the meshes to update their light related information in their rendering used effects
  68838. * @hidden Internal Use Only
  68839. */
  68840. _markMeshesAsLightDirty(): void;
  68841. /**
  68842. * Recomputes the cached photometric scale if needed.
  68843. */
  68844. private _computePhotometricScale;
  68845. /**
  68846. * Returns the Photometric Scale according to the light type and intensity mode.
  68847. */
  68848. private _getPhotometricScale;
  68849. /**
  68850. * Reorder the light in the scene according to their defined priority.
  68851. * @hidden Internal Use Only
  68852. */
  68853. _reorderLightsInScene(): void;
  68854. /**
  68855. * Prepares the list of defines specific to the light type.
  68856. * @param defines the list of defines
  68857. * @param lightIndex defines the index of the light for the effect
  68858. */
  68859. abstract prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  68860. }
  68861. }
  68862. declare module BABYLON {
  68863. /**
  68864. * Interface used to define Action
  68865. */
  68866. export interface IAction {
  68867. /**
  68868. * Trigger for the action
  68869. */
  68870. trigger: number;
  68871. /** Options of the trigger */
  68872. triggerOptions: any;
  68873. /**
  68874. * Gets the trigger parameters
  68875. * @returns the trigger parameters
  68876. */
  68877. getTriggerParameter(): any;
  68878. /**
  68879. * Internal only - executes current action event
  68880. * @hidden
  68881. */
  68882. _executeCurrent(evt?: ActionEvent): void;
  68883. /**
  68884. * Serialize placeholder for child classes
  68885. * @param parent of child
  68886. * @returns the serialized object
  68887. */
  68888. serialize(parent: any): any;
  68889. /**
  68890. * Internal only
  68891. * @hidden
  68892. */
  68893. _prepare(): void;
  68894. /**
  68895. * Internal only - manager for action
  68896. * @hidden
  68897. */
  68898. _actionManager: AbstractActionManager;
  68899. }
  68900. /**
  68901. * The action to be carried out following a trigger
  68902. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#available-actions
  68903. */
  68904. export class Action implements IAction {
  68905. /** the trigger, with or without parameters, for the action */
  68906. triggerOptions: any;
  68907. /**
  68908. * Trigger for the action
  68909. */
  68910. trigger: number;
  68911. /**
  68912. * Internal only - manager for action
  68913. * @hidden
  68914. */
  68915. _actionManager: ActionManager;
  68916. private _nextActiveAction;
  68917. private _child;
  68918. private _condition?;
  68919. private _triggerParameter;
  68920. /**
  68921. * An event triggered prior to action being executed.
  68922. */
  68923. onBeforeExecuteObservable: Observable<Action>;
  68924. /**
  68925. * Creates a new Action
  68926. * @param triggerOptions the trigger, with or without parameters, for the action
  68927. * @param condition an optional determinant of action
  68928. */
  68929. constructor(
  68930. /** the trigger, with or without parameters, for the action */
  68931. triggerOptions: any, condition?: Condition);
  68932. /**
  68933. * Internal only
  68934. * @hidden
  68935. */
  68936. _prepare(): void;
  68937. /**
  68938. * Gets the trigger parameters
  68939. * @returns the trigger parameters
  68940. */
  68941. getTriggerParameter(): any;
  68942. /**
  68943. * Internal only - executes current action event
  68944. * @hidden
  68945. */
  68946. _executeCurrent(evt?: ActionEvent): void;
  68947. /**
  68948. * Execute placeholder for child classes
  68949. * @param evt optional action event
  68950. */
  68951. execute(evt?: ActionEvent): void;
  68952. /**
  68953. * Skips to next active action
  68954. */
  68955. skipToNextActiveAction(): void;
  68956. /**
  68957. * Adds action to chain of actions, may be a DoNothingAction
  68958. * @param action defines the next action to execute
  68959. * @returns The action passed in
  68960. * @see https://www.babylonjs-playground.com/#1T30HR#0
  68961. */
  68962. then(action: Action): Action;
  68963. /**
  68964. * Internal only
  68965. * @hidden
  68966. */
  68967. _getProperty(propertyPath: string): string;
  68968. /**
  68969. * Internal only
  68970. * @hidden
  68971. */
  68972. _getEffectiveTarget(target: any, propertyPath: string): any;
  68973. /**
  68974. * Serialize placeholder for child classes
  68975. * @param parent of child
  68976. * @returns the serialized object
  68977. */
  68978. serialize(parent: any): any;
  68979. /**
  68980. * Internal only called by serialize
  68981. * @hidden
  68982. */
  68983. protected _serialize(serializedAction: any, parent?: any): any;
  68984. /**
  68985. * Internal only
  68986. * @hidden
  68987. */
  68988. static _SerializeValueAsString: (value: any) => string;
  68989. /**
  68990. * Internal only
  68991. * @hidden
  68992. */
  68993. static _GetTargetProperty: (target: Scene | Node) => {
  68994. name: string;
  68995. targetType: string;
  68996. value: string;
  68997. };
  68998. }
  68999. }
  69000. declare module BABYLON {
  69001. /**
  69002. * A Condition applied to an Action
  69003. */
  69004. export class Condition {
  69005. /**
  69006. * Internal only - manager for action
  69007. * @hidden
  69008. */
  69009. _actionManager: ActionManager;
  69010. /**
  69011. * Internal only
  69012. * @hidden
  69013. */
  69014. _evaluationId: number;
  69015. /**
  69016. * Internal only
  69017. * @hidden
  69018. */
  69019. _currentResult: boolean;
  69020. /**
  69021. * Creates a new Condition
  69022. * @param actionManager the manager of the action the condition is applied to
  69023. */
  69024. constructor(actionManager: ActionManager);
  69025. /**
  69026. * Check if the current condition is valid
  69027. * @returns a boolean
  69028. */
  69029. isValid(): boolean;
  69030. /**
  69031. * Internal only
  69032. * @hidden
  69033. */
  69034. _getProperty(propertyPath: string): string;
  69035. /**
  69036. * Internal only
  69037. * @hidden
  69038. */
  69039. _getEffectiveTarget(target: any, propertyPath: string): any;
  69040. /**
  69041. * Serialize placeholder for child classes
  69042. * @returns the serialized object
  69043. */
  69044. serialize(): any;
  69045. /**
  69046. * Internal only
  69047. * @hidden
  69048. */
  69049. protected _serialize(serializedCondition: any): any;
  69050. }
  69051. /**
  69052. * Defines specific conditional operators as extensions of Condition
  69053. */
  69054. export class ValueCondition extends Condition {
  69055. /** path to specify the property of the target the conditional operator uses */
  69056. propertyPath: string;
  69057. /** the value compared by the conditional operator against the current value of the property */
  69058. value: any;
  69059. /** the conditional operator, default ValueCondition.IsEqual */
  69060. operator: number;
  69061. /**
  69062. * Internal only
  69063. * @hidden
  69064. */
  69065. private static _IsEqual;
  69066. /**
  69067. * Internal only
  69068. * @hidden
  69069. */
  69070. private static _IsDifferent;
  69071. /**
  69072. * Internal only
  69073. * @hidden
  69074. */
  69075. private static _IsGreater;
  69076. /**
  69077. * Internal only
  69078. * @hidden
  69079. */
  69080. private static _IsLesser;
  69081. /**
  69082. * returns the number for IsEqual
  69083. */
  69084. static readonly IsEqual: number;
  69085. /**
  69086. * Returns the number for IsDifferent
  69087. */
  69088. static readonly IsDifferent: number;
  69089. /**
  69090. * Returns the number for IsGreater
  69091. */
  69092. static readonly IsGreater: number;
  69093. /**
  69094. * Returns the number for IsLesser
  69095. */
  69096. static readonly IsLesser: number;
  69097. /**
  69098. * Internal only The action manager for the condition
  69099. * @hidden
  69100. */
  69101. _actionManager: ActionManager;
  69102. /**
  69103. * Internal only
  69104. * @hidden
  69105. */
  69106. private _target;
  69107. /**
  69108. * Internal only
  69109. * @hidden
  69110. */
  69111. private _effectiveTarget;
  69112. /**
  69113. * Internal only
  69114. * @hidden
  69115. */
  69116. private _property;
  69117. /**
  69118. * Creates a new ValueCondition
  69119. * @param actionManager manager for the action the condition applies to
  69120. * @param target for the action
  69121. * @param propertyPath path to specify the property of the target the conditional operator uses
  69122. * @param value the value compared by the conditional operator against the current value of the property
  69123. * @param operator the conditional operator, default ValueCondition.IsEqual
  69124. */
  69125. constructor(actionManager: ActionManager, target: any,
  69126. /** path to specify the property of the target the conditional operator uses */
  69127. propertyPath: string,
  69128. /** the value compared by the conditional operator against the current value of the property */
  69129. value: any,
  69130. /** the conditional operator, default ValueCondition.IsEqual */
  69131. operator?: number);
  69132. /**
  69133. * Compares the given value with the property value for the specified conditional operator
  69134. * @returns the result of the comparison
  69135. */
  69136. isValid(): boolean;
  69137. /**
  69138. * Serialize the ValueCondition into a JSON compatible object
  69139. * @returns serialization object
  69140. */
  69141. serialize(): any;
  69142. /**
  69143. * Gets the name of the conditional operator for the ValueCondition
  69144. * @param operator the conditional operator
  69145. * @returns the name
  69146. */
  69147. static GetOperatorName(operator: number): string;
  69148. }
  69149. /**
  69150. * Defines a predicate condition as an extension of Condition
  69151. */
  69152. export class PredicateCondition extends Condition {
  69153. /** defines the predicate function used to validate the condition */
  69154. predicate: () => boolean;
  69155. /**
  69156. * Internal only - manager for action
  69157. * @hidden
  69158. */
  69159. _actionManager: ActionManager;
  69160. /**
  69161. * Creates a new PredicateCondition
  69162. * @param actionManager manager for the action the condition applies to
  69163. * @param predicate defines the predicate function used to validate the condition
  69164. */
  69165. constructor(actionManager: ActionManager,
  69166. /** defines the predicate function used to validate the condition */
  69167. predicate: () => boolean);
  69168. /**
  69169. * @returns the validity of the predicate condition
  69170. */
  69171. isValid(): boolean;
  69172. }
  69173. /**
  69174. * Defines a state condition as an extension of Condition
  69175. */
  69176. export class StateCondition extends Condition {
  69177. /** Value to compare with target state */
  69178. value: string;
  69179. /**
  69180. * Internal only - manager for action
  69181. * @hidden
  69182. */
  69183. _actionManager: ActionManager;
  69184. /**
  69185. * Internal only
  69186. * @hidden
  69187. */
  69188. private _target;
  69189. /**
  69190. * Creates a new StateCondition
  69191. * @param actionManager manager for the action the condition applies to
  69192. * @param target of the condition
  69193. * @param value to compare with target state
  69194. */
  69195. constructor(actionManager: ActionManager, target: any,
  69196. /** Value to compare with target state */
  69197. value: string);
  69198. /**
  69199. * Gets a boolean indicating if the current condition is met
  69200. * @returns the validity of the state
  69201. */
  69202. isValid(): boolean;
  69203. /**
  69204. * Serialize the StateCondition into a JSON compatible object
  69205. * @returns serialization object
  69206. */
  69207. serialize(): any;
  69208. }
  69209. }
  69210. declare module BABYLON {
  69211. /**
  69212. * This defines an action responsible to toggle a boolean once triggered.
  69213. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  69214. */
  69215. export class SwitchBooleanAction extends Action {
  69216. /**
  69217. * The path to the boolean property in the target object
  69218. */
  69219. propertyPath: string;
  69220. private _target;
  69221. private _effectiveTarget;
  69222. private _property;
  69223. /**
  69224. * Instantiate the action
  69225. * @param triggerOptions defines the trigger options
  69226. * @param target defines the object containing the boolean
  69227. * @param propertyPath defines the path to the boolean property in the target object
  69228. * @param condition defines the trigger related conditions
  69229. */
  69230. constructor(triggerOptions: any, target: any, propertyPath: string, condition?: Condition);
  69231. /** @hidden */
  69232. _prepare(): void;
  69233. /**
  69234. * Execute the action toggle the boolean value.
  69235. */
  69236. execute(): void;
  69237. /**
  69238. * Serializes the actions and its related information.
  69239. * @param parent defines the object to serialize in
  69240. * @returns the serialized object
  69241. */
  69242. serialize(parent: any): any;
  69243. }
  69244. /**
  69245. * This defines an action responsible to set a the state field of the target
  69246. * to a desired value once triggered.
  69247. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  69248. */
  69249. export class SetStateAction extends Action {
  69250. /**
  69251. * The value to store in the state field.
  69252. */
  69253. value: string;
  69254. private _target;
  69255. /**
  69256. * Instantiate the action
  69257. * @param triggerOptions defines the trigger options
  69258. * @param target defines the object containing the state property
  69259. * @param value defines the value to store in the state field
  69260. * @param condition defines the trigger related conditions
  69261. */
  69262. constructor(triggerOptions: any, target: any, value: string, condition?: Condition);
  69263. /**
  69264. * Execute the action and store the value on the target state property.
  69265. */
  69266. execute(): void;
  69267. /**
  69268. * Serializes the actions and its related information.
  69269. * @param parent defines the object to serialize in
  69270. * @returns the serialized object
  69271. */
  69272. serialize(parent: any): any;
  69273. }
  69274. /**
  69275. * This defines an action responsible to set a property of the target
  69276. * to a desired value once triggered.
  69277. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  69278. */
  69279. export class SetValueAction extends Action {
  69280. /**
  69281. * The path of the property to set in the target.
  69282. */
  69283. propertyPath: string;
  69284. /**
  69285. * The value to set in the property
  69286. */
  69287. value: any;
  69288. private _target;
  69289. private _effectiveTarget;
  69290. private _property;
  69291. /**
  69292. * Instantiate the action
  69293. * @param triggerOptions defines the trigger options
  69294. * @param target defines the object containing the property
  69295. * @param propertyPath defines the path of the property to set in the target
  69296. * @param value defines the value to set in the property
  69297. * @param condition defines the trigger related conditions
  69298. */
  69299. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  69300. /** @hidden */
  69301. _prepare(): void;
  69302. /**
  69303. * Execute the action and set the targetted property to the desired value.
  69304. */
  69305. execute(): void;
  69306. /**
  69307. * Serializes the actions and its related information.
  69308. * @param parent defines the object to serialize in
  69309. * @returns the serialized object
  69310. */
  69311. serialize(parent: any): any;
  69312. }
  69313. /**
  69314. * This defines an action responsible to increment the target value
  69315. * to a desired value once triggered.
  69316. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  69317. */
  69318. export class IncrementValueAction extends Action {
  69319. /**
  69320. * The path of the property to increment in the target.
  69321. */
  69322. propertyPath: string;
  69323. /**
  69324. * The value we should increment the property by.
  69325. */
  69326. value: any;
  69327. private _target;
  69328. private _effectiveTarget;
  69329. private _property;
  69330. /**
  69331. * Instantiate the action
  69332. * @param triggerOptions defines the trigger options
  69333. * @param target defines the object containing the property
  69334. * @param propertyPath defines the path of the property to increment in the target
  69335. * @param value defines the value value we should increment the property by
  69336. * @param condition defines the trigger related conditions
  69337. */
  69338. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  69339. /** @hidden */
  69340. _prepare(): void;
  69341. /**
  69342. * Execute the action and increment the target of the value amount.
  69343. */
  69344. execute(): void;
  69345. /**
  69346. * Serializes the actions and its related information.
  69347. * @param parent defines the object to serialize in
  69348. * @returns the serialized object
  69349. */
  69350. serialize(parent: any): any;
  69351. }
  69352. /**
  69353. * This defines an action responsible to start an animation once triggered.
  69354. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  69355. */
  69356. export class PlayAnimationAction extends Action {
  69357. /**
  69358. * Where the animation should start (animation frame)
  69359. */
  69360. from: number;
  69361. /**
  69362. * Where the animation should stop (animation frame)
  69363. */
  69364. to: number;
  69365. /**
  69366. * Define if the animation should loop or stop after the first play.
  69367. */
  69368. loop?: boolean;
  69369. private _target;
  69370. /**
  69371. * Instantiate the action
  69372. * @param triggerOptions defines the trigger options
  69373. * @param target defines the target animation or animation name
  69374. * @param from defines from where the animation should start (animation frame)
  69375. * @param end defines where the animation should stop (animation frame)
  69376. * @param loop defines if the animation should loop or stop after the first play
  69377. * @param condition defines the trigger related conditions
  69378. */
  69379. constructor(triggerOptions: any, target: any, from: number, to: number, loop?: boolean, condition?: Condition);
  69380. /** @hidden */
  69381. _prepare(): void;
  69382. /**
  69383. * Execute the action and play the animation.
  69384. */
  69385. execute(): void;
  69386. /**
  69387. * Serializes the actions and its related information.
  69388. * @param parent defines the object to serialize in
  69389. * @returns the serialized object
  69390. */
  69391. serialize(parent: any): any;
  69392. }
  69393. /**
  69394. * This defines an action responsible to stop an animation once triggered.
  69395. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  69396. */
  69397. export class StopAnimationAction extends Action {
  69398. private _target;
  69399. /**
  69400. * Instantiate the action
  69401. * @param triggerOptions defines the trigger options
  69402. * @param target defines the target animation or animation name
  69403. * @param condition defines the trigger related conditions
  69404. */
  69405. constructor(triggerOptions: any, target: any, condition?: Condition);
  69406. /** @hidden */
  69407. _prepare(): void;
  69408. /**
  69409. * Execute the action and stop the animation.
  69410. */
  69411. execute(): void;
  69412. /**
  69413. * Serializes the actions and its related information.
  69414. * @param parent defines the object to serialize in
  69415. * @returns the serialized object
  69416. */
  69417. serialize(parent: any): any;
  69418. }
  69419. /**
  69420. * This defines an action responsible that does nothing once triggered.
  69421. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  69422. */
  69423. export class DoNothingAction extends Action {
  69424. /**
  69425. * Instantiate the action
  69426. * @param triggerOptions defines the trigger options
  69427. * @param condition defines the trigger related conditions
  69428. */
  69429. constructor(triggerOptions?: any, condition?: Condition);
  69430. /**
  69431. * Execute the action and do nothing.
  69432. */
  69433. execute(): void;
  69434. /**
  69435. * Serializes the actions and its related information.
  69436. * @param parent defines the object to serialize in
  69437. * @returns the serialized object
  69438. */
  69439. serialize(parent: any): any;
  69440. }
  69441. /**
  69442. * This defines an action responsible to trigger several actions once triggered.
  69443. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  69444. */
  69445. export class CombineAction extends Action {
  69446. /**
  69447. * The list of aggregated animations to run.
  69448. */
  69449. children: Action[];
  69450. /**
  69451. * Instantiate the action
  69452. * @param triggerOptions defines the trigger options
  69453. * @param children defines the list of aggregated animations to run
  69454. * @param condition defines the trigger related conditions
  69455. */
  69456. constructor(triggerOptions: any, children: Action[], condition?: Condition);
  69457. /** @hidden */
  69458. _prepare(): void;
  69459. /**
  69460. * Execute the action and executes all the aggregated actions.
  69461. */
  69462. execute(evt: ActionEvent): void;
  69463. /**
  69464. * Serializes the actions and its related information.
  69465. * @param parent defines the object to serialize in
  69466. * @returns the serialized object
  69467. */
  69468. serialize(parent: any): any;
  69469. }
  69470. /**
  69471. * This defines an action responsible to run code (external event) once triggered.
  69472. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  69473. */
  69474. export class ExecuteCodeAction extends Action {
  69475. /**
  69476. * The callback function to run.
  69477. */
  69478. func: (evt: ActionEvent) => void;
  69479. /**
  69480. * Instantiate the action
  69481. * @param triggerOptions defines the trigger options
  69482. * @param func defines the callback function to run
  69483. * @param condition defines the trigger related conditions
  69484. */
  69485. constructor(triggerOptions: any, func: (evt: ActionEvent) => void, condition?: Condition);
  69486. /**
  69487. * Execute the action and run the attached code.
  69488. */
  69489. execute(evt: ActionEvent): void;
  69490. }
  69491. /**
  69492. * This defines an action responsible to set the parent property of the target once triggered.
  69493. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  69494. */
  69495. export class SetParentAction extends Action {
  69496. private _parent;
  69497. private _target;
  69498. /**
  69499. * Instantiate the action
  69500. * @param triggerOptions defines the trigger options
  69501. * @param target defines the target containing the parent property
  69502. * @param parent defines from where the animation should start (animation frame)
  69503. * @param condition defines the trigger related conditions
  69504. */
  69505. constructor(triggerOptions: any, target: any, parent: any, condition?: Condition);
  69506. /** @hidden */
  69507. _prepare(): void;
  69508. /**
  69509. * Execute the action and set the parent property.
  69510. */
  69511. execute(): void;
  69512. /**
  69513. * Serializes the actions and its related information.
  69514. * @param parent defines the object to serialize in
  69515. * @returns the serialized object
  69516. */
  69517. serialize(parent: any): any;
  69518. }
  69519. }
  69520. declare module BABYLON {
  69521. /**
  69522. * Action Manager manages all events to be triggered on a given mesh or the global scene.
  69523. * A single scene can have many Action Managers to handle predefined actions on specific meshes.
  69524. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  69525. */
  69526. export class ActionManager extends AbstractActionManager {
  69527. /**
  69528. * Nothing
  69529. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  69530. */
  69531. static readonly NothingTrigger: number;
  69532. /**
  69533. * On pick
  69534. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  69535. */
  69536. static readonly OnPickTrigger: number;
  69537. /**
  69538. * On left pick
  69539. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  69540. */
  69541. static readonly OnLeftPickTrigger: number;
  69542. /**
  69543. * On right pick
  69544. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  69545. */
  69546. static readonly OnRightPickTrigger: number;
  69547. /**
  69548. * On center pick
  69549. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  69550. */
  69551. static readonly OnCenterPickTrigger: number;
  69552. /**
  69553. * On pick down
  69554. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  69555. */
  69556. static readonly OnPickDownTrigger: number;
  69557. /**
  69558. * On double pick
  69559. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  69560. */
  69561. static readonly OnDoublePickTrigger: number;
  69562. /**
  69563. * On pick up
  69564. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  69565. */
  69566. static readonly OnPickUpTrigger: number;
  69567. /**
  69568. * On pick out.
  69569. * This trigger will only be raised if you also declared a OnPickDown
  69570. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  69571. */
  69572. static readonly OnPickOutTrigger: number;
  69573. /**
  69574. * On long press
  69575. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  69576. */
  69577. static readonly OnLongPressTrigger: number;
  69578. /**
  69579. * On pointer over
  69580. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  69581. */
  69582. static readonly OnPointerOverTrigger: number;
  69583. /**
  69584. * On pointer out
  69585. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  69586. */
  69587. static readonly OnPointerOutTrigger: number;
  69588. /**
  69589. * On every frame
  69590. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  69591. */
  69592. static readonly OnEveryFrameTrigger: number;
  69593. /**
  69594. * On intersection enter
  69595. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  69596. */
  69597. static readonly OnIntersectionEnterTrigger: number;
  69598. /**
  69599. * On intersection exit
  69600. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  69601. */
  69602. static readonly OnIntersectionExitTrigger: number;
  69603. /**
  69604. * On key down
  69605. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  69606. */
  69607. static readonly OnKeyDownTrigger: number;
  69608. /**
  69609. * On key up
  69610. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  69611. */
  69612. static readonly OnKeyUpTrigger: number;
  69613. private _scene;
  69614. /**
  69615. * Creates a new action manager
  69616. * @param scene defines the hosting scene
  69617. */
  69618. constructor(scene: Scene);
  69619. /**
  69620. * Releases all associated resources
  69621. */
  69622. dispose(): void;
  69623. /**
  69624. * Gets hosting scene
  69625. * @returns the hosting scene
  69626. */
  69627. getScene(): Scene;
  69628. /**
  69629. * Does this action manager handles actions of any of the given triggers
  69630. * @param triggers defines the triggers to be tested
  69631. * @return a boolean indicating whether one (or more) of the triggers is handled
  69632. */
  69633. hasSpecificTriggers(triggers: number[]): boolean;
  69634. /**
  69635. * Does this action manager handles actions of any of the given triggers. This function takes two arguments for
  69636. * speed.
  69637. * @param triggerA defines the trigger to be tested
  69638. * @param triggerB defines the trigger to be tested
  69639. * @return a boolean indicating whether one (or more) of the triggers is handled
  69640. */
  69641. hasSpecificTriggers2(triggerA: number, triggerB: number): boolean;
  69642. /**
  69643. * Does this action manager handles actions of a given trigger
  69644. * @param trigger defines the trigger to be tested
  69645. * @param parameterPredicate defines an optional predicate to filter triggers by parameter
  69646. * @return whether the trigger is handled
  69647. */
  69648. hasSpecificTrigger(trigger: number, parameterPredicate?: (parameter: any) => boolean): boolean;
  69649. /**
  69650. * Does this action manager has pointer triggers
  69651. */
  69652. readonly hasPointerTriggers: boolean;
  69653. /**
  69654. * Does this action manager has pick triggers
  69655. */
  69656. readonly hasPickTriggers: boolean;
  69657. /**
  69658. * Registers an action to this action manager
  69659. * @param action defines the action to be registered
  69660. * @return the action amended (prepared) after registration
  69661. */
  69662. registerAction(action: IAction): Nullable<IAction>;
  69663. /**
  69664. * Unregisters an action to this action manager
  69665. * @param action defines the action to be unregistered
  69666. * @return a boolean indicating whether the action has been unregistered
  69667. */
  69668. unregisterAction(action: IAction): Boolean;
  69669. /**
  69670. * Process a specific trigger
  69671. * @param trigger defines the trigger to process
  69672. * @param evt defines the event details to be processed
  69673. */
  69674. processTrigger(trigger: number, evt?: IActionEvent): void;
  69675. /** @hidden */
  69676. _getEffectiveTarget(target: any, propertyPath: string): any;
  69677. /** @hidden */
  69678. _getProperty(propertyPath: string): string;
  69679. /**
  69680. * Serialize this manager to a JSON object
  69681. * @param name defines the property name to store this manager
  69682. * @returns a JSON representation of this manager
  69683. */
  69684. serialize(name: string): any;
  69685. /**
  69686. * Creates a new ActionManager from a JSON data
  69687. * @param parsedActions defines the JSON data to read from
  69688. * @param object defines the hosting mesh
  69689. * @param scene defines the hosting scene
  69690. */
  69691. static Parse(parsedActions: any, object: Nullable<AbstractMesh>, scene: Scene): void;
  69692. /**
  69693. * Get a trigger name by index
  69694. * @param trigger defines the trigger index
  69695. * @returns a trigger name
  69696. */
  69697. static GetTriggerName(trigger: number): string;
  69698. }
  69699. }
  69700. declare module BABYLON {
  69701. /**
  69702. * Class representing a ray with position and direction
  69703. */
  69704. export class Ray {
  69705. /** origin point */
  69706. origin: Vector3;
  69707. /** direction */
  69708. direction: Vector3;
  69709. /** length of the ray */
  69710. length: number;
  69711. private static readonly TmpVector3;
  69712. private _tmpRay;
  69713. /**
  69714. * Creates a new ray
  69715. * @param origin origin point
  69716. * @param direction direction
  69717. * @param length length of the ray
  69718. */
  69719. constructor(
  69720. /** origin point */
  69721. origin: Vector3,
  69722. /** direction */
  69723. direction: Vector3,
  69724. /** length of the ray */
  69725. length?: number);
  69726. /**
  69727. * Checks if the ray intersects a box
  69728. * @param minimum bound of the box
  69729. * @param maximum bound of the box
  69730. * @param intersectionTreshold extra extend to be added to the box in all direction
  69731. * @returns if the box was hit
  69732. */
  69733. intersectsBoxMinMax(minimum: DeepImmutable<Vector3>, maximum: DeepImmutable<Vector3>, intersectionTreshold?: number): boolean;
  69734. /**
  69735. * Checks if the ray intersects a box
  69736. * @param box the bounding box to check
  69737. * @param intersectionTreshold extra extend to be added to the BoundingBox in all direction
  69738. * @returns if the box was hit
  69739. */
  69740. intersectsBox(box: DeepImmutable<BoundingBox>, intersectionTreshold?: number): boolean;
  69741. /**
  69742. * If the ray hits a sphere
  69743. * @param sphere the bounding sphere to check
  69744. * @param intersectionTreshold extra extend to be added to the BoundingSphere in all direction
  69745. * @returns true if it hits the sphere
  69746. */
  69747. intersectsSphere(sphere: DeepImmutable<BoundingSphere>, intersectionTreshold?: number): boolean;
  69748. /**
  69749. * If the ray hits a triange
  69750. * @param vertex0 triangle vertex
  69751. * @param vertex1 triangle vertex
  69752. * @param vertex2 triangle vertex
  69753. * @returns intersection information if hit
  69754. */
  69755. intersectsTriangle(vertex0: DeepImmutable<Vector3>, vertex1: DeepImmutable<Vector3>, vertex2: DeepImmutable<Vector3>): Nullable<IntersectionInfo>;
  69756. /**
  69757. * Checks if ray intersects a plane
  69758. * @param plane the plane to check
  69759. * @returns the distance away it was hit
  69760. */
  69761. intersectsPlane(plane: DeepImmutable<Plane>): Nullable<number>;
  69762. /**
  69763. * Checks if ray intersects a mesh
  69764. * @param mesh the mesh to check
  69765. * @param fastCheck if only the bounding box should checked
  69766. * @returns picking info of the intersecton
  69767. */
  69768. intersectsMesh(mesh: DeepImmutable<AbstractMesh>, fastCheck?: boolean): PickingInfo;
  69769. /**
  69770. * Checks if ray intersects a mesh
  69771. * @param meshes the meshes to check
  69772. * @param fastCheck if only the bounding box should checked
  69773. * @param results array to store result in
  69774. * @returns Array of picking infos
  69775. */
  69776. intersectsMeshes(meshes: Array<DeepImmutable<AbstractMesh>>, fastCheck?: boolean, results?: Array<PickingInfo>): Array<PickingInfo>;
  69777. private _comparePickingInfo;
  69778. private static smallnum;
  69779. private static rayl;
  69780. /**
  69781. * Intersection test between the ray and a given segment whithin a given tolerance (threshold)
  69782. * @param sega the first point of the segment to test the intersection against
  69783. * @param segb the second point of the segment to test the intersection against
  69784. * @param threshold the tolerance margin, if the ray doesn't intersect the segment but is close to the given threshold, the intersection is successful
  69785. * @return the distance from the ray origin to the intersection point if there's intersection, or -1 if there's no intersection
  69786. */
  69787. intersectionSegment(sega: DeepImmutable<Vector3>, segb: DeepImmutable<Vector3>, threshold: number): number;
  69788. /**
  69789. * Update the ray from viewport position
  69790. * @param x position
  69791. * @param y y position
  69792. * @param viewportWidth viewport width
  69793. * @param viewportHeight viewport height
  69794. * @param world world matrix
  69795. * @param view view matrix
  69796. * @param projection projection matrix
  69797. * @returns this ray updated
  69798. */
  69799. update(x: number, y: number, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Ray;
  69800. /**
  69801. * Creates a ray with origin and direction of 0,0,0
  69802. * @returns the new ray
  69803. */
  69804. static Zero(): Ray;
  69805. /**
  69806. * Creates a new ray from screen space and viewport
  69807. * @param x position
  69808. * @param y y position
  69809. * @param viewportWidth viewport width
  69810. * @param viewportHeight viewport height
  69811. * @param world world matrix
  69812. * @param view view matrix
  69813. * @param projection projection matrix
  69814. * @returns new ray
  69815. */
  69816. static CreateNew(x: number, y: number, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Ray;
  69817. /**
  69818. * 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
  69819. * transformed to the given world matrix.
  69820. * @param origin The origin point
  69821. * @param end The end point
  69822. * @param world a matrix to transform the ray to. Default is the identity matrix.
  69823. * @returns the new ray
  69824. */
  69825. static CreateNewFromTo(origin: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, world?: DeepImmutable<Matrix>): Ray;
  69826. /**
  69827. * Transforms a ray by a matrix
  69828. * @param ray ray to transform
  69829. * @param matrix matrix to apply
  69830. * @returns the resulting new ray
  69831. */
  69832. static Transform(ray: DeepImmutable<Ray>, matrix: DeepImmutable<Matrix>): Ray;
  69833. /**
  69834. * Transforms a ray by a matrix
  69835. * @param ray ray to transform
  69836. * @param matrix matrix to apply
  69837. * @param result ray to store result in
  69838. */
  69839. static TransformToRef(ray: DeepImmutable<Ray>, matrix: DeepImmutable<Matrix>, result: Ray): void;
  69840. /**
  69841. * Unproject a ray from screen space to object space
  69842. * @param sourceX defines the screen space x coordinate to use
  69843. * @param sourceY defines the screen space y coordinate to use
  69844. * @param viewportWidth defines the current width of the viewport
  69845. * @param viewportHeight defines the current height of the viewport
  69846. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  69847. * @param view defines the view matrix to use
  69848. * @param projection defines the projection matrix to use
  69849. */
  69850. unprojectRayToRef(sourceX: float, sourceY: float, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): void;
  69851. }
  69852. /**
  69853. * Type used to define predicate used to select faces when a mesh intersection is detected
  69854. */
  69855. export type TrianglePickingPredicate = (p0: Vector3, p1: Vector3, p2: Vector3, ray: Ray) => boolean;
  69856. interface Scene {
  69857. /** @hidden */
  69858. _tempPickingRay: Nullable<Ray>;
  69859. /** @hidden */
  69860. _cachedRayForTransform: Ray;
  69861. /** @hidden */
  69862. _pickWithRayInverseMatrix: Matrix;
  69863. /** @hidden */
  69864. _internalPick(rayFunction: (world: Matrix) => Ray, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  69865. /** @hidden */
  69866. _internalMultiPick(rayFunction: (world: Matrix) => Ray, predicate?: (mesh: AbstractMesh) => boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  69867. }
  69868. }
  69869. declare module BABYLON {
  69870. /**
  69871. * Groups all the scene component constants in one place to ease maintenance.
  69872. * @hidden
  69873. */
  69874. export class SceneComponentConstants {
  69875. static readonly NAME_EFFECTLAYER: string;
  69876. static readonly NAME_LAYER: string;
  69877. static readonly NAME_LENSFLARESYSTEM: string;
  69878. static readonly NAME_BOUNDINGBOXRENDERER: string;
  69879. static readonly NAME_PARTICLESYSTEM: string;
  69880. static readonly NAME_GAMEPAD: string;
  69881. static readonly NAME_SIMPLIFICATIONQUEUE: string;
  69882. static readonly NAME_GEOMETRYBUFFERRENDERER: string;
  69883. static readonly NAME_DEPTHRENDERER: string;
  69884. static readonly NAME_POSTPROCESSRENDERPIPELINEMANAGER: string;
  69885. static readonly NAME_SPRITE: string;
  69886. static readonly NAME_OUTLINERENDERER: string;
  69887. static readonly NAME_PROCEDURALTEXTURE: string;
  69888. static readonly NAME_SHADOWGENERATOR: string;
  69889. static readonly NAME_OCTREE: string;
  69890. static readonly NAME_PHYSICSENGINE: string;
  69891. static readonly NAME_AUDIO: string;
  69892. static readonly STEP_ISREADYFORMESH_EFFECTLAYER: number;
  69893. static readonly STEP_BEFOREEVALUATEACTIVEMESH_BOUNDINGBOXRENDERER: number;
  69894. static readonly STEP_EVALUATESUBMESH_BOUNDINGBOXRENDERER: number;
  69895. static readonly STEP_ACTIVEMESH_BOUNDINGBOXRENDERER: number;
  69896. static readonly STEP_CAMERADRAWRENDERTARGET_EFFECTLAYER: number;
  69897. static readonly STEP_BEFORECAMERADRAW_EFFECTLAYER: number;
  69898. static readonly STEP_BEFORECAMERADRAW_LAYER: number;
  69899. static readonly STEP_BEFORERENDERTARGETDRAW_LAYER: number;
  69900. static readonly STEP_BEFORERENDERINGMESH_OUTLINE: number;
  69901. static readonly STEP_AFTERRENDERINGMESH_OUTLINE: number;
  69902. static readonly STEP_AFTERRENDERINGGROUPDRAW_EFFECTLAYER_DRAW: number;
  69903. static readonly STEP_AFTERRENDERINGGROUPDRAW_BOUNDINGBOXRENDERER: number;
  69904. static readonly STEP_BEFORECAMERAUPDATE_SIMPLIFICATIONQUEUE: number;
  69905. static readonly STEP_BEFORECAMERAUPDATE_GAMEPAD: number;
  69906. static readonly STEP_BEFORECLEAR_PROCEDURALTEXTURE: number;
  69907. static readonly STEP_AFTERRENDERTARGETDRAW_LAYER: number;
  69908. static readonly STEP_AFTERCAMERADRAW_EFFECTLAYER: number;
  69909. static readonly STEP_AFTERCAMERADRAW_LENSFLARESYSTEM: number;
  69910. static readonly STEP_AFTERCAMERADRAW_EFFECTLAYER_DRAW: number;
  69911. static readonly STEP_AFTERCAMERADRAW_LAYER: number;
  69912. static readonly STEP_AFTERRENDER_AUDIO: number;
  69913. static readonly STEP_GATHERRENDERTARGETS_SHADOWGENERATOR: number;
  69914. static readonly STEP_GATHERRENDERTARGETS_GEOMETRYBUFFERRENDERER: number;
  69915. static readonly STEP_GATHERRENDERTARGETS_DEPTHRENDERER: number;
  69916. static readonly STEP_GATHERRENDERTARGETS_POSTPROCESSRENDERPIPELINEMANAGER: number;
  69917. static readonly STEP_GATHERACTIVECAMERARENDERTARGETS_DEPTHRENDERER: number;
  69918. static readonly STEP_POINTERMOVE_SPRITE: number;
  69919. static readonly STEP_POINTERDOWN_SPRITE: number;
  69920. static readonly STEP_POINTERUP_SPRITE: number;
  69921. }
  69922. /**
  69923. * This represents a scene component.
  69924. *
  69925. * This is used to decouple the dependency the scene is having on the different workloads like
  69926. * layers, post processes...
  69927. */
  69928. export interface ISceneComponent {
  69929. /**
  69930. * The name of the component. Each component must have a unique name.
  69931. */
  69932. name: string;
  69933. /**
  69934. * The scene the component belongs to.
  69935. */
  69936. scene: Scene;
  69937. /**
  69938. * Register the component to one instance of a scene.
  69939. */
  69940. register(): void;
  69941. /**
  69942. * Rebuilds the elements related to this component in case of
  69943. * context lost for instance.
  69944. */
  69945. rebuild(): void;
  69946. /**
  69947. * Disposes the component and the associated ressources.
  69948. */
  69949. dispose(): void;
  69950. }
  69951. /**
  69952. * This represents a SERIALIZABLE scene component.
  69953. *
  69954. * This extends Scene Component to add Serialization methods on top.
  69955. */
  69956. export interface ISceneSerializableComponent extends ISceneComponent {
  69957. /**
  69958. * Adds all the element from the container to the scene
  69959. * @param container the container holding the elements
  69960. */
  69961. addFromContainer(container: AbstractScene): void;
  69962. /**
  69963. * Removes all the elements in the container from the scene
  69964. * @param container contains the elements to remove
  69965. */
  69966. removeFromContainer(container: AbstractScene): void;
  69967. /**
  69968. * Serializes the component data to the specified json object
  69969. * @param serializationObject The object to serialize to
  69970. */
  69971. serialize(serializationObject: any): void;
  69972. }
  69973. /**
  69974. * Strong typing of a Mesh related stage step action
  69975. */
  69976. export type MeshStageAction = (mesh: AbstractMesh, hardwareInstancedRendering: boolean) => boolean;
  69977. /**
  69978. * Strong typing of a Evaluate Sub Mesh related stage step action
  69979. */
  69980. export type EvaluateSubMeshStageAction = (mesh: AbstractMesh, subMesh: SubMesh) => void;
  69981. /**
  69982. * Strong typing of a Active Mesh related stage step action
  69983. */
  69984. export type ActiveMeshStageAction = (sourceMesh: AbstractMesh, mesh: AbstractMesh) => void;
  69985. /**
  69986. * Strong typing of a Camera related stage step action
  69987. */
  69988. export type CameraStageAction = (camera: Camera) => void;
  69989. /**
  69990. * Strong typing of a Render Target related stage step action
  69991. */
  69992. export type RenderTargetStageAction = (renderTarget: RenderTargetTexture) => void;
  69993. /**
  69994. * Strong typing of a RenderingGroup related stage step action
  69995. */
  69996. export type RenderingGroupStageAction = (renderingGroupId: number) => void;
  69997. /**
  69998. * Strong typing of a Mesh Render related stage step action
  69999. */
  70000. export type RenderingMeshStageAction = (mesh: AbstractMesh, subMesh: SubMesh, batch: _InstancesBatch) => void;
  70001. /**
  70002. * Strong typing of a simple stage step action
  70003. */
  70004. export type SimpleStageAction = () => void;
  70005. /**
  70006. * Strong typing of a render target action.
  70007. */
  70008. export type RenderTargetsStageAction = (renderTargets: SmartArrayNoDuplicate<RenderTargetTexture>) => void;
  70009. /**
  70010. * Strong typing of a pointer move action.
  70011. */
  70012. export type PointerMoveStageAction = (unTranslatedPointerX: number, unTranslatedPointerY: number, pickResult: Nullable<PickingInfo>, isMeshPicked: boolean, canvas: HTMLCanvasElement) => Nullable<PickingInfo>;
  70013. /**
  70014. * Strong typing of a pointer up/down action.
  70015. */
  70016. export type PointerUpDownStageAction = (unTranslatedPointerX: number, unTranslatedPointerY: number, pickResult: Nullable<PickingInfo>, evt: PointerEvent) => Nullable<PickingInfo>;
  70017. /**
  70018. * Repressentation of a stage in the scene (Basically a list of ordered steps)
  70019. * @hidden
  70020. */
  70021. export class Stage<T extends Function> extends Array<{
  70022. index: number;
  70023. component: ISceneComponent;
  70024. action: T;
  70025. }> {
  70026. /**
  70027. * Hide ctor from the rest of the world.
  70028. * @param items The items to add.
  70029. */
  70030. private constructor();
  70031. /**
  70032. * Creates a new Stage.
  70033. * @returns A new instance of a Stage
  70034. */
  70035. static Create<T extends Function>(): Stage<T>;
  70036. /**
  70037. * Registers a step in an ordered way in the targeted stage.
  70038. * @param index Defines the position to register the step in
  70039. * @param component Defines the component attached to the step
  70040. * @param action Defines the action to launch during the step
  70041. */
  70042. registerStep(index: number, component: ISceneComponent, action: T): void;
  70043. /**
  70044. * Clears all the steps from the stage.
  70045. */
  70046. clear(): void;
  70047. }
  70048. }
  70049. declare module BABYLON {
  70050. interface Scene {
  70051. /** @hidden */
  70052. _pointerOverSprite: Nullable<Sprite>;
  70053. /** @hidden */
  70054. _pickedDownSprite: Nullable<Sprite>;
  70055. /** @hidden */
  70056. _tempSpritePickingRay: Nullable<Ray>;
  70057. /**
  70058. * All of the sprite managers added to this scene
  70059. * @see http://doc.babylonjs.com/babylon101/sprites
  70060. */
  70061. spriteManagers: Array<ISpriteManager>;
  70062. /**
  70063. * An event triggered when sprites rendering is about to start
  70064. * Note: This event can be trigger more than once per frame (because sprites can be rendered by render target textures as well)
  70065. */
  70066. onBeforeSpritesRenderingObservable: Observable<Scene>;
  70067. /**
  70068. * An event triggered when sprites rendering is done
  70069. * Note: This event can be trigger more than once per frame (because sprites can be rendered by render target textures as well)
  70070. */
  70071. onAfterSpritesRenderingObservable: Observable<Scene>;
  70072. /** @hidden */
  70073. _internalPickSprites(ray: Ray, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  70074. /** Launch a ray to try to pick a sprite in the scene
  70075. * @param x position on screen
  70076. * @param y position on screen
  70077. * @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
  70078. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  70079. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  70080. * @returns a PickingInfo
  70081. */
  70082. pickSprite(x: number, y: number, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  70083. /** Use the given ray to pick a sprite in the scene
  70084. * @param ray The ray (in world space) to use to pick meshes
  70085. * @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
  70086. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  70087. * @param camera camera to use. Can be set to null. In this case, the scene.activeCamera will be used
  70088. * @returns a PickingInfo
  70089. */
  70090. pickSpriteWithRay(ray: Ray, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  70091. /**
  70092. * Force the sprite under the pointer
  70093. * @param sprite defines the sprite to use
  70094. */
  70095. setPointerOverSprite(sprite: Nullable<Sprite>): void;
  70096. /**
  70097. * Gets the sprite under the pointer
  70098. * @returns a Sprite or null if no sprite is under the pointer
  70099. */
  70100. getPointerOverSprite(): Nullable<Sprite>;
  70101. }
  70102. /**
  70103. * Defines the sprite scene component responsible to manage sprites
  70104. * in a given scene.
  70105. */
  70106. export class SpriteSceneComponent implements ISceneComponent {
  70107. /**
  70108. * The component name helpfull to identify the component in the list of scene components.
  70109. */
  70110. readonly name: string;
  70111. /**
  70112. * The scene the component belongs to.
  70113. */
  70114. scene: Scene;
  70115. /** @hidden */
  70116. private _spritePredicate;
  70117. /**
  70118. * Creates a new instance of the component for the given scene
  70119. * @param scene Defines the scene to register the component in
  70120. */
  70121. constructor(scene: Scene);
  70122. /**
  70123. * Registers the component in a given scene
  70124. */
  70125. register(): void;
  70126. /**
  70127. * Rebuilds the elements related to this component in case of
  70128. * context lost for instance.
  70129. */
  70130. rebuild(): void;
  70131. /**
  70132. * Disposes the component and the associated ressources.
  70133. */
  70134. dispose(): void;
  70135. private _pickSpriteButKeepRay;
  70136. private _pointerMove;
  70137. private _pointerDown;
  70138. private _pointerUp;
  70139. }
  70140. }
  70141. declare module BABYLON {
  70142. /** @hidden */
  70143. export var fogFragmentDeclaration: {
  70144. name: string;
  70145. shader: string;
  70146. };
  70147. }
  70148. declare module BABYLON {
  70149. /** @hidden */
  70150. export var fogFragment: {
  70151. name: string;
  70152. shader: string;
  70153. };
  70154. }
  70155. declare module BABYLON {
  70156. /** @hidden */
  70157. export var spritesPixelShader: {
  70158. name: string;
  70159. shader: string;
  70160. };
  70161. }
  70162. declare module BABYLON {
  70163. /** @hidden */
  70164. export var fogVertexDeclaration: {
  70165. name: string;
  70166. shader: string;
  70167. };
  70168. }
  70169. declare module BABYLON {
  70170. /** @hidden */
  70171. export var spritesVertexShader: {
  70172. name: string;
  70173. shader: string;
  70174. };
  70175. }
  70176. declare module BABYLON {
  70177. /**
  70178. * Defines the minimum interface to fullfil in order to be a sprite manager.
  70179. */
  70180. export interface ISpriteManager extends IDisposable {
  70181. /**
  70182. * Restricts the camera to viewing objects with the same layerMask.
  70183. * A camera with a layerMask of 1 will render spriteManager.layerMask & camera.layerMask!== 0
  70184. */
  70185. layerMask: number;
  70186. /**
  70187. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  70188. */
  70189. isPickable: boolean;
  70190. /**
  70191. * Specifies the rendering group id for this mesh (0 by default)
  70192. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  70193. */
  70194. renderingGroupId: number;
  70195. /**
  70196. * Defines the list of sprites managed by the manager.
  70197. */
  70198. sprites: Array<Sprite>;
  70199. /**
  70200. * Tests the intersection of a sprite with a specific ray.
  70201. * @param ray The ray we are sending to test the collision
  70202. * @param camera The camera space we are sending rays in
  70203. * @param predicate A predicate allowing excluding sprites from the list of object to test
  70204. * @param fastCheck Is the hit test done in a OOBB or AOBB fashion the faster, the less precise
  70205. * @returns picking info or null.
  70206. */
  70207. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  70208. /**
  70209. * Renders the list of sprites on screen.
  70210. */
  70211. render(): void;
  70212. }
  70213. /**
  70214. * Class used to manage multiple sprites on the same spritesheet
  70215. * @see http://doc.babylonjs.com/babylon101/sprites
  70216. */
  70217. export class SpriteManager implements ISpriteManager {
  70218. /** defines the manager's name */
  70219. name: string;
  70220. /** Gets the list of sprites */
  70221. sprites: Sprite[];
  70222. /** Gets or sets the rendering group id (0 by default) */
  70223. renderingGroupId: number;
  70224. /** Gets or sets camera layer mask */
  70225. layerMask: number;
  70226. /** Gets or sets a boolean indicating if the manager must consider scene fog when rendering */
  70227. fogEnabled: boolean;
  70228. /** Gets or sets a boolean indicating if the sprites are pickable */
  70229. isPickable: boolean;
  70230. /** Defines the default width of a cell in the spritesheet */
  70231. cellWidth: number;
  70232. /** Defines the default height of a cell in the spritesheet */
  70233. cellHeight: number;
  70234. /**
  70235. * An event triggered when the manager is disposed.
  70236. */
  70237. onDisposeObservable: Observable<SpriteManager>;
  70238. private _onDisposeObserver;
  70239. /**
  70240. * Callback called when the manager is disposed
  70241. */
  70242. onDispose: () => void;
  70243. private _capacity;
  70244. private _spriteTexture;
  70245. private _epsilon;
  70246. private _scene;
  70247. private _vertexData;
  70248. private _buffer;
  70249. private _vertexBuffers;
  70250. private _indexBuffer;
  70251. private _effectBase;
  70252. private _effectFog;
  70253. /**
  70254. * Gets or sets the spritesheet texture
  70255. */
  70256. texture: Texture;
  70257. /**
  70258. * Creates a new sprite manager
  70259. * @param name defines the manager's name
  70260. * @param imgUrl defines the sprite sheet url
  70261. * @param capacity defines the maximum allowed number of sprites
  70262. * @param cellSize defines the size of a sprite cell
  70263. * @param scene defines the hosting scene
  70264. * @param epsilon defines the epsilon value to align texture (0.01 by default)
  70265. * @param samplingMode defines the smapling mode to use with spritesheet
  70266. */
  70267. constructor(
  70268. /** defines the manager's name */
  70269. name: string, imgUrl: string, capacity: number, cellSize: any, scene: Scene, epsilon?: number, samplingMode?: number);
  70270. private _appendSpriteVertex;
  70271. /**
  70272. * Intersects the sprites with a ray
  70273. * @param ray defines the ray to intersect with
  70274. * @param camera defines the current active camera
  70275. * @param predicate defines a predicate used to select candidate sprites
  70276. * @param fastCheck defines if a fast check only must be done (the first potential sprite is will be used and not the closer)
  70277. * @returns null if no hit or a PickingInfo
  70278. */
  70279. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  70280. /**
  70281. * Render all child sprites
  70282. */
  70283. render(): void;
  70284. /**
  70285. * Release associated resources
  70286. */
  70287. dispose(): void;
  70288. }
  70289. }
  70290. declare module BABYLON {
  70291. /**
  70292. * Class used to represent a sprite
  70293. * @see http://doc.babylonjs.com/babylon101/sprites
  70294. */
  70295. export class Sprite {
  70296. /** defines the name */
  70297. name: string;
  70298. /** Gets or sets the current world position */
  70299. position: Vector3;
  70300. /** Gets or sets the main color */
  70301. color: Color4;
  70302. /** Gets or sets the width */
  70303. width: number;
  70304. /** Gets or sets the height */
  70305. height: number;
  70306. /** Gets or sets rotation angle */
  70307. angle: number;
  70308. /** Gets or sets the cell index in the sprite sheet */
  70309. cellIndex: number;
  70310. /** Gets or sets a boolean indicating if UV coordinates should be inverted in U axis */
  70311. invertU: number;
  70312. /** Gets or sets a boolean indicating if UV coordinates should be inverted in B axis */
  70313. invertV: number;
  70314. /** Gets or sets a boolean indicating that this sprite should be disposed after animation ends */
  70315. disposeWhenFinishedAnimating: boolean;
  70316. /** Gets the list of attached animations */
  70317. animations: Animation[];
  70318. /** Gets or sets a boolean indicating if the sprite can be picked */
  70319. isPickable: boolean;
  70320. /**
  70321. * Gets or sets the associated action manager
  70322. */
  70323. actionManager: Nullable<ActionManager>;
  70324. private _animationStarted;
  70325. private _loopAnimation;
  70326. private _fromIndex;
  70327. private _toIndex;
  70328. private _delay;
  70329. private _direction;
  70330. private _manager;
  70331. private _time;
  70332. private _onAnimationEnd;
  70333. /**
  70334. * Gets or sets a boolean indicating if the sprite is visible (renderable). Default is true
  70335. */
  70336. isVisible: boolean;
  70337. /**
  70338. * Gets or sets the sprite size
  70339. */
  70340. size: number;
  70341. /**
  70342. * Creates a new Sprite
  70343. * @param name defines the name
  70344. * @param manager defines the manager
  70345. */
  70346. constructor(
  70347. /** defines the name */
  70348. name: string, manager: ISpriteManager);
  70349. /**
  70350. * Starts an animation
  70351. * @param from defines the initial key
  70352. * @param to defines the end key
  70353. * @param loop defines if the animation must loop
  70354. * @param delay defines the start delay (in ms)
  70355. * @param onAnimationEnd defines a callback to call when animation ends
  70356. */
  70357. playAnimation(from: number, to: number, loop: boolean, delay: number, onAnimationEnd: () => void): void;
  70358. /** Stops current animation (if any) */
  70359. stopAnimation(): void;
  70360. /** @hidden */
  70361. _animate(deltaTime: number): void;
  70362. /** Release associated resources */
  70363. dispose(): void;
  70364. }
  70365. }
  70366. declare module BABYLON {
  70367. /**
  70368. * Information about the result of picking within a scene
  70369. * @see https://doc.babylonjs.com/babylon101/picking_collisions
  70370. */
  70371. export class PickingInfo {
  70372. /** @hidden */
  70373. _pickingUnavailable: boolean;
  70374. /**
  70375. * If the pick collided with an object
  70376. */
  70377. hit: boolean;
  70378. /**
  70379. * Distance away where the pick collided
  70380. */
  70381. distance: number;
  70382. /**
  70383. * The location of pick collision
  70384. */
  70385. pickedPoint: Nullable<Vector3>;
  70386. /**
  70387. * The mesh corresponding the the pick collision
  70388. */
  70389. pickedMesh: Nullable<AbstractMesh>;
  70390. /** (See getTextureCoordinates) The barycentric U coordinate that is used when calulating the texture coordinates of the collision.*/
  70391. bu: number;
  70392. /** (See getTextureCoordinates) The barycentric V coordinate that is used when calulating the texture coordinates of the collision.*/
  70393. bv: number;
  70394. /** The index of the face on the mesh that was picked, or the index of the Line if the picked Mesh is a LinesMesh */
  70395. faceId: number;
  70396. /** Id of the the submesh that was picked */
  70397. subMeshId: number;
  70398. /** If a sprite was picked, this will be the sprite the pick collided with */
  70399. pickedSprite: Nullable<Sprite>;
  70400. /**
  70401. * If a mesh was used to do the picking (eg. 6dof controller) this will be populated.
  70402. */
  70403. originMesh: Nullable<AbstractMesh>;
  70404. /**
  70405. * The ray that was used to perform the picking.
  70406. */
  70407. ray: Nullable<Ray>;
  70408. /**
  70409. * Gets the normal correspodning to the face the pick collided with
  70410. * @param useWorldCoordinates If the resulting normal should be relative to the world (default: false)
  70411. * @param useVerticesNormals If the vertices normals should be used to calculate the normal instead of the normal map
  70412. * @returns The normal correspodning to the face the pick collided with
  70413. */
  70414. getNormal(useWorldCoordinates?: boolean, useVerticesNormals?: boolean): Nullable<Vector3>;
  70415. /**
  70416. * Gets the texture coordinates of where the pick occured
  70417. * @returns the vector containing the coordnates of the texture
  70418. */
  70419. getTextureCoordinates(): Nullable<Vector2>;
  70420. }
  70421. }
  70422. declare module BABYLON {
  70423. /**
  70424. * Gather the list of pointer event types as constants.
  70425. */
  70426. export class PointerEventTypes {
  70427. /**
  70428. * 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.
  70429. */
  70430. static readonly POINTERDOWN: number;
  70431. /**
  70432. * The pointerup event is fired when a pointer is no longer active.
  70433. */
  70434. static readonly POINTERUP: number;
  70435. /**
  70436. * The pointermove event is fired when a pointer changes coordinates.
  70437. */
  70438. static readonly POINTERMOVE: number;
  70439. /**
  70440. * The pointerwheel event is fired when a mouse wheel has been rotated.
  70441. */
  70442. static readonly POINTERWHEEL: number;
  70443. /**
  70444. * The pointerpick event is fired when a mesh or sprite has been picked by the pointer.
  70445. */
  70446. static readonly POINTERPICK: number;
  70447. /**
  70448. * The pointertap event is fired when a the object has been touched and released without drag.
  70449. */
  70450. static readonly POINTERTAP: number;
  70451. /**
  70452. * The pointerdoubletap event is fired when a the object has been touched and released twice without drag.
  70453. */
  70454. static readonly POINTERDOUBLETAP: number;
  70455. }
  70456. /**
  70457. * Base class of pointer info types.
  70458. */
  70459. export class PointerInfoBase {
  70460. /**
  70461. * Defines the type of event (PointerEventTypes)
  70462. */
  70463. type: number;
  70464. /**
  70465. * Defines the related dom event
  70466. */
  70467. event: PointerEvent | MouseWheelEvent;
  70468. /**
  70469. * Instantiates the base class of pointers info.
  70470. * @param type Defines the type of event (PointerEventTypes)
  70471. * @param event Defines the related dom event
  70472. */
  70473. constructor(
  70474. /**
  70475. * Defines the type of event (PointerEventTypes)
  70476. */
  70477. type: number,
  70478. /**
  70479. * Defines the related dom event
  70480. */
  70481. event: PointerEvent | MouseWheelEvent);
  70482. }
  70483. /**
  70484. * This class is used to store pointer related info for the onPrePointerObservable event.
  70485. * Set the skipOnPointerObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onPointerObservable
  70486. */
  70487. export class PointerInfoPre extends PointerInfoBase {
  70488. /**
  70489. * Ray from a pointer if availible (eg. 6dof controller)
  70490. */
  70491. ray: Nullable<Ray>;
  70492. /**
  70493. * Defines the local position of the pointer on the canvas.
  70494. */
  70495. localPosition: Vector2;
  70496. /**
  70497. * Defines whether the engine should skip the next OnPointerObservable associated to this pre.
  70498. */
  70499. skipOnPointerObservable: boolean;
  70500. /**
  70501. * Instantiates a PointerInfoPre to store pointer related info to the onPrePointerObservable event.
  70502. * @param type Defines the type of event (PointerEventTypes)
  70503. * @param event Defines the related dom event
  70504. * @param localX Defines the local x coordinates of the pointer when the event occured
  70505. * @param localY Defines the local y coordinates of the pointer when the event occured
  70506. */
  70507. constructor(type: number, event: PointerEvent | MouseWheelEvent, localX: number, localY: number);
  70508. }
  70509. /**
  70510. * This type contains all the data related to a pointer event in Babylon.js.
  70511. * 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.
  70512. */
  70513. export class PointerInfo extends PointerInfoBase {
  70514. /**
  70515. * Defines the picking info associated to the info (if any)\
  70516. */
  70517. pickInfo: Nullable<PickingInfo>;
  70518. /**
  70519. * Instantiates a PointerInfo to store pointer related info to the onPointerObservable event.
  70520. * @param type Defines the type of event (PointerEventTypes)
  70521. * @param event Defines the related dom event
  70522. * @param pickInfo Defines the picking info associated to the info (if any)\
  70523. */
  70524. constructor(type: number, event: PointerEvent | MouseWheelEvent,
  70525. /**
  70526. * Defines the picking info associated to the info (if any)\
  70527. */
  70528. pickInfo: Nullable<PickingInfo>);
  70529. }
  70530. /**
  70531. * Data relating to a touch event on the screen.
  70532. */
  70533. export interface PointerTouch {
  70534. /**
  70535. * X coordinate of touch.
  70536. */
  70537. x: number;
  70538. /**
  70539. * Y coordinate of touch.
  70540. */
  70541. y: number;
  70542. /**
  70543. * Id of touch. Unique for each finger.
  70544. */
  70545. pointerId: number;
  70546. /**
  70547. * Event type passed from DOM.
  70548. */
  70549. type: any;
  70550. }
  70551. }
  70552. declare module BABYLON {
  70553. /**
  70554. * Manage the mouse inputs to control the movement of a free camera.
  70555. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  70556. */
  70557. export class FreeCameraMouseInput implements ICameraInput<FreeCamera> {
  70558. /**
  70559. * Define if touch is enabled in the mouse input
  70560. */
  70561. touchEnabled: boolean;
  70562. /**
  70563. * Defines the camera the input is attached to.
  70564. */
  70565. camera: FreeCamera;
  70566. /**
  70567. * Defines the buttons associated with the input to handle camera move.
  70568. */
  70569. buttons: number[];
  70570. /**
  70571. * Defines the pointer angular sensibility along the X and Y axis or how fast is the camera rotating.
  70572. */
  70573. angularSensibility: number;
  70574. private _pointerInput;
  70575. private _onMouseMove;
  70576. private _observer;
  70577. private previousPosition;
  70578. /**
  70579. * Manage the mouse inputs to control the movement of a free camera.
  70580. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  70581. * @param touchEnabled Defines if touch is enabled or not
  70582. */
  70583. constructor(
  70584. /**
  70585. * Define if touch is enabled in the mouse input
  70586. */
  70587. touchEnabled?: boolean);
  70588. /**
  70589. * Attach the input controls to a specific dom element to get the input from.
  70590. * @param element Defines the element the controls should be listened from
  70591. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  70592. */
  70593. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  70594. /**
  70595. * Called on JS contextmenu event.
  70596. * Override this method to provide functionality.
  70597. */
  70598. protected onContextMenu(evt: PointerEvent): void;
  70599. /**
  70600. * Detach the current controls from the specified dom element.
  70601. * @param element Defines the element to stop listening the inputs from
  70602. */
  70603. detachControl(element: Nullable<HTMLElement>): void;
  70604. /**
  70605. * Gets the class name of the current intput.
  70606. * @returns the class name
  70607. */
  70608. getClassName(): string;
  70609. /**
  70610. * Get the friendly name associated with the input class.
  70611. * @returns the input friendly name
  70612. */
  70613. getSimpleName(): string;
  70614. }
  70615. }
  70616. declare module BABYLON {
  70617. /**
  70618. * Manage the touch inputs to control the movement of a free camera.
  70619. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  70620. */
  70621. export class FreeCameraTouchInput implements ICameraInput<FreeCamera> {
  70622. /**
  70623. * Defines the camera the input is attached to.
  70624. */
  70625. camera: FreeCamera;
  70626. /**
  70627. * Defines the touch sensibility for rotation.
  70628. * The higher the faster.
  70629. */
  70630. touchAngularSensibility: number;
  70631. /**
  70632. * Defines the touch sensibility for move.
  70633. * The higher the faster.
  70634. */
  70635. touchMoveSensibility: number;
  70636. private _offsetX;
  70637. private _offsetY;
  70638. private _pointerPressed;
  70639. private _pointerInput;
  70640. private _observer;
  70641. private _onLostFocus;
  70642. /**
  70643. * Attach the input controls to a specific dom element to get the input from.
  70644. * @param element Defines the element the controls should be listened from
  70645. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  70646. */
  70647. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  70648. /**
  70649. * Detach the current controls from the specified dom element.
  70650. * @param element Defines the element to stop listening the inputs from
  70651. */
  70652. detachControl(element: Nullable<HTMLElement>): void;
  70653. /**
  70654. * Update the current camera state depending on the inputs that have been used this frame.
  70655. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  70656. */
  70657. checkInputs(): void;
  70658. /**
  70659. * Gets the class name of the current intput.
  70660. * @returns the class name
  70661. */
  70662. getClassName(): string;
  70663. /**
  70664. * Get the friendly name associated with the input class.
  70665. * @returns the input friendly name
  70666. */
  70667. getSimpleName(): string;
  70668. }
  70669. }
  70670. declare module BABYLON {
  70671. /**
  70672. * Default Inputs manager for the FreeCamera.
  70673. * It groups all the default supported inputs for ease of use.
  70674. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  70675. */
  70676. export class FreeCameraInputsManager extends CameraInputsManager<FreeCamera> {
  70677. /**
  70678. * Instantiates a new FreeCameraInputsManager.
  70679. * @param camera Defines the camera the inputs belong to
  70680. */
  70681. constructor(camera: FreeCamera);
  70682. /**
  70683. * Add keyboard input support to the input manager.
  70684. * @returns the current input manager
  70685. */
  70686. addKeyboard(): FreeCameraInputsManager;
  70687. /**
  70688. * Add mouse input support to the input manager.
  70689. * @param touchEnabled if the FreeCameraMouseInput should support touch (default: true)
  70690. * @returns the current input manager
  70691. */
  70692. addMouse(touchEnabled?: boolean): FreeCameraInputsManager;
  70693. /**
  70694. * Add touch input support to the input manager.
  70695. * @returns the current input manager
  70696. */
  70697. addTouch(): FreeCameraInputsManager;
  70698. }
  70699. }
  70700. declare module BABYLON {
  70701. /**
  70702. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  70703. * Please consider using the new UniversalCamera instead as it adds more functionality like the gamepad.
  70704. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  70705. */
  70706. export class FreeCamera extends TargetCamera {
  70707. /**
  70708. * Define the collision ellipsoid of the camera.
  70709. * This is helpful to simulate a camera body like the player body around the camera
  70710. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  70711. */
  70712. ellipsoid: Vector3;
  70713. /**
  70714. * Define an offset for the position of the ellipsoid around the camera.
  70715. * This can be helpful to determine the center of the body near the gravity center of the body
  70716. * instead of its head.
  70717. */
  70718. ellipsoidOffset: Vector3;
  70719. /**
  70720. * Enable or disable collisions of the camera with the rest of the scene objects.
  70721. */
  70722. checkCollisions: boolean;
  70723. /**
  70724. * Enable or disable gravity on the camera.
  70725. */
  70726. applyGravity: boolean;
  70727. /**
  70728. * Define the input manager associated to the camera.
  70729. */
  70730. inputs: FreeCameraInputsManager;
  70731. /**
  70732. * Gets the input sensibility for a mouse input. (default is 2000.0)
  70733. * Higher values reduce sensitivity.
  70734. */
  70735. /**
  70736. * Sets the input sensibility for a mouse input. (default is 2000.0)
  70737. * Higher values reduce sensitivity.
  70738. */
  70739. angularSensibility: number;
  70740. /**
  70741. * Gets or Set the list of keyboard keys used to control the forward move of the camera.
  70742. */
  70743. keysUp: number[];
  70744. /**
  70745. * Gets or Set the list of keyboard keys used to control the backward move of the camera.
  70746. */
  70747. keysDown: number[];
  70748. /**
  70749. * Gets or Set the list of keyboard keys used to control the left strafe move of the camera.
  70750. */
  70751. keysLeft: number[];
  70752. /**
  70753. * Gets or Set the list of keyboard keys used to control the right strafe move of the camera.
  70754. */
  70755. keysRight: number[];
  70756. /**
  70757. * Event raised when the camera collide with a mesh in the scene.
  70758. */
  70759. onCollide: (collidedMesh: AbstractMesh) => void;
  70760. private _collider;
  70761. private _needMoveForGravity;
  70762. private _oldPosition;
  70763. private _diffPosition;
  70764. private _newPosition;
  70765. /** @hidden */
  70766. _localDirection: Vector3;
  70767. /** @hidden */
  70768. _transformedDirection: Vector3;
  70769. /**
  70770. * Instantiates a Free Camera.
  70771. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  70772. * Please consider using the new UniversalCamera instead as it adds more functionality like touch to this camera.
  70773. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  70774. * @param name Define the name of the camera in the scene
  70775. * @param position Define the start position of the camera in the scene
  70776. * @param scene Define the scene the camera belongs to
  70777. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  70778. */
  70779. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  70780. /**
  70781. * Attached controls to the current camera.
  70782. * @param element Defines the element the controls should be listened from
  70783. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  70784. */
  70785. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  70786. /**
  70787. * Detach the current controls from the camera.
  70788. * The camera will stop reacting to inputs.
  70789. * @param element Defines the element to stop listening the inputs from
  70790. */
  70791. detachControl(element: HTMLElement): void;
  70792. private _collisionMask;
  70793. /**
  70794. * Define a collision mask to limit the list of object the camera can collide with
  70795. */
  70796. collisionMask: number;
  70797. /** @hidden */
  70798. _collideWithWorld(displacement: Vector3): void;
  70799. private _onCollisionPositionChange;
  70800. /** @hidden */
  70801. _checkInputs(): void;
  70802. /** @hidden */
  70803. _decideIfNeedsToMove(): boolean;
  70804. /** @hidden */
  70805. _updatePosition(): void;
  70806. /**
  70807. * Destroy the camera and release the current resources hold by it.
  70808. */
  70809. dispose(): void;
  70810. /**
  70811. * Gets the current object class name.
  70812. * @return the class name
  70813. */
  70814. getClassName(): string;
  70815. }
  70816. }
  70817. declare module BABYLON {
  70818. /**
  70819. * Represents a gamepad control stick position
  70820. */
  70821. export class StickValues {
  70822. /**
  70823. * The x component of the control stick
  70824. */
  70825. x: number;
  70826. /**
  70827. * The y component of the control stick
  70828. */
  70829. y: number;
  70830. /**
  70831. * Initializes the gamepad x and y control stick values
  70832. * @param x The x component of the gamepad control stick value
  70833. * @param y The y component of the gamepad control stick value
  70834. */
  70835. constructor(
  70836. /**
  70837. * The x component of the control stick
  70838. */
  70839. x: number,
  70840. /**
  70841. * The y component of the control stick
  70842. */
  70843. y: number);
  70844. }
  70845. /**
  70846. * An interface which manages callbacks for gamepad button changes
  70847. */
  70848. export interface GamepadButtonChanges {
  70849. /**
  70850. * Called when a gamepad has been changed
  70851. */
  70852. changed: boolean;
  70853. /**
  70854. * Called when a gamepad press event has been triggered
  70855. */
  70856. pressChanged: boolean;
  70857. /**
  70858. * Called when a touch event has been triggered
  70859. */
  70860. touchChanged: boolean;
  70861. /**
  70862. * Called when a value has changed
  70863. */
  70864. valueChanged: boolean;
  70865. }
  70866. /**
  70867. * Represents a gamepad
  70868. */
  70869. export class Gamepad {
  70870. /**
  70871. * The id of the gamepad
  70872. */
  70873. id: string;
  70874. /**
  70875. * The index of the gamepad
  70876. */
  70877. index: number;
  70878. /**
  70879. * The browser gamepad
  70880. */
  70881. browserGamepad: any;
  70882. /**
  70883. * Specifies what type of gamepad this represents
  70884. */
  70885. type: number;
  70886. private _leftStick;
  70887. private _rightStick;
  70888. /** @hidden */
  70889. _isConnected: boolean;
  70890. private _leftStickAxisX;
  70891. private _leftStickAxisY;
  70892. private _rightStickAxisX;
  70893. private _rightStickAxisY;
  70894. /**
  70895. * Triggered when the left control stick has been changed
  70896. */
  70897. private _onleftstickchanged;
  70898. /**
  70899. * Triggered when the right control stick has been changed
  70900. */
  70901. private _onrightstickchanged;
  70902. /**
  70903. * Represents a gamepad controller
  70904. */
  70905. static GAMEPAD: number;
  70906. /**
  70907. * Represents a generic controller
  70908. */
  70909. static GENERIC: number;
  70910. /**
  70911. * Represents an XBox controller
  70912. */
  70913. static XBOX: number;
  70914. /**
  70915. * Represents a pose-enabled controller
  70916. */
  70917. static POSE_ENABLED: number;
  70918. /**
  70919. * Specifies whether the left control stick should be Y-inverted
  70920. */
  70921. protected _invertLeftStickY: boolean;
  70922. /**
  70923. * Specifies if the gamepad has been connected
  70924. */
  70925. readonly isConnected: boolean;
  70926. /**
  70927. * Initializes the gamepad
  70928. * @param id The id of the gamepad
  70929. * @param index The index of the gamepad
  70930. * @param browserGamepad The browser gamepad
  70931. * @param leftStickX The x component of the left joystick
  70932. * @param leftStickY The y component of the left joystick
  70933. * @param rightStickX The x component of the right joystick
  70934. * @param rightStickY The y component of the right joystick
  70935. */
  70936. constructor(
  70937. /**
  70938. * The id of the gamepad
  70939. */
  70940. id: string,
  70941. /**
  70942. * The index of the gamepad
  70943. */
  70944. index: number,
  70945. /**
  70946. * The browser gamepad
  70947. */
  70948. browserGamepad: any, leftStickX?: number, leftStickY?: number, rightStickX?: number, rightStickY?: number);
  70949. /**
  70950. * Callback triggered when the left joystick has changed
  70951. * @param callback
  70952. */
  70953. onleftstickchanged(callback: (values: StickValues) => void): void;
  70954. /**
  70955. * Callback triggered when the right joystick has changed
  70956. * @param callback
  70957. */
  70958. onrightstickchanged(callback: (values: StickValues) => void): void;
  70959. /**
  70960. * Gets the left joystick
  70961. */
  70962. /**
  70963. * Sets the left joystick values
  70964. */
  70965. leftStick: StickValues;
  70966. /**
  70967. * Gets the right joystick
  70968. */
  70969. /**
  70970. * Sets the right joystick value
  70971. */
  70972. rightStick: StickValues;
  70973. /**
  70974. * Updates the gamepad joystick positions
  70975. */
  70976. update(): void;
  70977. /**
  70978. * Disposes the gamepad
  70979. */
  70980. dispose(): void;
  70981. }
  70982. /**
  70983. * Represents a generic gamepad
  70984. */
  70985. export class GenericPad extends Gamepad {
  70986. private _buttons;
  70987. private _onbuttondown;
  70988. private _onbuttonup;
  70989. /**
  70990. * Observable triggered when a button has been pressed
  70991. */
  70992. onButtonDownObservable: Observable<number>;
  70993. /**
  70994. * Observable triggered when a button has been released
  70995. */
  70996. onButtonUpObservable: Observable<number>;
  70997. /**
  70998. * Callback triggered when a button has been pressed
  70999. * @param callback Called when a button has been pressed
  71000. */
  71001. onbuttondown(callback: (buttonPressed: number) => void): void;
  71002. /**
  71003. * Callback triggered when a button has been released
  71004. * @param callback Called when a button has been released
  71005. */
  71006. onbuttonup(callback: (buttonReleased: number) => void): void;
  71007. /**
  71008. * Initializes the generic gamepad
  71009. * @param id The id of the generic gamepad
  71010. * @param index The index of the generic gamepad
  71011. * @param browserGamepad The browser gamepad
  71012. */
  71013. constructor(id: string, index: number, browserGamepad: any);
  71014. private _setButtonValue;
  71015. /**
  71016. * Updates the generic gamepad
  71017. */
  71018. update(): void;
  71019. /**
  71020. * Disposes the generic gamepad
  71021. */
  71022. dispose(): void;
  71023. }
  71024. }
  71025. declare module BABYLON {
  71026. /**
  71027. * Defines the types of pose enabled controllers that are supported
  71028. */
  71029. export enum PoseEnabledControllerType {
  71030. /**
  71031. * HTC Vive
  71032. */
  71033. VIVE = 0,
  71034. /**
  71035. * Oculus Rift
  71036. */
  71037. OCULUS = 1,
  71038. /**
  71039. * Windows mixed reality
  71040. */
  71041. WINDOWS = 2,
  71042. /**
  71043. * Samsung gear VR
  71044. */
  71045. GEAR_VR = 3,
  71046. /**
  71047. * Google Daydream
  71048. */
  71049. DAYDREAM = 4,
  71050. /**
  71051. * Generic
  71052. */
  71053. GENERIC = 5
  71054. }
  71055. /**
  71056. * Defines the MutableGamepadButton interface for the state of a gamepad button
  71057. */
  71058. export interface MutableGamepadButton {
  71059. /**
  71060. * Value of the button/trigger
  71061. */
  71062. value: number;
  71063. /**
  71064. * If the button/trigger is currently touched
  71065. */
  71066. touched: boolean;
  71067. /**
  71068. * If the button/trigger is currently pressed
  71069. */
  71070. pressed: boolean;
  71071. }
  71072. /**
  71073. * Defines the ExtendedGamepadButton interface for a gamepad button which includes state provided by a pose controller
  71074. * @hidden
  71075. */
  71076. export interface ExtendedGamepadButton extends GamepadButton {
  71077. /**
  71078. * If the button/trigger is currently pressed
  71079. */
  71080. readonly pressed: boolean;
  71081. /**
  71082. * If the button/trigger is currently touched
  71083. */
  71084. readonly touched: boolean;
  71085. /**
  71086. * Value of the button/trigger
  71087. */
  71088. readonly value: number;
  71089. }
  71090. /** @hidden */
  71091. export interface _GamePadFactory {
  71092. /**
  71093. * Returns wether or not the current gamepad can be created for this type of controller.
  71094. * @param gamepadInfo Defines the gamepad info as receveid from the controller APIs.
  71095. * @returns true if it can be created, otherwise false
  71096. */
  71097. canCreate(gamepadInfo: any): boolean;
  71098. /**
  71099. * Creates a new instance of the Gamepad.
  71100. * @param gamepadInfo Defines the gamepad info as receveid from the controller APIs.
  71101. * @returns the new gamepad instance
  71102. */
  71103. create(gamepadInfo: any): Gamepad;
  71104. }
  71105. /**
  71106. * Defines the PoseEnabledControllerHelper object that is used initialize a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  71107. */
  71108. export class PoseEnabledControllerHelper {
  71109. /** @hidden */
  71110. static _ControllerFactories: _GamePadFactory[];
  71111. /** @hidden */
  71112. static _DefaultControllerFactory: Nullable<(gamepadInfo: any) => Gamepad>;
  71113. /**
  71114. * Initializes a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  71115. * @param vrGamepad the gamepad to initialized
  71116. * @returns a vr controller of the type the gamepad identified as
  71117. */
  71118. static InitiateController(vrGamepad: any): Gamepad;
  71119. }
  71120. /**
  71121. * Defines the PoseEnabledController object that contains state of a vr capable controller
  71122. */
  71123. export class PoseEnabledController extends Gamepad implements PoseControlled {
  71124. private _deviceRoomPosition;
  71125. private _deviceRoomRotationQuaternion;
  71126. /**
  71127. * The device position in babylon space
  71128. */
  71129. devicePosition: Vector3;
  71130. /**
  71131. * The device rotation in babylon space
  71132. */
  71133. deviceRotationQuaternion: Quaternion;
  71134. /**
  71135. * The scale factor of the device in babylon space
  71136. */
  71137. deviceScaleFactor: number;
  71138. /**
  71139. * (Likely devicePosition should be used instead) The device position in its room space
  71140. */
  71141. position: Vector3;
  71142. /**
  71143. * (Likely deviceRotationQuaternion should be used instead) The device rotation in its room space
  71144. */
  71145. rotationQuaternion: Quaternion;
  71146. /**
  71147. * The type of controller (Eg. Windows mixed reality)
  71148. */
  71149. controllerType: PoseEnabledControllerType;
  71150. protected _calculatedPosition: Vector3;
  71151. private _calculatedRotation;
  71152. /**
  71153. * The raw pose from the device
  71154. */
  71155. rawPose: DevicePose;
  71156. private _trackPosition;
  71157. private _maxRotationDistFromHeadset;
  71158. private _draggedRoomRotation;
  71159. /**
  71160. * @hidden
  71161. */
  71162. _disableTrackPosition(fixedPosition: Vector3): void;
  71163. /**
  71164. * Internal, the mesh attached to the controller
  71165. * @hidden
  71166. */
  71167. _mesh: Nullable<AbstractMesh>;
  71168. private _poseControlledCamera;
  71169. private _leftHandSystemQuaternion;
  71170. /**
  71171. * Internal, matrix used to convert room space to babylon space
  71172. * @hidden
  71173. */
  71174. _deviceToWorld: Matrix;
  71175. /**
  71176. * Node to be used when casting a ray from the controller
  71177. * @hidden
  71178. */
  71179. _pointingPoseNode: Nullable<TransformNode>;
  71180. /**
  71181. * Name of the child mesh that can be used to cast a ray from the controller
  71182. */
  71183. static readonly POINTING_POSE: string;
  71184. /**
  71185. * Creates a new PoseEnabledController from a gamepad
  71186. * @param browserGamepad the gamepad that the PoseEnabledController should be created from
  71187. */
  71188. constructor(browserGamepad: any);
  71189. private _workingMatrix;
  71190. /**
  71191. * Updates the state of the pose enbaled controller and mesh based on the current position and rotation of the controller
  71192. */
  71193. update(): void;
  71194. /**
  71195. * Updates only the pose device and mesh without doing any button event checking
  71196. */
  71197. protected _updatePoseAndMesh(): void;
  71198. /**
  71199. * Updates the state of the pose enbaled controller based on the raw pose data from the device
  71200. * @param poseData raw pose fromthe device
  71201. */
  71202. updateFromDevice(poseData: DevicePose): void;
  71203. /**
  71204. * @hidden
  71205. */
  71206. _meshAttachedObservable: Observable<AbstractMesh>;
  71207. /**
  71208. * Attaches a mesh to the controller
  71209. * @param mesh the mesh to be attached
  71210. */
  71211. attachToMesh(mesh: AbstractMesh): void;
  71212. /**
  71213. * Attaches the controllers mesh to a camera
  71214. * @param camera the camera the mesh should be attached to
  71215. */
  71216. attachToPoseControlledCamera(camera: TargetCamera): void;
  71217. /**
  71218. * Disposes of the controller
  71219. */
  71220. dispose(): void;
  71221. /**
  71222. * The mesh that is attached to the controller
  71223. */
  71224. readonly mesh: Nullable<AbstractMesh>;
  71225. /**
  71226. * Gets the ray of the controller in the direction the controller is pointing
  71227. * @param length the length the resulting ray should be
  71228. * @returns a ray in the direction the controller is pointing
  71229. */
  71230. getForwardRay(length?: number): Ray;
  71231. }
  71232. }
  71233. declare module BABYLON {
  71234. /**
  71235. * Defines the WebVRController object that represents controllers tracked in 3D space
  71236. */
  71237. export abstract class WebVRController extends PoseEnabledController {
  71238. /**
  71239. * Internal, the default controller model for the controller
  71240. */
  71241. protected _defaultModel: AbstractMesh;
  71242. /**
  71243. * Fired when the trigger state has changed
  71244. */
  71245. onTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  71246. /**
  71247. * Fired when the main button state has changed
  71248. */
  71249. onMainButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  71250. /**
  71251. * Fired when the secondary button state has changed
  71252. */
  71253. onSecondaryButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  71254. /**
  71255. * Fired when the pad state has changed
  71256. */
  71257. onPadStateChangedObservable: Observable<ExtendedGamepadButton>;
  71258. /**
  71259. * Fired when controllers stick values have changed
  71260. */
  71261. onPadValuesChangedObservable: Observable<StickValues>;
  71262. /**
  71263. * Array of button availible on the controller
  71264. */
  71265. protected _buttons: Array<MutableGamepadButton>;
  71266. private _onButtonStateChange;
  71267. /**
  71268. * Fired when a controller button's state has changed
  71269. * @param callback the callback containing the button that was modified
  71270. */
  71271. onButtonStateChange(callback: (controlledIndex: number, buttonIndex: number, state: ExtendedGamepadButton) => void): void;
  71272. /**
  71273. * X and Y axis corrisponding to the controllers joystick
  71274. */
  71275. pad: StickValues;
  71276. /**
  71277. * 'left' or 'right', see https://w3c.github.io/gamepad/extensions.html#gamepadhand-enum
  71278. */
  71279. hand: string;
  71280. /**
  71281. * The default controller model for the controller
  71282. */
  71283. readonly defaultModel: AbstractMesh;
  71284. /**
  71285. * Creates a new WebVRController from a gamepad
  71286. * @param vrGamepad the gamepad that the WebVRController should be created from
  71287. */
  71288. constructor(vrGamepad: any);
  71289. /**
  71290. * Updates the state of the controller and mesh based on the current position and rotation of the controller
  71291. */
  71292. update(): void;
  71293. /**
  71294. * Function to be called when a button is modified
  71295. */
  71296. protected abstract _handleButtonChange(buttonIdx: number, value: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  71297. /**
  71298. * Loads a mesh and attaches it to the controller
  71299. * @param scene the scene the mesh should be added to
  71300. * @param meshLoaded callback for when the mesh has been loaded
  71301. */
  71302. abstract initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  71303. private _setButtonValue;
  71304. private _changes;
  71305. private _checkChanges;
  71306. /**
  71307. * Disposes of th webVRCOntroller
  71308. */
  71309. dispose(): void;
  71310. }
  71311. }
  71312. declare module BABYLON {
  71313. /**
  71314. * The HemisphericLight simulates the ambient environment light,
  71315. * so the passed direction is the light reflection direction, not the incoming direction.
  71316. */
  71317. export class HemisphericLight extends Light {
  71318. /**
  71319. * The groundColor is the light in the opposite direction to the one specified during creation.
  71320. * 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.
  71321. */
  71322. groundColor: Color3;
  71323. /**
  71324. * The light reflection direction, not the incoming direction.
  71325. */
  71326. direction: Vector3;
  71327. /**
  71328. * Creates a HemisphericLight object in the scene according to the passed direction (Vector3).
  71329. * The HemisphericLight simulates the ambient environment light, so the passed direction is the light reflection direction, not the incoming direction.
  71330. * The HemisphericLight can't cast shadows.
  71331. * Documentation : https://doc.babylonjs.com/babylon101/lights
  71332. * @param name The friendly name of the light
  71333. * @param direction The direction of the light reflection
  71334. * @param scene The scene the light belongs to
  71335. */
  71336. constructor(name: string, direction: Vector3, scene: Scene);
  71337. protected _buildUniformLayout(): void;
  71338. /**
  71339. * Returns the string "HemisphericLight".
  71340. * @return The class name
  71341. */
  71342. getClassName(): string;
  71343. /**
  71344. * Sets the HemisphericLight direction towards the passed target (Vector3).
  71345. * Returns the updated direction.
  71346. * @param target The target the direction should point to
  71347. * @return The computed direction
  71348. */
  71349. setDirectionToTarget(target: Vector3): Vector3;
  71350. /**
  71351. * Returns the shadow generator associated to the light.
  71352. * @returns Always null for hemispheric lights because it does not support shadows.
  71353. */
  71354. getShadowGenerator(): Nullable<IShadowGenerator>;
  71355. /**
  71356. * Sets the passed Effect object with the HemisphericLight normalized direction and color and the passed name (string).
  71357. * @param effect The effect to update
  71358. * @param lightIndex The index of the light in the effect to update
  71359. * @returns The hemispheric light
  71360. */
  71361. transferToEffect(effect: Effect, lightIndex: string): HemisphericLight;
  71362. /**
  71363. * Computes the world matrix of the node
  71364. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  71365. * @param useWasUpdatedFlag defines a reserved property
  71366. * @returns the world matrix
  71367. */
  71368. computeWorldMatrix(): Matrix;
  71369. /**
  71370. * Returns the integer 3.
  71371. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  71372. */
  71373. getTypeID(): number;
  71374. /**
  71375. * Prepares the list of defines specific to the light type.
  71376. * @param defines the list of defines
  71377. * @param lightIndex defines the index of the light for the effect
  71378. */
  71379. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  71380. }
  71381. }
  71382. declare module BABYLON {
  71383. /**
  71384. * This is a copy of VRPose. See https://developer.mozilla.org/en-US/docs/Web/API/VRPose
  71385. * IMPORTANT!! The data is right-hand data.
  71386. * @export
  71387. * @interface DevicePose
  71388. */
  71389. export interface DevicePose {
  71390. /**
  71391. * The position of the device, values in array are [x,y,z].
  71392. */
  71393. readonly position: Nullable<Float32Array>;
  71394. /**
  71395. * The linearVelocity of the device, values in array are [x,y,z].
  71396. */
  71397. readonly linearVelocity: Nullable<Float32Array>;
  71398. /**
  71399. * The linearAcceleration of the device, values in array are [x,y,z].
  71400. */
  71401. readonly linearAcceleration: Nullable<Float32Array>;
  71402. /**
  71403. * The orientation of the device in a quaternion array, values in array are [x,y,z,w].
  71404. */
  71405. readonly orientation: Nullable<Float32Array>;
  71406. /**
  71407. * The angularVelocity of the device, values in array are [x,y,z].
  71408. */
  71409. readonly angularVelocity: Nullable<Float32Array>;
  71410. /**
  71411. * The angularAcceleration of the device, values in array are [x,y,z].
  71412. */
  71413. readonly angularAcceleration: Nullable<Float32Array>;
  71414. }
  71415. /**
  71416. * Interface representing a pose controlled object in Babylon.
  71417. * A pose controlled object has both regular pose values as well as pose values
  71418. * from an external device such as a VR head mounted display
  71419. */
  71420. export interface PoseControlled {
  71421. /**
  71422. * The position of the object in babylon space.
  71423. */
  71424. position: Vector3;
  71425. /**
  71426. * The rotation quaternion of the object in babylon space.
  71427. */
  71428. rotationQuaternion: Quaternion;
  71429. /**
  71430. * The position of the device in babylon space.
  71431. */
  71432. devicePosition?: Vector3;
  71433. /**
  71434. * The rotation quaternion of the device in babylon space.
  71435. */
  71436. deviceRotationQuaternion: Quaternion;
  71437. /**
  71438. * The raw pose coming from the device.
  71439. */
  71440. rawPose: Nullable<DevicePose>;
  71441. /**
  71442. * The scale of the device to be used when translating from device space to babylon space.
  71443. */
  71444. deviceScaleFactor: number;
  71445. /**
  71446. * Updates the poseControlled values based on the input device pose.
  71447. * @param poseData the pose data to update the object with
  71448. */
  71449. updateFromDevice(poseData: DevicePose): void;
  71450. }
  71451. /**
  71452. * Set of options to customize the webVRCamera
  71453. */
  71454. export interface WebVROptions {
  71455. /**
  71456. * Sets if the webVR camera should be tracked to the vrDevice. (default: true)
  71457. */
  71458. trackPosition?: boolean;
  71459. /**
  71460. * Sets the scale of the vrDevice in babylon space. (default: 1)
  71461. */
  71462. positionScale?: number;
  71463. /**
  71464. * If there are more than one VRDisplays, this will choose the display matching this name. (default: pick first vrDisplay)
  71465. */
  71466. displayName?: string;
  71467. /**
  71468. * Should the native controller meshes be initialized. (default: true)
  71469. */
  71470. controllerMeshes?: boolean;
  71471. /**
  71472. * Creating a default HemiLight only on controllers. (default: true)
  71473. */
  71474. defaultLightingOnControllers?: boolean;
  71475. /**
  71476. * If you don't want to use the default VR button of the helper. (default: false)
  71477. */
  71478. useCustomVRButton?: boolean;
  71479. /**
  71480. * If you'd like to provide your own button to the VRHelper. (default: standard babylon vr button)
  71481. */
  71482. customVRButton?: HTMLButtonElement;
  71483. /**
  71484. * To change the length of the ray for gaze/controllers. Will be scaled by positionScale. (default: 100)
  71485. */
  71486. rayLength?: number;
  71487. /**
  71488. * To change the default offset from the ground to account for user's height in meters. Will be scaled by positionScale. (default: 1.7)
  71489. */
  71490. defaultHeight?: number;
  71491. }
  71492. /**
  71493. * This represents a WebVR camera.
  71494. * The WebVR camera is Babylon's simple interface to interaction with Windows Mixed Reality, HTC Vive and Oculus Rift.
  71495. * @example http://doc.babylonjs.com/how_to/webvr_camera
  71496. */
  71497. export class WebVRFreeCamera extends FreeCamera implements PoseControlled {
  71498. private webVROptions;
  71499. /**
  71500. * @hidden
  71501. * The vrDisplay tied to the camera. See https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay
  71502. */
  71503. _vrDevice: any;
  71504. /**
  71505. * The rawPose of the vrDevice.
  71506. */
  71507. rawPose: Nullable<DevicePose>;
  71508. private _onVREnabled;
  71509. private _specsVersion;
  71510. private _attached;
  71511. private _frameData;
  71512. protected _descendants: Array<Node>;
  71513. private _deviceRoomPosition;
  71514. /** @hidden */
  71515. _deviceRoomRotationQuaternion: Quaternion;
  71516. private _standingMatrix;
  71517. /**
  71518. * Represents device position in babylon space.
  71519. */
  71520. devicePosition: Vector3;
  71521. /**
  71522. * Represents device rotation in babylon space.
  71523. */
  71524. deviceRotationQuaternion: Quaternion;
  71525. /**
  71526. * The scale of the device to be used when translating from device space to babylon space.
  71527. */
  71528. deviceScaleFactor: number;
  71529. private _deviceToWorld;
  71530. private _worldToDevice;
  71531. /**
  71532. * References to the webVR controllers for the vrDevice.
  71533. */
  71534. controllers: Array<WebVRController>;
  71535. /**
  71536. * Emits an event when a controller is attached.
  71537. */
  71538. onControllersAttachedObservable: Observable<WebVRController[]>;
  71539. /**
  71540. * Emits an event when a controller's mesh has been loaded;
  71541. */
  71542. onControllerMeshLoadedObservable: Observable<WebVRController>;
  71543. /**
  71544. * Emits an event when the HMD's pose has been updated.
  71545. */
  71546. onPoseUpdatedFromDeviceObservable: Observable<any>;
  71547. private _poseSet;
  71548. /**
  71549. * If the rig cameras be used as parent instead of this camera.
  71550. */
  71551. rigParenting: boolean;
  71552. private _lightOnControllers;
  71553. private _defaultHeight?;
  71554. /**
  71555. * Instantiates a WebVRFreeCamera.
  71556. * @param name The name of the WebVRFreeCamera
  71557. * @param position The starting anchor position for the camera
  71558. * @param scene The scene the camera belongs to
  71559. * @param webVROptions a set of customizable options for the webVRCamera
  71560. */
  71561. constructor(name: string, position: Vector3, scene: Scene, webVROptions?: WebVROptions);
  71562. /**
  71563. * Gets the device distance from the ground in meters.
  71564. * @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.
  71565. */
  71566. deviceDistanceToRoomGround(): number;
  71567. /**
  71568. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  71569. * @param callback will be called when the standing matrix is set. Callback parameter is if the standing matrix is supported.
  71570. */
  71571. useStandingMatrix(callback?: (bool: boolean) => void): void;
  71572. /**
  71573. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  71574. * @returns A promise with a boolean set to if the standing matrix is supported.
  71575. */
  71576. useStandingMatrixAsync(): Promise<boolean>;
  71577. /**
  71578. * Disposes the camera
  71579. */
  71580. dispose(): void;
  71581. /**
  71582. * Gets a vrController by name.
  71583. * @param name The name of the controller to retreive
  71584. * @returns the controller matching the name specified or null if not found
  71585. */
  71586. getControllerByName(name: string): Nullable<WebVRController>;
  71587. private _leftController;
  71588. /**
  71589. * The controller corrisponding to the users left hand.
  71590. */
  71591. readonly leftController: Nullable<WebVRController>;
  71592. private _rightController;
  71593. /**
  71594. * The controller corrisponding to the users right hand.
  71595. */
  71596. readonly rightController: Nullable<WebVRController>;
  71597. /**
  71598. * Casts a ray forward from the vrCamera's gaze.
  71599. * @param length Length of the ray (default: 100)
  71600. * @returns the ray corrisponding to the gaze
  71601. */
  71602. getForwardRay(length?: number): Ray;
  71603. /**
  71604. * @hidden
  71605. * Updates the camera based on device's frame data
  71606. */
  71607. _checkInputs(): void;
  71608. /**
  71609. * Updates the poseControlled values based on the input device pose.
  71610. * @param poseData Pose coming from the device
  71611. */
  71612. updateFromDevice(poseData: DevicePose): void;
  71613. private _htmlElementAttached;
  71614. private _detachIfAttached;
  71615. /**
  71616. * WebVR's attach control will start broadcasting frames to the device.
  71617. * Note that in certain browsers (chrome for example) this function must be called
  71618. * within a user-interaction callback. Example:
  71619. * <pre> scene.onPointerDown = function() { camera.attachControl(canvas); }</pre>
  71620. *
  71621. * @param element html element to attach the vrDevice to
  71622. * @param noPreventDefault prevent the default html element operation when attaching the vrDevice
  71623. */
  71624. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  71625. /**
  71626. * Detaches the camera from the html element and disables VR
  71627. *
  71628. * @param element html element to detach from
  71629. */
  71630. detachControl(element: HTMLElement): void;
  71631. /**
  71632. * @returns the name of this class
  71633. */
  71634. getClassName(): string;
  71635. /**
  71636. * Calls resetPose on the vrDisplay
  71637. * See: https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay/resetPose
  71638. */
  71639. resetToCurrentRotation(): void;
  71640. /**
  71641. * @hidden
  71642. * Updates the rig cameras (left and right eye)
  71643. */
  71644. _updateRigCameras(): void;
  71645. private _workingVector;
  71646. private _oneVector;
  71647. private _workingMatrix;
  71648. private updateCacheCalled;
  71649. private _correctPositionIfNotTrackPosition;
  71650. /**
  71651. * @hidden
  71652. * Updates the cached values of the camera
  71653. * @param ignoreParentClass ignores updating the parent class's cache (default: false)
  71654. */
  71655. _updateCache(ignoreParentClass?: boolean): void;
  71656. /**
  71657. * @hidden
  71658. * Get current device position in babylon world
  71659. */
  71660. _computeDevicePosition(): void;
  71661. /**
  71662. * Updates the current device position and rotation in the babylon world
  71663. */
  71664. update(): void;
  71665. /**
  71666. * @hidden
  71667. * Gets the view matrix of this camera (Always set to identity as left and right eye cameras contain the actual view matrix)
  71668. * @returns an identity matrix
  71669. */
  71670. _getViewMatrix(): Matrix;
  71671. private _tmpMatrix;
  71672. /**
  71673. * This function is called by the two RIG cameras.
  71674. * 'this' is the left or right camera (and NOT (!!!) the WebVRFreeCamera instance)
  71675. * @hidden
  71676. */
  71677. _getWebVRViewMatrix(): Matrix;
  71678. /** @hidden */
  71679. _getWebVRProjectionMatrix(): Matrix;
  71680. private _onGamepadConnectedObserver;
  71681. private _onGamepadDisconnectedObserver;
  71682. private _updateCacheWhenTrackingDisabledObserver;
  71683. /**
  71684. * Initializes the controllers and their meshes
  71685. */
  71686. initControllers(): void;
  71687. }
  71688. }
  71689. declare module BABYLON {
  71690. /**
  71691. * Size options for a post process
  71692. */
  71693. export type PostProcessOptions = {
  71694. width: number;
  71695. height: number;
  71696. };
  71697. /**
  71698. * PostProcess can be used to apply a shader to a texture after it has been rendered
  71699. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  71700. */
  71701. export class PostProcess {
  71702. /** Name of the PostProcess. */
  71703. name: string;
  71704. /**
  71705. * Gets or sets the unique id of the post process
  71706. */
  71707. uniqueId: number;
  71708. /**
  71709. * Width of the texture to apply the post process on
  71710. */
  71711. width: number;
  71712. /**
  71713. * Height of the texture to apply the post process on
  71714. */
  71715. height: number;
  71716. /**
  71717. * Internal, reference to the location where this postprocess was output to. (Typically the texture on the next postprocess in the chain)
  71718. * @hidden
  71719. */
  71720. _outputTexture: Nullable<InternalTexture>;
  71721. /**
  71722. * Sampling mode used by the shader
  71723. * See https://doc.babylonjs.com/classes/3.1/texture
  71724. */
  71725. renderTargetSamplingMode: number;
  71726. /**
  71727. * Clear color to use when screen clearing
  71728. */
  71729. clearColor: Color4;
  71730. /**
  71731. * If the buffer needs to be cleared before applying the post process. (default: true)
  71732. * Should be set to false if shader will overwrite all previous pixels.
  71733. */
  71734. autoClear: boolean;
  71735. /**
  71736. * Type of alpha mode to use when performing the post process (default: Engine.ALPHA_DISABLE)
  71737. */
  71738. alphaMode: number;
  71739. /**
  71740. * Sets the setAlphaBlendConstants of the babylon engine
  71741. */
  71742. alphaConstants: Color4;
  71743. /**
  71744. * Animations to be used for the post processing
  71745. */
  71746. animations: Animation[];
  71747. /**
  71748. * Enable Pixel Perfect mode where texture is not scaled to be power of 2.
  71749. * Can only be used on a single postprocess or on the last one of a chain. (default: false)
  71750. */
  71751. enablePixelPerfectMode: boolean;
  71752. /**
  71753. * Force the postprocess to be applied without taking in account viewport
  71754. */
  71755. forceFullscreenViewport: boolean;
  71756. /**
  71757. * List of inspectable custom properties (used by the Inspector)
  71758. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  71759. */
  71760. inspectableCustomProperties: IInspectable[];
  71761. /**
  71762. * Scale mode for the post process (default: Engine.SCALEMODE_FLOOR)
  71763. *
  71764. * | Value | Type | Description |
  71765. * | ----- | ----------------------------------- | ----------- |
  71766. * | 1 | SCALEMODE_FLOOR | [engine.scalemode_floor](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_floor) |
  71767. * | 2 | SCALEMODE_NEAREST | [engine.scalemode_nearest](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_nearest) |
  71768. * | 3 | SCALEMODE_CEILING | [engine.scalemode_ceiling](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_ceiling) |
  71769. *
  71770. */
  71771. scaleMode: number;
  71772. /**
  71773. * Force textures to be a power of two (default: false)
  71774. */
  71775. alwaysForcePOT: boolean;
  71776. private _samples;
  71777. /**
  71778. * Number of sample textures (default: 1)
  71779. */
  71780. samples: number;
  71781. /**
  71782. * Modify the scale of the post process to be the same as the viewport (default: false)
  71783. */
  71784. adaptScaleToCurrentViewport: boolean;
  71785. private _camera;
  71786. private _scene;
  71787. private _engine;
  71788. private _options;
  71789. private _reusable;
  71790. private _textureType;
  71791. /**
  71792. * Smart array of input and output textures for the post process.
  71793. * @hidden
  71794. */
  71795. _textures: SmartArray<InternalTexture>;
  71796. /**
  71797. * The index in _textures that corresponds to the output texture.
  71798. * @hidden
  71799. */
  71800. _currentRenderTextureInd: number;
  71801. private _effect;
  71802. private _samplers;
  71803. private _fragmentUrl;
  71804. private _vertexUrl;
  71805. private _parameters;
  71806. private _scaleRatio;
  71807. protected _indexParameters: any;
  71808. private _shareOutputWithPostProcess;
  71809. private _texelSize;
  71810. private _forcedOutputTexture;
  71811. /**
  71812. * Returns the fragment url or shader name used in the post process.
  71813. * @returns the fragment url or name in the shader store.
  71814. */
  71815. getEffectName(): string;
  71816. /**
  71817. * An event triggered when the postprocess is activated.
  71818. */
  71819. onActivateObservable: Observable<Camera>;
  71820. private _onActivateObserver;
  71821. /**
  71822. * A function that is added to the onActivateObservable
  71823. */
  71824. onActivate: Nullable<(camera: Camera) => void>;
  71825. /**
  71826. * An event triggered when the postprocess changes its size.
  71827. */
  71828. onSizeChangedObservable: Observable<PostProcess>;
  71829. private _onSizeChangedObserver;
  71830. /**
  71831. * A function that is added to the onSizeChangedObservable
  71832. */
  71833. onSizeChanged: (postProcess: PostProcess) => void;
  71834. /**
  71835. * An event triggered when the postprocess applies its effect.
  71836. */
  71837. onApplyObservable: Observable<Effect>;
  71838. private _onApplyObserver;
  71839. /**
  71840. * A function that is added to the onApplyObservable
  71841. */
  71842. onApply: (effect: Effect) => void;
  71843. /**
  71844. * An event triggered before rendering the postprocess
  71845. */
  71846. onBeforeRenderObservable: Observable<Effect>;
  71847. private _onBeforeRenderObserver;
  71848. /**
  71849. * A function that is added to the onBeforeRenderObservable
  71850. */
  71851. onBeforeRender: (effect: Effect) => void;
  71852. /**
  71853. * An event triggered after rendering the postprocess
  71854. */
  71855. onAfterRenderObservable: Observable<Effect>;
  71856. private _onAfterRenderObserver;
  71857. /**
  71858. * A function that is added to the onAfterRenderObservable
  71859. */
  71860. onAfterRender: (efect: Effect) => void;
  71861. /**
  71862. * 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
  71863. * render it's output into this texture and this texture will be used as textureSampler in the fragment shader of this post process.
  71864. */
  71865. inputTexture: InternalTexture;
  71866. /**
  71867. * Gets the camera which post process is applied to.
  71868. * @returns The camera the post process is applied to.
  71869. */
  71870. getCamera(): Camera;
  71871. /**
  71872. * Gets the texel size of the postprocess.
  71873. * See https://en.wikipedia.org/wiki/Texel_(graphics)
  71874. */
  71875. readonly texelSize: Vector2;
  71876. /**
  71877. * Creates a new instance PostProcess
  71878. * @param name The name of the PostProcess.
  71879. * @param fragmentUrl The url of the fragment shader to be used.
  71880. * @param parameters Array of the names of uniform non-sampler2D variables that will be passed to the shader.
  71881. * @param samplers Array of the names of uniform sampler2D variables that will be passed to the shader.
  71882. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  71883. * @param camera The camera to apply the render pass to.
  71884. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  71885. * @param engine The engine which the post process will be applied. (default: current engine)
  71886. * @param reusable If the post process can be reused on the same frame. (default: false)
  71887. * @param defines String of defines that will be set when running the fragment shader. (default: null)
  71888. * @param textureType Type of textures used when performing the post process. (default: 0)
  71889. * @param vertexUrl The url of the vertex shader to be used. (default: "postprocess")
  71890. * @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
  71891. * @param blockCompilation If the shader should not be compiled imediatly. (default: false)
  71892. */
  71893. constructor(
  71894. /** Name of the PostProcess. */
  71895. 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);
  71896. /**
  71897. * Gets a string idenfifying the name of the class
  71898. * @returns "PostProcess" string
  71899. */
  71900. getClassName(): string;
  71901. /**
  71902. * Gets the engine which this post process belongs to.
  71903. * @returns The engine the post process was enabled with.
  71904. */
  71905. getEngine(): Engine;
  71906. /**
  71907. * The effect that is created when initializing the post process.
  71908. * @returns The created effect corrisponding the the postprocess.
  71909. */
  71910. getEffect(): Effect;
  71911. /**
  71912. * To avoid multiple redundant textures for multiple post process, the output the output texture for this post process can be shared with another.
  71913. * @param postProcess The post process to share the output with.
  71914. * @returns This post process.
  71915. */
  71916. shareOutputWith(postProcess: PostProcess): PostProcess;
  71917. /**
  71918. * Reverses the effect of calling shareOutputWith and returns the post process back to its original state.
  71919. * This should be called if the post process that shares output with this post process is disabled/disposed.
  71920. */
  71921. useOwnOutput(): void;
  71922. /**
  71923. * Updates the effect with the current post process compile time values and recompiles the shader.
  71924. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  71925. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  71926. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  71927. * @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
  71928. * @param onCompiled Called when the shader has been compiled.
  71929. * @param onError Called if there is an error when compiling a shader.
  71930. */
  71931. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  71932. /**
  71933. * The post process is reusable if it can be used multiple times within one frame.
  71934. * @returns If the post process is reusable
  71935. */
  71936. isReusable(): boolean;
  71937. /** invalidate frameBuffer to hint the postprocess to create a depth buffer */
  71938. markTextureDirty(): void;
  71939. /**
  71940. * Activates the post process by intializing the textures to be used when executed. Notifies onActivateObservable.
  71941. * 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.
  71942. * @param camera The camera that will be used in the post process. This camera will be used when calling onActivateObservable.
  71943. * @param sourceTexture The source texture to be inspected to get the width and height if not specified in the post process constructor. (default: null)
  71944. * @param forceDepthStencil If true, a depth and stencil buffer will be generated. (default: false)
  71945. * @returns The target texture that was bound to be written to.
  71946. */
  71947. activate(camera: Nullable<Camera>, sourceTexture?: Nullable<InternalTexture>, forceDepthStencil?: boolean): InternalTexture;
  71948. /**
  71949. * If the post process is supported.
  71950. */
  71951. readonly isSupported: boolean;
  71952. /**
  71953. * The aspect ratio of the output texture.
  71954. */
  71955. readonly aspectRatio: number;
  71956. /**
  71957. * Get a value indicating if the post-process is ready to be used
  71958. * @returns true if the post-process is ready (shader is compiled)
  71959. */
  71960. isReady(): boolean;
  71961. /**
  71962. * Binds all textures and uniforms to the shader, this will be run on every pass.
  71963. * @returns the effect corrisponding to this post process. Null if not compiled or not ready.
  71964. */
  71965. apply(): Nullable<Effect>;
  71966. private _disposeTextures;
  71967. /**
  71968. * Disposes the post process.
  71969. * @param camera The camera to dispose the post process on.
  71970. */
  71971. dispose(camera?: Camera): void;
  71972. }
  71973. }
  71974. declare module BABYLON {
  71975. /**
  71976. * PostProcessManager is used to manage one or more post processes or post process pipelines
  71977. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  71978. */
  71979. export class PostProcessManager {
  71980. private _scene;
  71981. private _indexBuffer;
  71982. private _vertexBuffers;
  71983. /**
  71984. * Creates a new instance PostProcess
  71985. * @param scene The scene that the post process is associated with.
  71986. */
  71987. constructor(scene: Scene);
  71988. private _prepareBuffers;
  71989. private _buildIndexBuffer;
  71990. /**
  71991. * Rebuilds the vertex buffers of the manager.
  71992. * @hidden
  71993. */
  71994. _rebuild(): void;
  71995. /**
  71996. * Prepares a frame to be run through a post process.
  71997. * @param sourceTexture The input texture to the post procesess. (default: null)
  71998. * @param postProcesses An array of post processes to be run. (default: null)
  71999. * @returns True if the post processes were able to be run.
  72000. * @hidden
  72001. */
  72002. _prepareFrame(sourceTexture?: Nullable<InternalTexture>, postProcesses?: Nullable<PostProcess[]>): boolean;
  72003. /**
  72004. * Manually render a set of post processes to a texture.
  72005. * @param postProcesses An array of post processes to be run.
  72006. * @param targetTexture The target texture to render to.
  72007. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight
  72008. * @param faceIndex defines the face to render to if a cubemap is defined as the target
  72009. * @param lodLevel defines which lod of the texture to render to
  72010. */
  72011. directRender(postProcesses: PostProcess[], targetTexture?: Nullable<InternalTexture>, forceFullscreenViewport?: boolean, faceIndex?: number, lodLevel?: number): void;
  72012. /**
  72013. * Finalize the result of the output of the postprocesses.
  72014. * @param doNotPresent If true the result will not be displayed to the screen.
  72015. * @param targetTexture The target texture to render to.
  72016. * @param faceIndex The index of the face to bind the target texture to.
  72017. * @param postProcesses The array of post processes to render.
  72018. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight (default: false)
  72019. * @hidden
  72020. */
  72021. _finalizeFrame(doNotPresent?: boolean, targetTexture?: InternalTexture, faceIndex?: number, postProcesses?: Array<PostProcess>, forceFullscreenViewport?: boolean): void;
  72022. /**
  72023. * Disposes of the post process manager.
  72024. */
  72025. dispose(): void;
  72026. }
  72027. }
  72028. declare module BABYLON {
  72029. interface AbstractScene {
  72030. /**
  72031. * The list of layers (background and foreground) of the scene
  72032. */
  72033. layers: Array<Layer>;
  72034. }
  72035. /**
  72036. * Defines the layer scene component responsible to manage any layers
  72037. * in a given scene.
  72038. */
  72039. export class LayerSceneComponent implements ISceneComponent {
  72040. /**
  72041. * The component name helpfull to identify the component in the list of scene components.
  72042. */
  72043. readonly name: string;
  72044. /**
  72045. * The scene the component belongs to.
  72046. */
  72047. scene: Scene;
  72048. private _engine;
  72049. /**
  72050. * Creates a new instance of the component for the given scene
  72051. * @param scene Defines the scene to register the component in
  72052. */
  72053. constructor(scene: Scene);
  72054. /**
  72055. * Registers the component in a given scene
  72056. */
  72057. register(): void;
  72058. /**
  72059. * Rebuilds the elements related to this component in case of
  72060. * context lost for instance.
  72061. */
  72062. rebuild(): void;
  72063. /**
  72064. * Disposes the component and the associated ressources.
  72065. */
  72066. dispose(): void;
  72067. private _draw;
  72068. private _drawCameraPredicate;
  72069. private _drawCameraBackground;
  72070. private _drawCameraForeground;
  72071. private _drawRenderTargetPredicate;
  72072. private _drawRenderTargetBackground;
  72073. private _drawRenderTargetForeground;
  72074. }
  72075. }
  72076. declare module BABYLON {
  72077. /** @hidden */
  72078. export var layerPixelShader: {
  72079. name: string;
  72080. shader: string;
  72081. };
  72082. }
  72083. declare module BABYLON {
  72084. /** @hidden */
  72085. export var layerVertexShader: {
  72086. name: string;
  72087. shader: string;
  72088. };
  72089. }
  72090. declare module BABYLON {
  72091. /**
  72092. * This represents a full screen 2d layer.
  72093. * This can be useful to display a picture in the background of your scene for instance.
  72094. * @see https://www.babylonjs-playground.com/#08A2BS#1
  72095. */
  72096. export class Layer {
  72097. /**
  72098. * Define the name of the layer.
  72099. */
  72100. name: string;
  72101. /**
  72102. * Define the texture the layer should display.
  72103. */
  72104. texture: Nullable<Texture>;
  72105. /**
  72106. * Is the layer in background or foreground.
  72107. */
  72108. isBackground: boolean;
  72109. /**
  72110. * Define the color of the layer (instead of texture).
  72111. */
  72112. color: Color4;
  72113. /**
  72114. * Define the scale of the layer in order to zoom in out of the texture.
  72115. */
  72116. scale: Vector2;
  72117. /**
  72118. * Define an offset for the layer in order to shift the texture.
  72119. */
  72120. offset: Vector2;
  72121. /**
  72122. * Define the alpha blending mode used in the layer in case the texture or color has an alpha.
  72123. */
  72124. alphaBlendingMode: number;
  72125. /**
  72126. * Define if the layer should alpha test or alpha blend with the rest of the scene.
  72127. * Alpha test will not mix with the background color in case of transparency.
  72128. * It will either use the texture color or the background depending on the alpha value of the current pixel.
  72129. */
  72130. alphaTest: boolean;
  72131. /**
  72132. * Define a mask to restrict the layer to only some of the scene cameras.
  72133. */
  72134. layerMask: number;
  72135. /**
  72136. * Define the list of render target the layer is visible into.
  72137. */
  72138. renderTargetTextures: RenderTargetTexture[];
  72139. /**
  72140. * Define if the layer is only used in renderTarget or if it also
  72141. * renders in the main frame buffer of the canvas.
  72142. */
  72143. renderOnlyInRenderTargetTextures: boolean;
  72144. private _scene;
  72145. private _vertexBuffers;
  72146. private _indexBuffer;
  72147. private _effect;
  72148. private _alphaTestEffect;
  72149. /**
  72150. * An event triggered when the layer is disposed.
  72151. */
  72152. onDisposeObservable: Observable<Layer>;
  72153. private _onDisposeObserver;
  72154. /**
  72155. * Back compatibility with callback before the onDisposeObservable existed.
  72156. * The set callback will be triggered when the layer has been disposed.
  72157. */
  72158. onDispose: () => void;
  72159. /**
  72160. * An event triggered before rendering the scene
  72161. */
  72162. onBeforeRenderObservable: Observable<Layer>;
  72163. private _onBeforeRenderObserver;
  72164. /**
  72165. * Back compatibility with callback before the onBeforeRenderObservable existed.
  72166. * The set callback will be triggered just before rendering the layer.
  72167. */
  72168. onBeforeRender: () => void;
  72169. /**
  72170. * An event triggered after rendering the scene
  72171. */
  72172. onAfterRenderObservable: Observable<Layer>;
  72173. private _onAfterRenderObserver;
  72174. /**
  72175. * Back compatibility with callback before the onAfterRenderObservable existed.
  72176. * The set callback will be triggered just after rendering the layer.
  72177. */
  72178. onAfterRender: () => void;
  72179. /**
  72180. * Instantiates a new layer.
  72181. * This represents a full screen 2d layer.
  72182. * This can be useful to display a picture in the background of your scene for instance.
  72183. * @see https://www.babylonjs-playground.com/#08A2BS#1
  72184. * @param name Define the name of the layer in the scene
  72185. * @param imgUrl Define the url of the texture to display in the layer
  72186. * @param scene Define the scene the layer belongs to
  72187. * @param isBackground Defines whether the layer is displayed in front or behind the scene
  72188. * @param color Defines a color for the layer
  72189. */
  72190. constructor(
  72191. /**
  72192. * Define the name of the layer.
  72193. */
  72194. name: string, imgUrl: Nullable<string>, scene: Nullable<Scene>, isBackground?: boolean, color?: Color4);
  72195. private _createIndexBuffer;
  72196. /** @hidden */
  72197. _rebuild(): void;
  72198. /**
  72199. * Renders the layer in the scene.
  72200. */
  72201. render(): void;
  72202. /**
  72203. * Disposes and releases the associated ressources.
  72204. */
  72205. dispose(): void;
  72206. }
  72207. }
  72208. declare module BABYLON {
  72209. interface AbstractScene {
  72210. /**
  72211. * The list of procedural textures added to the scene
  72212. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  72213. */
  72214. proceduralTextures: Array<ProceduralTexture>;
  72215. }
  72216. /**
  72217. * Defines the Procedural Texture scene component responsible to manage any Procedural Texture
  72218. * in a given scene.
  72219. */
  72220. export class ProceduralTextureSceneComponent implements ISceneComponent {
  72221. /**
  72222. * The component name helpfull to identify the component in the list of scene components.
  72223. */
  72224. readonly name: string;
  72225. /**
  72226. * The scene the component belongs to.
  72227. */
  72228. scene: Scene;
  72229. /**
  72230. * Creates a new instance of the component for the given scene
  72231. * @param scene Defines the scene to register the component in
  72232. */
  72233. constructor(scene: Scene);
  72234. /**
  72235. * Registers the component in a given scene
  72236. */
  72237. register(): void;
  72238. /**
  72239. * Rebuilds the elements related to this component in case of
  72240. * context lost for instance.
  72241. */
  72242. rebuild(): void;
  72243. /**
  72244. * Disposes the component and the associated ressources.
  72245. */
  72246. dispose(): void;
  72247. private _beforeClear;
  72248. }
  72249. }
  72250. declare module BABYLON {
  72251. /** @hidden */
  72252. export var proceduralVertexShader: {
  72253. name: string;
  72254. shader: string;
  72255. };
  72256. }
  72257. declare module BABYLON {
  72258. /**
  72259. * 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.
  72260. * This is the base class of any Procedural texture and contains most of the shareable code.
  72261. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  72262. */
  72263. export class ProceduralTexture extends Texture {
  72264. isCube: boolean;
  72265. /**
  72266. * Define if the texture is enabled or not (disabled texture will not render)
  72267. */
  72268. isEnabled: boolean;
  72269. /**
  72270. * Define if the texture must be cleared before rendering (default is true)
  72271. */
  72272. autoClear: boolean;
  72273. /**
  72274. * Callback called when the texture is generated
  72275. */
  72276. onGenerated: () => void;
  72277. /**
  72278. * Event raised when the texture is generated
  72279. */
  72280. onGeneratedObservable: Observable<ProceduralTexture>;
  72281. /** @hidden */
  72282. _generateMipMaps: boolean;
  72283. /** @hidden **/
  72284. _effect: Effect;
  72285. /** @hidden */
  72286. _textures: {
  72287. [key: string]: Texture;
  72288. };
  72289. private _size;
  72290. private _currentRefreshId;
  72291. private _refreshRate;
  72292. private _vertexBuffers;
  72293. private _indexBuffer;
  72294. private _uniforms;
  72295. private _samplers;
  72296. private _fragment;
  72297. private _floats;
  72298. private _ints;
  72299. private _floatsArrays;
  72300. private _colors3;
  72301. private _colors4;
  72302. private _vectors2;
  72303. private _vectors3;
  72304. private _matrices;
  72305. private _fallbackTexture;
  72306. private _fallbackTextureUsed;
  72307. private _engine;
  72308. private _cachedDefines;
  72309. private _contentUpdateId;
  72310. private _contentData;
  72311. /**
  72312. * Instantiates a new procedural texture.
  72313. * 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.
  72314. * This is the base class of any Procedural texture and contains most of the shareable code.
  72315. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  72316. * @param name Define the name of the texture
  72317. * @param size Define the size of the texture to create
  72318. * @param fragment Define the fragment shader to use to generate the texture or null if it is defined later
  72319. * @param scene Define the scene the texture belongs to
  72320. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  72321. * @param generateMipMaps Define if the texture should creates mip maps or not
  72322. * @param isCube Define if the texture is a cube texture or not (this will render each faces of the cube)
  72323. */
  72324. constructor(name: string, size: any, fragment: any, scene: Nullable<Scene>, fallbackTexture?: Nullable<Texture>, generateMipMaps?: boolean, isCube?: boolean);
  72325. /**
  72326. * The effect that is created when initializing the post process.
  72327. * @returns The created effect corrisponding the the postprocess.
  72328. */
  72329. getEffect(): Effect;
  72330. /**
  72331. * Gets texture content (Use this function wisely as reading from a texture can be slow)
  72332. * @returns an ArrayBufferView (Uint8Array or Float32Array)
  72333. */
  72334. getContent(): Nullable<ArrayBufferView>;
  72335. private _createIndexBuffer;
  72336. /** @hidden */
  72337. _rebuild(): void;
  72338. /**
  72339. * Resets the texture in order to recreate its associated resources.
  72340. * This can be called in case of context loss
  72341. */
  72342. reset(): void;
  72343. protected _getDefines(): string;
  72344. /**
  72345. * Is the texture ready to be used ? (rendered at least once)
  72346. * @returns true if ready, otherwise, false.
  72347. */
  72348. isReady(): boolean;
  72349. /**
  72350. * Resets the refresh counter of the texture and start bak from scratch.
  72351. * Could be useful to regenerate the texture if it is setup to render only once.
  72352. */
  72353. resetRefreshCounter(): void;
  72354. /**
  72355. * Set the fragment shader to use in order to render the texture.
  72356. * @param fragment This can be set to a path (into the shader store) or to a json object containing a fragmentElement property.
  72357. */
  72358. setFragment(fragment: any): void;
  72359. /**
  72360. * Define the refresh rate of the texture or the rendering frequency.
  72361. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  72362. */
  72363. refreshRate: number;
  72364. /** @hidden */
  72365. _shouldRender(): boolean;
  72366. /**
  72367. * Get the size the texture is rendering at.
  72368. * @returns the size (texture is always squared)
  72369. */
  72370. getRenderSize(): number;
  72371. /**
  72372. * Resize the texture to new value.
  72373. * @param size Define the new size the texture should have
  72374. * @param generateMipMaps Define whether the new texture should create mip maps
  72375. */
  72376. resize(size: number, generateMipMaps: boolean): void;
  72377. private _checkUniform;
  72378. /**
  72379. * Set a texture in the shader program used to render.
  72380. * @param name Define the name of the uniform samplers as defined in the shader
  72381. * @param texture Define the texture to bind to this sampler
  72382. * @return the texture itself allowing "fluent" like uniform updates
  72383. */
  72384. setTexture(name: string, texture: Texture): ProceduralTexture;
  72385. /**
  72386. * Set a float in the shader.
  72387. * @param name Define the name of the uniform as defined in the shader
  72388. * @param value Define the value to give to the uniform
  72389. * @return the texture itself allowing "fluent" like uniform updates
  72390. */
  72391. setFloat(name: string, value: number): ProceduralTexture;
  72392. /**
  72393. * Set a int in the shader.
  72394. * @param name Define the name of the uniform as defined in the shader
  72395. * @param value Define the value to give to the uniform
  72396. * @return the texture itself allowing "fluent" like uniform updates
  72397. */
  72398. setInt(name: string, value: number): ProceduralTexture;
  72399. /**
  72400. * Set an array of floats in the shader.
  72401. * @param name Define the name of the uniform as defined in the shader
  72402. * @param value Define the value to give to the uniform
  72403. * @return the texture itself allowing "fluent" like uniform updates
  72404. */
  72405. setFloats(name: string, value: number[]): ProceduralTexture;
  72406. /**
  72407. * Set a vec3 in the shader from a Color3.
  72408. * @param name Define the name of the uniform as defined in the shader
  72409. * @param value Define the value to give to the uniform
  72410. * @return the texture itself allowing "fluent" like uniform updates
  72411. */
  72412. setColor3(name: string, value: Color3): ProceduralTexture;
  72413. /**
  72414. * Set a vec4 in the shader from a Color4.
  72415. * @param name Define the name of the uniform as defined in the shader
  72416. * @param value Define the value to give to the uniform
  72417. * @return the texture itself allowing "fluent" like uniform updates
  72418. */
  72419. setColor4(name: string, value: Color4): ProceduralTexture;
  72420. /**
  72421. * Set a vec2 in the shader from a Vector2.
  72422. * @param name Define the name of the uniform as defined in the shader
  72423. * @param value Define the value to give to the uniform
  72424. * @return the texture itself allowing "fluent" like uniform updates
  72425. */
  72426. setVector2(name: string, value: Vector2): ProceduralTexture;
  72427. /**
  72428. * Set a vec3 in the shader from a Vector3.
  72429. * @param name Define the name of the uniform as defined in the shader
  72430. * @param value Define the value to give to the uniform
  72431. * @return the texture itself allowing "fluent" like uniform updates
  72432. */
  72433. setVector3(name: string, value: Vector3): ProceduralTexture;
  72434. /**
  72435. * Set a mat4 in the shader from a MAtrix.
  72436. * @param name Define the name of the uniform as defined in the shader
  72437. * @param value Define the value to give to the uniform
  72438. * @return the texture itself allowing "fluent" like uniform updates
  72439. */
  72440. setMatrix(name: string, value: Matrix): ProceduralTexture;
  72441. /**
  72442. * Render the texture to its associated render target.
  72443. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  72444. */
  72445. render(useCameraPostProcess?: boolean): void;
  72446. /**
  72447. * Clone the texture.
  72448. * @returns the cloned texture
  72449. */
  72450. clone(): ProceduralTexture;
  72451. /**
  72452. * Dispose the texture and release its asoociated resources.
  72453. */
  72454. dispose(): void;
  72455. }
  72456. }
  72457. declare module BABYLON {
  72458. /**
  72459. * This represents the base class for particle system in Babylon.
  72460. * 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.
  72461. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  72462. * @example https://doc.babylonjs.com/babylon101/particles
  72463. */
  72464. export class BaseParticleSystem {
  72465. /**
  72466. * Source color is added to the destination color without alpha affecting the result
  72467. */
  72468. static BLENDMODE_ONEONE: number;
  72469. /**
  72470. * Blend current color and particle color using particle’s alpha
  72471. */
  72472. static BLENDMODE_STANDARD: number;
  72473. /**
  72474. * Add current color and particle color multiplied by particle’s alpha
  72475. */
  72476. static BLENDMODE_ADD: number;
  72477. /**
  72478. * Multiply current color with particle color
  72479. */
  72480. static BLENDMODE_MULTIPLY: number;
  72481. /**
  72482. * Multiply current color with particle color then add current color and particle color multiplied by particle’s alpha
  72483. */
  72484. static BLENDMODE_MULTIPLYADD: number;
  72485. /**
  72486. * List of animations used by the particle system.
  72487. */
  72488. animations: Animation[];
  72489. /**
  72490. * The id of the Particle system.
  72491. */
  72492. id: string;
  72493. /**
  72494. * The friendly name of the Particle system.
  72495. */
  72496. name: string;
  72497. /**
  72498. * The rendering group used by the Particle system to chose when to render.
  72499. */
  72500. renderingGroupId: number;
  72501. /**
  72502. * The emitter represents the Mesh or position we are attaching the particle system to.
  72503. */
  72504. emitter: Nullable<AbstractMesh | Vector3>;
  72505. /**
  72506. * The maximum number of particles to emit per frame
  72507. */
  72508. emitRate: number;
  72509. /**
  72510. * If you want to launch only a few particles at once, that can be done, as well.
  72511. */
  72512. manualEmitCount: number;
  72513. /**
  72514. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  72515. */
  72516. updateSpeed: number;
  72517. /**
  72518. * The amount of time the particle system is running (depends of the overall update speed).
  72519. */
  72520. targetStopDuration: number;
  72521. /**
  72522. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  72523. */
  72524. disposeOnStop: boolean;
  72525. /**
  72526. * Minimum power of emitting particles.
  72527. */
  72528. minEmitPower: number;
  72529. /**
  72530. * Maximum power of emitting particles.
  72531. */
  72532. maxEmitPower: number;
  72533. /**
  72534. * Minimum life time of emitting particles.
  72535. */
  72536. minLifeTime: number;
  72537. /**
  72538. * Maximum life time of emitting particles.
  72539. */
  72540. maxLifeTime: number;
  72541. /**
  72542. * Minimum Size of emitting particles.
  72543. */
  72544. minSize: number;
  72545. /**
  72546. * Maximum Size of emitting particles.
  72547. */
  72548. maxSize: number;
  72549. /**
  72550. * Minimum scale of emitting particles on X axis.
  72551. */
  72552. minScaleX: number;
  72553. /**
  72554. * Maximum scale of emitting particles on X axis.
  72555. */
  72556. maxScaleX: number;
  72557. /**
  72558. * Minimum scale of emitting particles on Y axis.
  72559. */
  72560. minScaleY: number;
  72561. /**
  72562. * Maximum scale of emitting particles on Y axis.
  72563. */
  72564. maxScaleY: number;
  72565. /**
  72566. * Gets or sets the minimal initial rotation in radians.
  72567. */
  72568. minInitialRotation: number;
  72569. /**
  72570. * Gets or sets the maximal initial rotation in radians.
  72571. */
  72572. maxInitialRotation: number;
  72573. /**
  72574. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  72575. */
  72576. minAngularSpeed: number;
  72577. /**
  72578. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  72579. */
  72580. maxAngularSpeed: number;
  72581. /**
  72582. * The texture used to render each particle. (this can be a spritesheet)
  72583. */
  72584. particleTexture: Nullable<Texture>;
  72585. /**
  72586. * The layer mask we are rendering the particles through.
  72587. */
  72588. layerMask: number;
  72589. /**
  72590. * This can help using your own shader to render the particle system.
  72591. * The according effect will be created
  72592. */
  72593. customShader: any;
  72594. /**
  72595. * By default particle system starts as soon as they are created. This prevents the
  72596. * automatic start to happen and let you decide when to start emitting particles.
  72597. */
  72598. preventAutoStart: boolean;
  72599. private _noiseTexture;
  72600. /**
  72601. * Gets or sets a texture used to add random noise to particle positions
  72602. */
  72603. noiseTexture: Nullable<ProceduralTexture>;
  72604. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  72605. noiseStrength: Vector3;
  72606. /**
  72607. * Callback triggered when the particle animation is ending.
  72608. */
  72609. onAnimationEnd: Nullable<() => void>;
  72610. /**
  72611. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE or ParticleSystem.BLENDMODE_STANDARD.
  72612. */
  72613. blendMode: number;
  72614. /**
  72615. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  72616. * to override the particles.
  72617. */
  72618. forceDepthWrite: boolean;
  72619. /** 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 */
  72620. preWarmCycles: number;
  72621. /** Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1) */
  72622. preWarmStepOffset: number;
  72623. /**
  72624. * 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)
  72625. */
  72626. spriteCellChangeSpeed: number;
  72627. /**
  72628. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  72629. */
  72630. startSpriteCellID: number;
  72631. /**
  72632. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  72633. */
  72634. endSpriteCellID: number;
  72635. /**
  72636. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  72637. */
  72638. spriteCellWidth: number;
  72639. /**
  72640. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  72641. */
  72642. spriteCellHeight: number;
  72643. /**
  72644. * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID
  72645. */
  72646. spriteRandomStartCell: boolean;
  72647. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  72648. translationPivot: Vector2;
  72649. /** @hidden */
  72650. protected _isAnimationSheetEnabled: boolean;
  72651. /**
  72652. * Gets or sets a boolean indicating that hosted animations (in the system.animations array) must be started when system.start() is called
  72653. */
  72654. beginAnimationOnStart: boolean;
  72655. /**
  72656. * Gets or sets the frame to start the animation from when beginAnimationOnStart is true
  72657. */
  72658. beginAnimationFrom: number;
  72659. /**
  72660. * Gets or sets the frame to end the animation on when beginAnimationOnStart is true
  72661. */
  72662. beginAnimationTo: number;
  72663. /**
  72664. * Gets or sets a boolean indicating if animations must loop when beginAnimationOnStart is true
  72665. */
  72666. beginAnimationLoop: boolean;
  72667. /**
  72668. * Gets or sets a world offset applied to all particles
  72669. */
  72670. worldOffset: Vector3;
  72671. /**
  72672. * Gets or sets whether an animation sprite sheet is enabled or not on the particle system
  72673. */
  72674. isAnimationSheetEnabled: boolean;
  72675. /**
  72676. * Get hosting scene
  72677. * @returns the scene
  72678. */
  72679. getScene(): Scene;
  72680. /**
  72681. * You can use gravity if you want to give an orientation to your particles.
  72682. */
  72683. gravity: Vector3;
  72684. protected _colorGradients: Nullable<Array<ColorGradient>>;
  72685. protected _sizeGradients: Nullable<Array<FactorGradient>>;
  72686. protected _lifeTimeGradients: Nullable<Array<FactorGradient>>;
  72687. protected _angularSpeedGradients: Nullable<Array<FactorGradient>>;
  72688. protected _velocityGradients: Nullable<Array<FactorGradient>>;
  72689. protected _limitVelocityGradients: Nullable<Array<FactorGradient>>;
  72690. protected _dragGradients: Nullable<Array<FactorGradient>>;
  72691. protected _emitRateGradients: Nullable<Array<FactorGradient>>;
  72692. protected _startSizeGradients: Nullable<Array<FactorGradient>>;
  72693. protected _rampGradients: Nullable<Array<Color3Gradient>>;
  72694. protected _colorRemapGradients: Nullable<Array<FactorGradient>>;
  72695. protected _alphaRemapGradients: Nullable<Array<FactorGradient>>;
  72696. protected _hasTargetStopDurationDependantGradient(): boolean | null;
  72697. /**
  72698. * Defines the delay in milliseconds before starting the system (0 by default)
  72699. */
  72700. startDelay: number;
  72701. /**
  72702. * Gets the current list of drag gradients.
  72703. * You must use addDragGradient and removeDragGradient to udpate this list
  72704. * @returns the list of drag gradients
  72705. */
  72706. getDragGradients(): Nullable<Array<FactorGradient>>;
  72707. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  72708. limitVelocityDamping: number;
  72709. /**
  72710. * Gets the current list of limit velocity gradients.
  72711. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to udpate this list
  72712. * @returns the list of limit velocity gradients
  72713. */
  72714. getLimitVelocityGradients(): Nullable<Array<FactorGradient>>;
  72715. /**
  72716. * Gets the current list of color gradients.
  72717. * You must use addColorGradient and removeColorGradient to udpate this list
  72718. * @returns the list of color gradients
  72719. */
  72720. getColorGradients(): Nullable<Array<ColorGradient>>;
  72721. /**
  72722. * Gets the current list of size gradients.
  72723. * You must use addSizeGradient and removeSizeGradient to udpate this list
  72724. * @returns the list of size gradients
  72725. */
  72726. getSizeGradients(): Nullable<Array<FactorGradient>>;
  72727. /**
  72728. * Gets the current list of color remap gradients.
  72729. * You must use addColorRemapGradient and removeColorRemapGradient to udpate this list
  72730. * @returns the list of color remap gradients
  72731. */
  72732. getColorRemapGradients(): Nullable<Array<FactorGradient>>;
  72733. /**
  72734. * Gets the current list of alpha remap gradients.
  72735. * You must use addAlphaRemapGradient and removeAlphaRemapGradient to udpate this list
  72736. * @returns the list of alpha remap gradients
  72737. */
  72738. getAlphaRemapGradients(): Nullable<Array<FactorGradient>>;
  72739. /**
  72740. * Gets the current list of life time gradients.
  72741. * You must use addLifeTimeGradient and removeLifeTimeGradient to udpate this list
  72742. * @returns the list of life time gradients
  72743. */
  72744. getLifeTimeGradients(): Nullable<Array<FactorGradient>>;
  72745. /**
  72746. * Gets the current list of angular speed gradients.
  72747. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  72748. * @returns the list of angular speed gradients
  72749. */
  72750. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  72751. /**
  72752. * Gets the current list of velocity gradients.
  72753. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  72754. * @returns the list of velocity gradients
  72755. */
  72756. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  72757. /**
  72758. * Gets the current list of start size gradients.
  72759. * You must use addStartSizeGradient and removeStartSizeGradient to udpate this list
  72760. * @returns the list of start size gradients
  72761. */
  72762. getStartSizeGradients(): Nullable<Array<FactorGradient>>;
  72763. /**
  72764. * Gets the current list of emit rate gradients.
  72765. * You must use addEmitRateGradient and removeEmitRateGradient to udpate this list
  72766. * @returns the list of emit rate gradients
  72767. */
  72768. getEmitRateGradients(): Nullable<Array<FactorGradient>>;
  72769. /**
  72770. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  72771. * This only works when particleEmitterTyps is a BoxParticleEmitter
  72772. */
  72773. direction1: Vector3;
  72774. /**
  72775. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  72776. * This only works when particleEmitterTyps is a BoxParticleEmitter
  72777. */
  72778. direction2: Vector3;
  72779. /**
  72780. * 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.
  72781. * This only works when particleEmitterTyps is a BoxParticleEmitter
  72782. */
  72783. minEmitBox: Vector3;
  72784. /**
  72785. * 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.
  72786. * This only works when particleEmitterTyps is a BoxParticleEmitter
  72787. */
  72788. maxEmitBox: Vector3;
  72789. /**
  72790. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  72791. */
  72792. color1: Color4;
  72793. /**
  72794. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  72795. */
  72796. color2: Color4;
  72797. /**
  72798. * Color the particle will have at the end of its lifetime
  72799. */
  72800. colorDead: Color4;
  72801. /**
  72802. * An optional mask to filter some colors out of the texture, or filter a part of the alpha channel
  72803. */
  72804. textureMask: Color4;
  72805. /**
  72806. * The particle emitter type defines the emitter used by the particle system.
  72807. * It can be for example box, sphere, or cone...
  72808. */
  72809. particleEmitterType: IParticleEmitterType;
  72810. /** @hidden */
  72811. _isSubEmitter: boolean;
  72812. /**
  72813. * Gets or sets the billboard mode to use when isBillboardBased = true.
  72814. * Value can be: ParticleSystem.BILLBOARDMODE_ALL, ParticleSystem.BILLBOARDMODE_Y, ParticleSystem.BILLBOARDMODE_STRETCHED
  72815. */
  72816. billboardMode: number;
  72817. protected _isBillboardBased: boolean;
  72818. /**
  72819. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  72820. */
  72821. isBillboardBased: boolean;
  72822. /**
  72823. * The scene the particle system belongs to.
  72824. */
  72825. protected _scene: Scene;
  72826. /**
  72827. * Local cache of defines for image processing.
  72828. */
  72829. protected _imageProcessingConfigurationDefines: ImageProcessingConfigurationDefines;
  72830. /**
  72831. * Default configuration related to image processing available in the standard Material.
  72832. */
  72833. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  72834. /**
  72835. * Gets the image processing configuration used either in this material.
  72836. */
  72837. /**
  72838. * Sets the Default image processing configuration used either in the this material.
  72839. *
  72840. * If sets to null, the scene one is in use.
  72841. */
  72842. imageProcessingConfiguration: ImageProcessingConfiguration;
  72843. /**
  72844. * Attaches a new image processing configuration to the Standard Material.
  72845. * @param configuration
  72846. */
  72847. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  72848. /** @hidden */
  72849. protected _reset(): void;
  72850. /** @hidden */
  72851. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: Nullable<RawTexture>): BaseParticleSystem;
  72852. /**
  72853. * Instantiates a particle system.
  72854. * 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.
  72855. * @param name The name of the particle system
  72856. */
  72857. constructor(name: string);
  72858. /**
  72859. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  72860. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  72861. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  72862. * @returns the emitter
  72863. */
  72864. createPointEmitter(direction1: Vector3, direction2: Vector3): PointParticleEmitter;
  72865. /**
  72866. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  72867. * @param radius The radius of the hemisphere to emit from
  72868. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  72869. * @returns the emitter
  72870. */
  72871. createHemisphericEmitter(radius?: number, radiusRange?: number): HemisphericParticleEmitter;
  72872. /**
  72873. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  72874. * @param radius The radius of the sphere to emit from
  72875. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  72876. * @returns the emitter
  72877. */
  72878. createSphereEmitter(radius?: number, radiusRange?: number): SphereParticleEmitter;
  72879. /**
  72880. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  72881. * @param radius The radius of the sphere to emit from
  72882. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  72883. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  72884. * @returns the emitter
  72885. */
  72886. createDirectedSphereEmitter(radius?: number, direction1?: Vector3, direction2?: Vector3): SphereDirectedParticleEmitter;
  72887. /**
  72888. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  72889. * @param radius The radius of the emission cylinder
  72890. * @param height The height of the emission cylinder
  72891. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  72892. * @param directionRandomizer How much to randomize the particle direction [0-1]
  72893. * @returns the emitter
  72894. */
  72895. createCylinderEmitter(radius?: number, height?: number, radiusRange?: number, directionRandomizer?: number): CylinderParticleEmitter;
  72896. /**
  72897. * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)
  72898. * @param radius The radius of the cylinder to emit from
  72899. * @param height The height of the emission cylinder
  72900. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  72901. * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder
  72902. * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder
  72903. * @returns the emitter
  72904. */
  72905. createDirectedCylinderEmitter(radius?: number, height?: number, radiusRange?: number, direction1?: Vector3, direction2?: Vector3): CylinderDirectedParticleEmitter;
  72906. /**
  72907. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  72908. * @param radius The radius of the cone to emit from
  72909. * @param angle The base angle of the cone
  72910. * @returns the emitter
  72911. */
  72912. createConeEmitter(radius?: number, angle?: number): ConeParticleEmitter;
  72913. /**
  72914. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  72915. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  72916. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  72917. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  72918. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  72919. * @returns the emitter
  72920. */
  72921. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  72922. }
  72923. }
  72924. declare module BABYLON {
  72925. /**
  72926. * Type of sub emitter
  72927. */
  72928. export enum SubEmitterType {
  72929. /**
  72930. * Attached to the particle over it's lifetime
  72931. */
  72932. ATTACHED = 0,
  72933. /**
  72934. * Created when the particle dies
  72935. */
  72936. END = 1
  72937. }
  72938. /**
  72939. * Sub emitter class used to emit particles from an existing particle
  72940. */
  72941. export class SubEmitter {
  72942. /**
  72943. * the particle system to be used by the sub emitter
  72944. */
  72945. particleSystem: ParticleSystem;
  72946. /**
  72947. * Type of the submitter (Default: END)
  72948. */
  72949. type: SubEmitterType;
  72950. /**
  72951. * 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)
  72952. * Note: This only is supported when using an emitter of type Mesh
  72953. */
  72954. inheritDirection: boolean;
  72955. /**
  72956. * How much of the attached particles speed should be added to the sub emitted particle (default: 0)
  72957. */
  72958. inheritedVelocityAmount: number;
  72959. /**
  72960. * Creates a sub emitter
  72961. * @param particleSystem the particle system to be used by the sub emitter
  72962. */
  72963. constructor(
  72964. /**
  72965. * the particle system to be used by the sub emitter
  72966. */
  72967. particleSystem: ParticleSystem);
  72968. /**
  72969. * Clones the sub emitter
  72970. * @returns the cloned sub emitter
  72971. */
  72972. clone(): SubEmitter;
  72973. /**
  72974. * Serialize current object to a JSON object
  72975. * @returns the serialized object
  72976. */
  72977. serialize(): any;
  72978. /** @hidden */
  72979. static _ParseParticleSystem(system: any, scene: Scene, rootUrl: string): ParticleSystem;
  72980. /**
  72981. * Creates a new SubEmitter from a serialized JSON version
  72982. * @param serializationObject defines the JSON object to read from
  72983. * @param scene defines the hosting scene
  72984. * @param rootUrl defines the rootUrl for data loading
  72985. * @returns a new SubEmitter
  72986. */
  72987. static Parse(serializationObject: any, scene: Scene, rootUrl: string): SubEmitter;
  72988. /** Release associated resources */
  72989. dispose(): void;
  72990. }
  72991. }
  72992. declare module BABYLON {
  72993. /** @hidden */
  72994. export var clipPlaneFragmentDeclaration: {
  72995. name: string;
  72996. shader: string;
  72997. };
  72998. }
  72999. declare module BABYLON {
  73000. /** @hidden */
  73001. export var imageProcessingDeclaration: {
  73002. name: string;
  73003. shader: string;
  73004. };
  73005. }
  73006. declare module BABYLON {
  73007. /** @hidden */
  73008. export var imageProcessingFunctions: {
  73009. name: string;
  73010. shader: string;
  73011. };
  73012. }
  73013. declare module BABYLON {
  73014. /** @hidden */
  73015. export var clipPlaneFragment: {
  73016. name: string;
  73017. shader: string;
  73018. };
  73019. }
  73020. declare module BABYLON {
  73021. /** @hidden */
  73022. export var particlesPixelShader: {
  73023. name: string;
  73024. shader: string;
  73025. };
  73026. }
  73027. declare module BABYLON {
  73028. /** @hidden */
  73029. export var clipPlaneVertexDeclaration: {
  73030. name: string;
  73031. shader: string;
  73032. };
  73033. }
  73034. declare module BABYLON {
  73035. /** @hidden */
  73036. export var clipPlaneVertex: {
  73037. name: string;
  73038. shader: string;
  73039. };
  73040. }
  73041. declare module BABYLON {
  73042. /** @hidden */
  73043. export var particlesVertexShader: {
  73044. name: string;
  73045. shader: string;
  73046. };
  73047. }
  73048. declare module BABYLON {
  73049. /**
  73050. * This represents a particle system in Babylon.
  73051. * 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.
  73052. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  73053. * @example https://doc.babylonjs.com/babylon101/particles
  73054. */
  73055. export class ParticleSystem extends BaseParticleSystem implements IDisposable, IAnimatable, IParticleSystem {
  73056. /**
  73057. * Billboard mode will only apply to Y axis
  73058. */
  73059. static readonly BILLBOARDMODE_Y: number;
  73060. /**
  73061. * Billboard mode will apply to all axes
  73062. */
  73063. static readonly BILLBOARDMODE_ALL: number;
  73064. /**
  73065. * Special billboard mode where the particle will be biilboard to the camera but rotated to align with direction
  73066. */
  73067. static readonly BILLBOARDMODE_STRETCHED: number;
  73068. /**
  73069. * This function can be defined to provide custom update for active particles.
  73070. * This function will be called instead of regular update (age, position, color, etc.).
  73071. * Do not forget that this function will be called on every frame so try to keep it simple and fast :)
  73072. */
  73073. updateFunction: (particles: Particle[]) => void;
  73074. private _emitterWorldMatrix;
  73075. /**
  73076. * This function can be defined to specify initial direction for every new particle.
  73077. * It by default use the emitterType defined function
  73078. */
  73079. startDirectionFunction: (worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle) => void;
  73080. /**
  73081. * This function can be defined to specify initial position for every new particle.
  73082. * It by default use the emitterType defined function
  73083. */
  73084. startPositionFunction: (worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle) => void;
  73085. /**
  73086. * @hidden
  73087. */
  73088. _inheritedVelocityOffset: Vector3;
  73089. /**
  73090. * An event triggered when the system is disposed
  73091. */
  73092. onDisposeObservable: Observable<ParticleSystem>;
  73093. private _onDisposeObserver;
  73094. /**
  73095. * Sets a callback that will be triggered when the system is disposed
  73096. */
  73097. onDispose: () => void;
  73098. private _particles;
  73099. private _epsilon;
  73100. private _capacity;
  73101. private _stockParticles;
  73102. private _newPartsExcess;
  73103. private _vertexData;
  73104. private _vertexBuffer;
  73105. private _vertexBuffers;
  73106. private _spriteBuffer;
  73107. private _indexBuffer;
  73108. private _effect;
  73109. private _customEffect;
  73110. private _cachedDefines;
  73111. private _scaledColorStep;
  73112. private _colorDiff;
  73113. private _scaledDirection;
  73114. private _scaledGravity;
  73115. private _currentRenderId;
  73116. private _alive;
  73117. private _useInstancing;
  73118. private _started;
  73119. private _stopped;
  73120. private _actualFrame;
  73121. private _scaledUpdateSpeed;
  73122. private _vertexBufferSize;
  73123. /** @hidden */
  73124. _currentEmitRateGradient: Nullable<FactorGradient>;
  73125. /** @hidden */
  73126. _currentEmitRate1: number;
  73127. /** @hidden */
  73128. _currentEmitRate2: number;
  73129. /** @hidden */
  73130. _currentStartSizeGradient: Nullable<FactorGradient>;
  73131. /** @hidden */
  73132. _currentStartSize1: number;
  73133. /** @hidden */
  73134. _currentStartSize2: number;
  73135. private readonly _rawTextureWidth;
  73136. private _rampGradientsTexture;
  73137. private _useRampGradients;
  73138. /** Gets or sets a boolean indicating that ramp gradients must be used
  73139. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  73140. */
  73141. useRampGradients: boolean;
  73142. /**
  73143. * 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.
  73144. * 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: [])
  73145. */
  73146. subEmitters: Array<ParticleSystem | SubEmitter | Array<SubEmitter>>;
  73147. private _subEmitters;
  73148. /**
  73149. * @hidden
  73150. * If the particle systems emitter should be disposed when the particle system is disposed
  73151. */
  73152. _disposeEmitterOnDispose: boolean;
  73153. /**
  73154. * The current active Sub-systems, this property is used by the root particle system only.
  73155. */
  73156. activeSubSystems: Array<ParticleSystem>;
  73157. private _rootParticleSystem;
  73158. /**
  73159. * Gets the current list of active particles
  73160. */
  73161. readonly particles: Particle[];
  73162. /**
  73163. * Returns the string "ParticleSystem"
  73164. * @returns a string containing the class name
  73165. */
  73166. getClassName(): string;
  73167. /**
  73168. * Instantiates a particle system.
  73169. * 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.
  73170. * @param name The name of the particle system
  73171. * @param capacity The max number of particles alive at the same time
  73172. * @param scene The scene the particle system belongs to
  73173. * @param customEffect a custom effect used to change the way particles are rendered by default
  73174. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  73175. * @param epsilon Offset used to render the particles
  73176. */
  73177. constructor(name: string, capacity: number, scene: Scene, customEffect?: Nullable<Effect>, isAnimationSheetEnabled?: boolean, epsilon?: number);
  73178. private _addFactorGradient;
  73179. private _removeFactorGradient;
  73180. /**
  73181. * Adds a new life time gradient
  73182. * @param gradient defines the gradient to use (between 0 and 1)
  73183. * @param factor defines the life time factor to affect to the specified gradient
  73184. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  73185. * @returns the current particle system
  73186. */
  73187. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  73188. /**
  73189. * Remove a specific life time gradient
  73190. * @param gradient defines the gradient to remove
  73191. * @returns the current particle system
  73192. */
  73193. removeLifeTimeGradient(gradient: number): IParticleSystem;
  73194. /**
  73195. * Adds a new size gradient
  73196. * @param gradient defines the gradient to use (between 0 and 1)
  73197. * @param factor defines the size factor to affect to the specified gradient
  73198. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  73199. * @returns the current particle system
  73200. */
  73201. addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  73202. /**
  73203. * Remove a specific size gradient
  73204. * @param gradient defines the gradient to remove
  73205. * @returns the current particle system
  73206. */
  73207. removeSizeGradient(gradient: number): IParticleSystem;
  73208. /**
  73209. * Adds a new color remap gradient
  73210. * @param gradient defines the gradient to use (between 0 and 1)
  73211. * @param min defines the color remap minimal range
  73212. * @param max defines the color remap maximal range
  73213. * @returns the current particle system
  73214. */
  73215. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  73216. /**
  73217. * Remove a specific color remap gradient
  73218. * @param gradient defines the gradient to remove
  73219. * @returns the current particle system
  73220. */
  73221. removeColorRemapGradient(gradient: number): IParticleSystem;
  73222. /**
  73223. * Adds a new alpha remap gradient
  73224. * @param gradient defines the gradient to use (between 0 and 1)
  73225. * @param min defines the alpha remap minimal range
  73226. * @param max defines the alpha remap maximal range
  73227. * @returns the current particle system
  73228. */
  73229. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  73230. /**
  73231. * Remove a specific alpha remap gradient
  73232. * @param gradient defines the gradient to remove
  73233. * @returns the current particle system
  73234. */
  73235. removeAlphaRemapGradient(gradient: number): IParticleSystem;
  73236. /**
  73237. * Adds a new angular speed gradient
  73238. * @param gradient defines the gradient to use (between 0 and 1)
  73239. * @param factor defines the angular speed to affect to the specified gradient
  73240. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  73241. * @returns the current particle system
  73242. */
  73243. addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  73244. /**
  73245. * Remove a specific angular speed gradient
  73246. * @param gradient defines the gradient to remove
  73247. * @returns the current particle system
  73248. */
  73249. removeAngularSpeedGradient(gradient: number): IParticleSystem;
  73250. /**
  73251. * Adds a new velocity gradient
  73252. * @param gradient defines the gradient to use (between 0 and 1)
  73253. * @param factor defines the velocity to affect to the specified gradient
  73254. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  73255. * @returns the current particle system
  73256. */
  73257. addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  73258. /**
  73259. * Remove a specific velocity gradient
  73260. * @param gradient defines the gradient to remove
  73261. * @returns the current particle system
  73262. */
  73263. removeVelocityGradient(gradient: number): IParticleSystem;
  73264. /**
  73265. * Adds a new limit velocity gradient
  73266. * @param gradient defines the gradient to use (between 0 and 1)
  73267. * @param factor defines the limit velocity value to affect to the specified gradient
  73268. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  73269. * @returns the current particle system
  73270. */
  73271. addLimitVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  73272. /**
  73273. * Remove a specific limit velocity gradient
  73274. * @param gradient defines the gradient to remove
  73275. * @returns the current particle system
  73276. */
  73277. removeLimitVelocityGradient(gradient: number): IParticleSystem;
  73278. /**
  73279. * Adds a new drag gradient
  73280. * @param gradient defines the gradient to use (between 0 and 1)
  73281. * @param factor defines the drag value to affect to the specified gradient
  73282. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  73283. * @returns the current particle system
  73284. */
  73285. addDragGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  73286. /**
  73287. * Remove a specific drag gradient
  73288. * @param gradient defines the gradient to remove
  73289. * @returns the current particle system
  73290. */
  73291. removeDragGradient(gradient: number): IParticleSystem;
  73292. /**
  73293. * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
  73294. * @param gradient defines the gradient to use (between 0 and 1)
  73295. * @param factor defines the emit rate value to affect to the specified gradient
  73296. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  73297. * @returns the current particle system
  73298. */
  73299. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  73300. /**
  73301. * Remove a specific emit rate gradient
  73302. * @param gradient defines the gradient to remove
  73303. * @returns the current particle system
  73304. */
  73305. removeEmitRateGradient(gradient: number): IParticleSystem;
  73306. /**
  73307. * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property)
  73308. * @param gradient defines the gradient to use (between 0 and 1)
  73309. * @param factor defines the start size value to affect to the specified gradient
  73310. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  73311. * @returns the current particle system
  73312. */
  73313. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  73314. /**
  73315. * Remove a specific start size gradient
  73316. * @param gradient defines the gradient to remove
  73317. * @returns the current particle system
  73318. */
  73319. removeStartSizeGradient(gradient: number): IParticleSystem;
  73320. private _createRampGradientTexture;
  73321. /**
  73322. * Gets the current list of ramp gradients.
  73323. * You must use addRampGradient and removeRampGradient to udpate this list
  73324. * @returns the list of ramp gradients
  73325. */
  73326. getRampGradients(): Nullable<Array<Color3Gradient>>;
  73327. /**
  73328. * Adds a new ramp gradient used to remap particle colors
  73329. * @param gradient defines the gradient to use (between 0 and 1)
  73330. * @param color defines the color to affect to the specified gradient
  73331. * @returns the current particle system
  73332. */
  73333. addRampGradient(gradient: number, color: Color3): ParticleSystem;
  73334. /**
  73335. * Remove a specific ramp gradient
  73336. * @param gradient defines the gradient to remove
  73337. * @returns the current particle system
  73338. */
  73339. removeRampGradient(gradient: number): ParticleSystem;
  73340. /**
  73341. * Adds a new color gradient
  73342. * @param gradient defines the gradient to use (between 0 and 1)
  73343. * @param color1 defines the color to affect to the specified gradient
  73344. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  73345. * @returns this particle system
  73346. */
  73347. addColorGradient(gradient: number, color1: Color4, color2?: Color4): IParticleSystem;
  73348. /**
  73349. * Remove a specific color gradient
  73350. * @param gradient defines the gradient to remove
  73351. * @returns this particle system
  73352. */
  73353. removeColorGradient(gradient: number): IParticleSystem;
  73354. private _fetchR;
  73355. protected _reset(): void;
  73356. private _resetEffect;
  73357. private _createVertexBuffers;
  73358. private _createIndexBuffer;
  73359. /**
  73360. * Gets the maximum number of particles active at the same time.
  73361. * @returns The max number of active particles.
  73362. */
  73363. getCapacity(): number;
  73364. /**
  73365. * Gets whether there are still active particles in the system.
  73366. * @returns True if it is alive, otherwise false.
  73367. */
  73368. isAlive(): boolean;
  73369. /**
  73370. * Gets if the system has been started. (Note: this will still be true after stop is called)
  73371. * @returns True if it has been started, otherwise false.
  73372. */
  73373. isStarted(): boolean;
  73374. private _prepareSubEmitterInternalArray;
  73375. /**
  73376. * Starts the particle system and begins to emit
  73377. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  73378. */
  73379. start(delay?: number): void;
  73380. /**
  73381. * Stops the particle system.
  73382. * @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.
  73383. */
  73384. stop(stopSubEmitters?: boolean): void;
  73385. /**
  73386. * Remove all active particles
  73387. */
  73388. reset(): void;
  73389. /**
  73390. * @hidden (for internal use only)
  73391. */
  73392. _appendParticleVertex(index: number, particle: Particle, offsetX: number, offsetY: number): void;
  73393. /**
  73394. * "Recycles" one of the particle by copying it back to the "stock" of particles and removing it from the active list.
  73395. * Its lifetime will start back at 0.
  73396. */
  73397. recycleParticle: (particle: Particle) => void;
  73398. private _stopSubEmitters;
  73399. private _createParticle;
  73400. private _removeFromRoot;
  73401. private _emitFromParticle;
  73402. private _update;
  73403. /** @hidden */
  73404. static _GetAttributeNamesOrOptions(isAnimationSheetEnabled?: boolean, isBillboardBased?: boolean, useRampGradients?: boolean): string[];
  73405. /** @hidden */
  73406. static _GetEffectCreationOptions(isAnimationSheetEnabled?: boolean): string[];
  73407. /** @hidden */
  73408. private _getEffect;
  73409. /**
  73410. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  73411. * @param preWarmOnly will prevent the system from updating the vertex buffer (default is false)
  73412. */
  73413. animate(preWarmOnly?: boolean): void;
  73414. private _appendParticleVertices;
  73415. /**
  73416. * Rebuilds the particle system.
  73417. */
  73418. rebuild(): void;
  73419. /**
  73420. * Is this system ready to be used/rendered
  73421. * @return true if the system is ready
  73422. */
  73423. isReady(): boolean;
  73424. private _render;
  73425. /**
  73426. * Renders the particle system in its current state.
  73427. * @returns the current number of particles
  73428. */
  73429. render(): number;
  73430. /**
  73431. * Disposes the particle system and free the associated resources
  73432. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  73433. */
  73434. dispose(disposeTexture?: boolean): void;
  73435. /**
  73436. * Clones the particle system.
  73437. * @param name The name of the cloned object
  73438. * @param newEmitter The new emitter to use
  73439. * @returns the cloned particle system
  73440. */
  73441. clone(name: string, newEmitter: any): ParticleSystem;
  73442. /**
  73443. * Serializes the particle system to a JSON object.
  73444. * @returns the JSON object
  73445. */
  73446. serialize(): any;
  73447. /** @hidden */
  73448. static _Serialize(serializationObject: any, particleSystem: IParticleSystem): void;
  73449. /** @hidden */
  73450. static _Parse(parsedParticleSystem: any, particleSystem: IParticleSystem, scene: Scene, rootUrl: string): void;
  73451. /**
  73452. * Parses a JSON object to create a particle system.
  73453. * @param parsedParticleSystem The JSON object to parse
  73454. * @param scene The scene to create the particle system in
  73455. * @param rootUrl The root url to use to load external dependencies like texture
  73456. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  73457. * @returns the Parsed particle system
  73458. */
  73459. static Parse(parsedParticleSystem: any, scene: Scene, rootUrl: string, doNotStart?: boolean): ParticleSystem;
  73460. }
  73461. }
  73462. declare module BABYLON {
  73463. /**
  73464. * A particle represents one of the element emitted by a particle system.
  73465. * This is mainly define by its coordinates, direction, velocity and age.
  73466. */
  73467. export class Particle {
  73468. /**
  73469. * The particle system the particle belongs to.
  73470. */
  73471. particleSystem: ParticleSystem;
  73472. private static _Count;
  73473. /**
  73474. * Unique ID of the particle
  73475. */
  73476. id: number;
  73477. /**
  73478. * The world position of the particle in the scene.
  73479. */
  73480. position: Vector3;
  73481. /**
  73482. * The world direction of the particle in the scene.
  73483. */
  73484. direction: Vector3;
  73485. /**
  73486. * The color of the particle.
  73487. */
  73488. color: Color4;
  73489. /**
  73490. * The color change of the particle per step.
  73491. */
  73492. colorStep: Color4;
  73493. /**
  73494. * Defines how long will the life of the particle be.
  73495. */
  73496. lifeTime: number;
  73497. /**
  73498. * The current age of the particle.
  73499. */
  73500. age: number;
  73501. /**
  73502. * The current size of the particle.
  73503. */
  73504. size: number;
  73505. /**
  73506. * The current scale of the particle.
  73507. */
  73508. scale: Vector2;
  73509. /**
  73510. * The current angle of the particle.
  73511. */
  73512. angle: number;
  73513. /**
  73514. * Defines how fast is the angle changing.
  73515. */
  73516. angularSpeed: number;
  73517. /**
  73518. * Defines the cell index used by the particle to be rendered from a sprite.
  73519. */
  73520. cellIndex: number;
  73521. /**
  73522. * The information required to support color remapping
  73523. */
  73524. remapData: Vector4;
  73525. /** @hidden */
  73526. _randomCellOffset?: number;
  73527. /** @hidden */
  73528. _initialDirection: Nullable<Vector3>;
  73529. /** @hidden */
  73530. _attachedSubEmitters: Nullable<Array<SubEmitter>>;
  73531. /** @hidden */
  73532. _initialStartSpriteCellID: number;
  73533. /** @hidden */
  73534. _initialEndSpriteCellID: number;
  73535. /** @hidden */
  73536. _currentColorGradient: Nullable<ColorGradient>;
  73537. /** @hidden */
  73538. _currentColor1: Color4;
  73539. /** @hidden */
  73540. _currentColor2: Color4;
  73541. /** @hidden */
  73542. _currentSizeGradient: Nullable<FactorGradient>;
  73543. /** @hidden */
  73544. _currentSize1: number;
  73545. /** @hidden */
  73546. _currentSize2: number;
  73547. /** @hidden */
  73548. _currentAngularSpeedGradient: Nullable<FactorGradient>;
  73549. /** @hidden */
  73550. _currentAngularSpeed1: number;
  73551. /** @hidden */
  73552. _currentAngularSpeed2: number;
  73553. /** @hidden */
  73554. _currentVelocityGradient: Nullable<FactorGradient>;
  73555. /** @hidden */
  73556. _currentVelocity1: number;
  73557. /** @hidden */
  73558. _currentVelocity2: number;
  73559. /** @hidden */
  73560. _currentLimitVelocityGradient: Nullable<FactorGradient>;
  73561. /** @hidden */
  73562. _currentLimitVelocity1: number;
  73563. /** @hidden */
  73564. _currentLimitVelocity2: number;
  73565. /** @hidden */
  73566. _currentDragGradient: Nullable<FactorGradient>;
  73567. /** @hidden */
  73568. _currentDrag1: number;
  73569. /** @hidden */
  73570. _currentDrag2: number;
  73571. /** @hidden */
  73572. _randomNoiseCoordinates1: Vector3;
  73573. /** @hidden */
  73574. _randomNoiseCoordinates2: Vector3;
  73575. /**
  73576. * Creates a new instance Particle
  73577. * @param particleSystem the particle system the particle belongs to
  73578. */
  73579. constructor(
  73580. /**
  73581. * The particle system the particle belongs to.
  73582. */
  73583. particleSystem: ParticleSystem);
  73584. private updateCellInfoFromSystem;
  73585. /**
  73586. * Defines how the sprite cell index is updated for the particle
  73587. */
  73588. updateCellIndex(): void;
  73589. /** @hidden */
  73590. _inheritParticleInfoToSubEmitter(subEmitter: SubEmitter): void;
  73591. /** @hidden */
  73592. _inheritParticleInfoToSubEmitters(): void;
  73593. /** @hidden */
  73594. _reset(): void;
  73595. /**
  73596. * Copy the properties of particle to another one.
  73597. * @param other the particle to copy the information to.
  73598. */
  73599. copyTo(other: Particle): void;
  73600. }
  73601. }
  73602. declare module BABYLON {
  73603. /**
  73604. * Particle emitter represents a volume emitting particles.
  73605. * This is the responsibility of the implementation to define the volume shape like cone/sphere/box.
  73606. */
  73607. export interface IParticleEmitterType {
  73608. /**
  73609. * Called by the particle System when the direction is computed for the created particle.
  73610. * @param worldMatrix is the world matrix of the particle system
  73611. * @param directionToUpdate is the direction vector to update with the result
  73612. * @param particle is the particle we are computed the direction for
  73613. */
  73614. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  73615. /**
  73616. * Called by the particle System when the position is computed for the created particle.
  73617. * @param worldMatrix is the world matrix of the particle system
  73618. * @param positionToUpdate is the position vector to update with the result
  73619. * @param particle is the particle we are computed the position for
  73620. */
  73621. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  73622. /**
  73623. * Clones the current emitter and returns a copy of it
  73624. * @returns the new emitter
  73625. */
  73626. clone(): IParticleEmitterType;
  73627. /**
  73628. * Called by the GPUParticleSystem to setup the update shader
  73629. * @param effect defines the update shader
  73630. */
  73631. applyToShader(effect: Effect): void;
  73632. /**
  73633. * Returns a string to use to update the GPU particles update shader
  73634. * @returns the effect defines string
  73635. */
  73636. getEffectDefines(): string;
  73637. /**
  73638. * Returns a string representing the class name
  73639. * @returns a string containing the class name
  73640. */
  73641. getClassName(): string;
  73642. /**
  73643. * Serializes the particle system to a JSON object.
  73644. * @returns the JSON object
  73645. */
  73646. serialize(): any;
  73647. /**
  73648. * Parse properties from a JSON object
  73649. * @param serializationObject defines the JSON object
  73650. */
  73651. parse(serializationObject: any): void;
  73652. }
  73653. }
  73654. declare module BABYLON {
  73655. /**
  73656. * Particle emitter emitting particles from the inside of a box.
  73657. * It emits the particles randomly between 2 given directions.
  73658. */
  73659. export class BoxParticleEmitter implements IParticleEmitterType {
  73660. /**
  73661. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  73662. */
  73663. direction1: Vector3;
  73664. /**
  73665. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  73666. */
  73667. direction2: Vector3;
  73668. /**
  73669. * 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.
  73670. */
  73671. minEmitBox: Vector3;
  73672. /**
  73673. * 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.
  73674. */
  73675. maxEmitBox: Vector3;
  73676. /**
  73677. * Creates a new instance BoxParticleEmitter
  73678. */
  73679. constructor();
  73680. /**
  73681. * Called by the particle System when the direction is computed for the created particle.
  73682. * @param worldMatrix is the world matrix of the particle system
  73683. * @param directionToUpdate is the direction vector to update with the result
  73684. * @param particle is the particle we are computed the direction for
  73685. */
  73686. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  73687. /**
  73688. * Called by the particle System when the position is computed for the created particle.
  73689. * @param worldMatrix is the world matrix of the particle system
  73690. * @param positionToUpdate is the position vector to update with the result
  73691. * @param particle is the particle we are computed the position for
  73692. */
  73693. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  73694. /**
  73695. * Clones the current emitter and returns a copy of it
  73696. * @returns the new emitter
  73697. */
  73698. clone(): BoxParticleEmitter;
  73699. /**
  73700. * Called by the GPUParticleSystem to setup the update shader
  73701. * @param effect defines the update shader
  73702. */
  73703. applyToShader(effect: Effect): void;
  73704. /**
  73705. * Returns a string to use to update the GPU particles update shader
  73706. * @returns a string containng the defines string
  73707. */
  73708. getEffectDefines(): string;
  73709. /**
  73710. * Returns the string "BoxParticleEmitter"
  73711. * @returns a string containing the class name
  73712. */
  73713. getClassName(): string;
  73714. /**
  73715. * Serializes the particle system to a JSON object.
  73716. * @returns the JSON object
  73717. */
  73718. serialize(): any;
  73719. /**
  73720. * Parse properties from a JSON object
  73721. * @param serializationObject defines the JSON object
  73722. */
  73723. parse(serializationObject: any): void;
  73724. }
  73725. }
  73726. declare module BABYLON {
  73727. /**
  73728. * Particle emitter emitting particles from the inside of a cone.
  73729. * It emits the particles alongside the cone volume from the base to the particle.
  73730. * The emission direction might be randomized.
  73731. */
  73732. export class ConeParticleEmitter implements IParticleEmitterType {
  73733. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  73734. directionRandomizer: number;
  73735. private _radius;
  73736. private _angle;
  73737. private _height;
  73738. /**
  73739. * Gets or sets a value indicating where on the radius the start position should be picked (1 = everywhere, 0 = only surface)
  73740. */
  73741. radiusRange: number;
  73742. /**
  73743. * Gets or sets a value indicating where on the height the start position should be picked (1 = everywhere, 0 = only surface)
  73744. */
  73745. heightRange: number;
  73746. /**
  73747. * Gets or sets a value indicating if all the particles should be emitted from the spawn point only (the base of the cone)
  73748. */
  73749. emitFromSpawnPointOnly: boolean;
  73750. /**
  73751. * Gets or sets the radius of the emission cone
  73752. */
  73753. radius: number;
  73754. /**
  73755. * Gets or sets the angle of the emission cone
  73756. */
  73757. angle: number;
  73758. private _buildHeight;
  73759. /**
  73760. * Creates a new instance ConeParticleEmitter
  73761. * @param radius the radius of the emission cone (1 by default)
  73762. * @param angle the cone base angle (PI by default)
  73763. * @param directionRandomizer defines how much to randomize the particle direction [0-1] (default is 0)
  73764. */
  73765. constructor(radius?: number, angle?: number,
  73766. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  73767. directionRandomizer?: number);
  73768. /**
  73769. * Called by the particle System when the direction is computed for the created particle.
  73770. * @param worldMatrix is the world matrix of the particle system
  73771. * @param directionToUpdate is the direction vector to update with the result
  73772. * @param particle is the particle we are computed the direction for
  73773. */
  73774. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  73775. /**
  73776. * Called by the particle System when the position is computed for the created particle.
  73777. * @param worldMatrix is the world matrix of the particle system
  73778. * @param positionToUpdate is the position vector to update with the result
  73779. * @param particle is the particle we are computed the position for
  73780. */
  73781. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  73782. /**
  73783. * Clones the current emitter and returns a copy of it
  73784. * @returns the new emitter
  73785. */
  73786. clone(): ConeParticleEmitter;
  73787. /**
  73788. * Called by the GPUParticleSystem to setup the update shader
  73789. * @param effect defines the update shader
  73790. */
  73791. applyToShader(effect: Effect): void;
  73792. /**
  73793. * Returns a string to use to update the GPU particles update shader
  73794. * @returns a string containng the defines string
  73795. */
  73796. getEffectDefines(): string;
  73797. /**
  73798. * Returns the string "ConeParticleEmitter"
  73799. * @returns a string containing the class name
  73800. */
  73801. getClassName(): string;
  73802. /**
  73803. * Serializes the particle system to a JSON object.
  73804. * @returns the JSON object
  73805. */
  73806. serialize(): any;
  73807. /**
  73808. * Parse properties from a JSON object
  73809. * @param serializationObject defines the JSON object
  73810. */
  73811. parse(serializationObject: any): void;
  73812. }
  73813. }
  73814. declare module BABYLON {
  73815. /**
  73816. * Particle emitter emitting particles from the inside of a cylinder.
  73817. * It emits the particles alongside the cylinder radius. The emission direction might be randomized.
  73818. */
  73819. export class CylinderParticleEmitter implements IParticleEmitterType {
  73820. /**
  73821. * The radius of the emission cylinder.
  73822. */
  73823. radius: number;
  73824. /**
  73825. * The height of the emission cylinder.
  73826. */
  73827. height: number;
  73828. /**
  73829. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  73830. */
  73831. radiusRange: number;
  73832. /**
  73833. * How much to randomize the particle direction [0-1].
  73834. */
  73835. directionRandomizer: number;
  73836. /**
  73837. * Creates a new instance CylinderParticleEmitter
  73838. * @param radius the radius of the emission cylinder (1 by default)
  73839. * @param height the height of the emission cylinder (1 by default)
  73840. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  73841. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  73842. */
  73843. constructor(
  73844. /**
  73845. * The radius of the emission cylinder.
  73846. */
  73847. radius?: number,
  73848. /**
  73849. * The height of the emission cylinder.
  73850. */
  73851. height?: number,
  73852. /**
  73853. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  73854. */
  73855. radiusRange?: number,
  73856. /**
  73857. * How much to randomize the particle direction [0-1].
  73858. */
  73859. directionRandomizer?: number);
  73860. /**
  73861. * Called by the particle System when the direction is computed for the created particle.
  73862. * @param worldMatrix is the world matrix of the particle system
  73863. * @param directionToUpdate is the direction vector to update with the result
  73864. * @param particle is the particle we are computed the direction for
  73865. */
  73866. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  73867. /**
  73868. * Called by the particle System when the position is computed for the created particle.
  73869. * @param worldMatrix is the world matrix of the particle system
  73870. * @param positionToUpdate is the position vector to update with the result
  73871. * @param particle is the particle we are computed the position for
  73872. */
  73873. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  73874. /**
  73875. * Clones the current emitter and returns a copy of it
  73876. * @returns the new emitter
  73877. */
  73878. clone(): CylinderParticleEmitter;
  73879. /**
  73880. * Called by the GPUParticleSystem to setup the update shader
  73881. * @param effect defines the update shader
  73882. */
  73883. applyToShader(effect: Effect): void;
  73884. /**
  73885. * Returns a string to use to update the GPU particles update shader
  73886. * @returns a string containng the defines string
  73887. */
  73888. getEffectDefines(): string;
  73889. /**
  73890. * Returns the string "CylinderParticleEmitter"
  73891. * @returns a string containing the class name
  73892. */
  73893. getClassName(): string;
  73894. /**
  73895. * Serializes the particle system to a JSON object.
  73896. * @returns the JSON object
  73897. */
  73898. serialize(): any;
  73899. /**
  73900. * Parse properties from a JSON object
  73901. * @param serializationObject defines the JSON object
  73902. */
  73903. parse(serializationObject: any): void;
  73904. }
  73905. /**
  73906. * Particle emitter emitting particles from the inside of a cylinder.
  73907. * It emits the particles randomly between two vectors.
  73908. */
  73909. export class CylinderDirectedParticleEmitter extends CylinderParticleEmitter {
  73910. /**
  73911. * The min limit of the emission direction.
  73912. */
  73913. direction1: Vector3;
  73914. /**
  73915. * The max limit of the emission direction.
  73916. */
  73917. direction2: Vector3;
  73918. /**
  73919. * Creates a new instance CylinderDirectedParticleEmitter
  73920. * @param radius the radius of the emission cylinder (1 by default)
  73921. * @param height the height of the emission cylinder (1 by default)
  73922. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  73923. * @param direction1 the min limit of the emission direction (up vector by default)
  73924. * @param direction2 the max limit of the emission direction (up vector by default)
  73925. */
  73926. constructor(radius?: number, height?: number, radiusRange?: number,
  73927. /**
  73928. * The min limit of the emission direction.
  73929. */
  73930. direction1?: Vector3,
  73931. /**
  73932. * The max limit of the emission direction.
  73933. */
  73934. direction2?: Vector3);
  73935. /**
  73936. * Called by the particle System when the direction is computed for the created particle.
  73937. * @param worldMatrix is the world matrix of the particle system
  73938. * @param directionToUpdate is the direction vector to update with the result
  73939. * @param particle is the particle we are computed the direction for
  73940. */
  73941. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  73942. /**
  73943. * Clones the current emitter and returns a copy of it
  73944. * @returns the new emitter
  73945. */
  73946. clone(): CylinderDirectedParticleEmitter;
  73947. /**
  73948. * Called by the GPUParticleSystem to setup the update shader
  73949. * @param effect defines the update shader
  73950. */
  73951. applyToShader(effect: Effect): void;
  73952. /**
  73953. * Returns a string to use to update the GPU particles update shader
  73954. * @returns a string containng the defines string
  73955. */
  73956. getEffectDefines(): string;
  73957. /**
  73958. * Returns the string "CylinderDirectedParticleEmitter"
  73959. * @returns a string containing the class name
  73960. */
  73961. getClassName(): string;
  73962. /**
  73963. * Serializes the particle system to a JSON object.
  73964. * @returns the JSON object
  73965. */
  73966. serialize(): any;
  73967. /**
  73968. * Parse properties from a JSON object
  73969. * @param serializationObject defines the JSON object
  73970. */
  73971. parse(serializationObject: any): void;
  73972. }
  73973. }
  73974. declare module BABYLON {
  73975. /**
  73976. * Particle emitter emitting particles from the inside of a hemisphere.
  73977. * It emits the particles alongside the hemisphere radius. The emission direction might be randomized.
  73978. */
  73979. export class HemisphericParticleEmitter implements IParticleEmitterType {
  73980. /**
  73981. * The radius of the emission hemisphere.
  73982. */
  73983. radius: number;
  73984. /**
  73985. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  73986. */
  73987. radiusRange: number;
  73988. /**
  73989. * How much to randomize the particle direction [0-1].
  73990. */
  73991. directionRandomizer: number;
  73992. /**
  73993. * Creates a new instance HemisphericParticleEmitter
  73994. * @param radius the radius of the emission hemisphere (1 by default)
  73995. * @param radiusRange the range of the emission hemisphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  73996. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  73997. */
  73998. constructor(
  73999. /**
  74000. * The radius of the emission hemisphere.
  74001. */
  74002. radius?: number,
  74003. /**
  74004. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  74005. */
  74006. radiusRange?: number,
  74007. /**
  74008. * How much to randomize the particle direction [0-1].
  74009. */
  74010. directionRandomizer?: number);
  74011. /**
  74012. * Called by the particle System when the direction is computed for the created particle.
  74013. * @param worldMatrix is the world matrix of the particle system
  74014. * @param directionToUpdate is the direction vector to update with the result
  74015. * @param particle is the particle we are computed the direction for
  74016. */
  74017. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  74018. /**
  74019. * Called by the particle System when the position is computed for the created particle.
  74020. * @param worldMatrix is the world matrix of the particle system
  74021. * @param positionToUpdate is the position vector to update with the result
  74022. * @param particle is the particle we are computed the position for
  74023. */
  74024. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  74025. /**
  74026. * Clones the current emitter and returns a copy of it
  74027. * @returns the new emitter
  74028. */
  74029. clone(): HemisphericParticleEmitter;
  74030. /**
  74031. * Called by the GPUParticleSystem to setup the update shader
  74032. * @param effect defines the update shader
  74033. */
  74034. applyToShader(effect: Effect): void;
  74035. /**
  74036. * Returns a string to use to update the GPU particles update shader
  74037. * @returns a string containng the defines string
  74038. */
  74039. getEffectDefines(): string;
  74040. /**
  74041. * Returns the string "HemisphericParticleEmitter"
  74042. * @returns a string containing the class name
  74043. */
  74044. getClassName(): string;
  74045. /**
  74046. * Serializes the particle system to a JSON object.
  74047. * @returns the JSON object
  74048. */
  74049. serialize(): any;
  74050. /**
  74051. * Parse properties from a JSON object
  74052. * @param serializationObject defines the JSON object
  74053. */
  74054. parse(serializationObject: any): void;
  74055. }
  74056. }
  74057. declare module BABYLON {
  74058. /**
  74059. * Particle emitter emitting particles from a point.
  74060. * It emits the particles randomly between 2 given directions.
  74061. */
  74062. export class PointParticleEmitter implements IParticleEmitterType {
  74063. /**
  74064. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  74065. */
  74066. direction1: Vector3;
  74067. /**
  74068. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  74069. */
  74070. direction2: Vector3;
  74071. /**
  74072. * Creates a new instance PointParticleEmitter
  74073. */
  74074. constructor();
  74075. /**
  74076. * Called by the particle System when the direction is computed for the created particle.
  74077. * @param worldMatrix is the world matrix of the particle system
  74078. * @param directionToUpdate is the direction vector to update with the result
  74079. * @param particle is the particle we are computed the direction for
  74080. */
  74081. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  74082. /**
  74083. * Called by the particle System when the position is computed for the created particle.
  74084. * @param worldMatrix is the world matrix of the particle system
  74085. * @param positionToUpdate is the position vector to update with the result
  74086. * @param particle is the particle we are computed the position for
  74087. */
  74088. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  74089. /**
  74090. * Clones the current emitter and returns a copy of it
  74091. * @returns the new emitter
  74092. */
  74093. clone(): PointParticleEmitter;
  74094. /**
  74095. * Called by the GPUParticleSystem to setup the update shader
  74096. * @param effect defines the update shader
  74097. */
  74098. applyToShader(effect: Effect): void;
  74099. /**
  74100. * Returns a string to use to update the GPU particles update shader
  74101. * @returns a string containng the defines string
  74102. */
  74103. getEffectDefines(): string;
  74104. /**
  74105. * Returns the string "PointParticleEmitter"
  74106. * @returns a string containing the class name
  74107. */
  74108. getClassName(): string;
  74109. /**
  74110. * Serializes the particle system to a JSON object.
  74111. * @returns the JSON object
  74112. */
  74113. serialize(): any;
  74114. /**
  74115. * Parse properties from a JSON object
  74116. * @param serializationObject defines the JSON object
  74117. */
  74118. parse(serializationObject: any): void;
  74119. }
  74120. }
  74121. declare module BABYLON {
  74122. /**
  74123. * Particle emitter emitting particles from the inside of a sphere.
  74124. * It emits the particles alongside the sphere radius. The emission direction might be randomized.
  74125. */
  74126. export class SphereParticleEmitter implements IParticleEmitterType {
  74127. /**
  74128. * The radius of the emission sphere.
  74129. */
  74130. radius: number;
  74131. /**
  74132. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  74133. */
  74134. radiusRange: number;
  74135. /**
  74136. * How much to randomize the particle direction [0-1].
  74137. */
  74138. directionRandomizer: number;
  74139. /**
  74140. * Creates a new instance SphereParticleEmitter
  74141. * @param radius the radius of the emission sphere (1 by default)
  74142. * @param radiusRange the range of the emission sphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  74143. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  74144. */
  74145. constructor(
  74146. /**
  74147. * The radius of the emission sphere.
  74148. */
  74149. radius?: number,
  74150. /**
  74151. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  74152. */
  74153. radiusRange?: number,
  74154. /**
  74155. * How much to randomize the particle direction [0-1].
  74156. */
  74157. directionRandomizer?: number);
  74158. /**
  74159. * Called by the particle System when the direction is computed for the created particle.
  74160. * @param worldMatrix is the world matrix of the particle system
  74161. * @param directionToUpdate is the direction vector to update with the result
  74162. * @param particle is the particle we are computed the direction for
  74163. */
  74164. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  74165. /**
  74166. * Called by the particle System when the position is computed for the created particle.
  74167. * @param worldMatrix is the world matrix of the particle system
  74168. * @param positionToUpdate is the position vector to update with the result
  74169. * @param particle is the particle we are computed the position for
  74170. */
  74171. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  74172. /**
  74173. * Clones the current emitter and returns a copy of it
  74174. * @returns the new emitter
  74175. */
  74176. clone(): SphereParticleEmitter;
  74177. /**
  74178. * Called by the GPUParticleSystem to setup the update shader
  74179. * @param effect defines the update shader
  74180. */
  74181. applyToShader(effect: Effect): void;
  74182. /**
  74183. * Returns a string to use to update the GPU particles update shader
  74184. * @returns a string containng the defines string
  74185. */
  74186. getEffectDefines(): string;
  74187. /**
  74188. * Returns the string "SphereParticleEmitter"
  74189. * @returns a string containing the class name
  74190. */
  74191. getClassName(): string;
  74192. /**
  74193. * Serializes the particle system to a JSON object.
  74194. * @returns the JSON object
  74195. */
  74196. serialize(): any;
  74197. /**
  74198. * Parse properties from a JSON object
  74199. * @param serializationObject defines the JSON object
  74200. */
  74201. parse(serializationObject: any): void;
  74202. }
  74203. /**
  74204. * Particle emitter emitting particles from the inside of a sphere.
  74205. * It emits the particles randomly between two vectors.
  74206. */
  74207. export class SphereDirectedParticleEmitter extends SphereParticleEmitter {
  74208. /**
  74209. * The min limit of the emission direction.
  74210. */
  74211. direction1: Vector3;
  74212. /**
  74213. * The max limit of the emission direction.
  74214. */
  74215. direction2: Vector3;
  74216. /**
  74217. * Creates a new instance SphereDirectedParticleEmitter
  74218. * @param radius the radius of the emission sphere (1 by default)
  74219. * @param direction1 the min limit of the emission direction (up vector by default)
  74220. * @param direction2 the max limit of the emission direction (up vector by default)
  74221. */
  74222. constructor(radius?: number,
  74223. /**
  74224. * The min limit of the emission direction.
  74225. */
  74226. direction1?: Vector3,
  74227. /**
  74228. * The max limit of the emission direction.
  74229. */
  74230. direction2?: Vector3);
  74231. /**
  74232. * Called by the particle System when the direction is computed for the created particle.
  74233. * @param worldMatrix is the world matrix of the particle system
  74234. * @param directionToUpdate is the direction vector to update with the result
  74235. * @param particle is the particle we are computed the direction for
  74236. */
  74237. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  74238. /**
  74239. * Clones the current emitter and returns a copy of it
  74240. * @returns the new emitter
  74241. */
  74242. clone(): SphereDirectedParticleEmitter;
  74243. /**
  74244. * Called by the GPUParticleSystem to setup the update shader
  74245. * @param effect defines the update shader
  74246. */
  74247. applyToShader(effect: Effect): void;
  74248. /**
  74249. * Returns a string to use to update the GPU particles update shader
  74250. * @returns a string containng the defines string
  74251. */
  74252. getEffectDefines(): string;
  74253. /**
  74254. * Returns the string "SphereDirectedParticleEmitter"
  74255. * @returns a string containing the class name
  74256. */
  74257. getClassName(): string;
  74258. /**
  74259. * Serializes the particle system to a JSON object.
  74260. * @returns the JSON object
  74261. */
  74262. serialize(): any;
  74263. /**
  74264. * Parse properties from a JSON object
  74265. * @param serializationObject defines the JSON object
  74266. */
  74267. parse(serializationObject: any): void;
  74268. }
  74269. }
  74270. declare module BABYLON {
  74271. /**
  74272. * Interface representing a particle system in Babylon.js.
  74273. * This groups the common functionalities that needs to be implemented in order to create a particle system.
  74274. * A particle system represents a way to manage particles from their emission to their animation and rendering.
  74275. */
  74276. export interface IParticleSystem {
  74277. /**
  74278. * List of animations used by the particle system.
  74279. */
  74280. animations: Animation[];
  74281. /**
  74282. * The id of the Particle system.
  74283. */
  74284. id: string;
  74285. /**
  74286. * The name of the Particle system.
  74287. */
  74288. name: string;
  74289. /**
  74290. * The emitter represents the Mesh or position we are attaching the particle system to.
  74291. */
  74292. emitter: Nullable<AbstractMesh | Vector3>;
  74293. /**
  74294. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  74295. */
  74296. isBillboardBased: boolean;
  74297. /**
  74298. * The rendering group used by the Particle system to chose when to render.
  74299. */
  74300. renderingGroupId: number;
  74301. /**
  74302. * The layer mask we are rendering the particles through.
  74303. */
  74304. layerMask: number;
  74305. /**
  74306. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  74307. */
  74308. updateSpeed: number;
  74309. /**
  74310. * The amount of time the particle system is running (depends of the overall update speed).
  74311. */
  74312. targetStopDuration: number;
  74313. /**
  74314. * The texture used to render each particle. (this can be a spritesheet)
  74315. */
  74316. particleTexture: Nullable<Texture>;
  74317. /**
  74318. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE, ParticleSystem.BLENDMODE_STANDARD or ParticleSystem.BLENDMODE_ADD.
  74319. */
  74320. blendMode: number;
  74321. /**
  74322. * Minimum life time of emitting particles.
  74323. */
  74324. minLifeTime: number;
  74325. /**
  74326. * Maximum life time of emitting particles.
  74327. */
  74328. maxLifeTime: number;
  74329. /**
  74330. * Minimum Size of emitting particles.
  74331. */
  74332. minSize: number;
  74333. /**
  74334. * Maximum Size of emitting particles.
  74335. */
  74336. maxSize: number;
  74337. /**
  74338. * Minimum scale of emitting particles on X axis.
  74339. */
  74340. minScaleX: number;
  74341. /**
  74342. * Maximum scale of emitting particles on X axis.
  74343. */
  74344. maxScaleX: number;
  74345. /**
  74346. * Minimum scale of emitting particles on Y axis.
  74347. */
  74348. minScaleY: number;
  74349. /**
  74350. * Maximum scale of emitting particles on Y axis.
  74351. */
  74352. maxScaleY: number;
  74353. /**
  74354. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  74355. */
  74356. color1: Color4;
  74357. /**
  74358. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  74359. */
  74360. color2: Color4;
  74361. /**
  74362. * Color the particle will have at the end of its lifetime.
  74363. */
  74364. colorDead: Color4;
  74365. /**
  74366. * The maximum number of particles to emit per frame until we reach the activeParticleCount value
  74367. */
  74368. emitRate: number;
  74369. /**
  74370. * You can use gravity if you want to give an orientation to your particles.
  74371. */
  74372. gravity: Vector3;
  74373. /**
  74374. * Minimum power of emitting particles.
  74375. */
  74376. minEmitPower: number;
  74377. /**
  74378. * Maximum power of emitting particles.
  74379. */
  74380. maxEmitPower: number;
  74381. /**
  74382. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  74383. */
  74384. minAngularSpeed: number;
  74385. /**
  74386. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  74387. */
  74388. maxAngularSpeed: number;
  74389. /**
  74390. * Gets or sets the minimal initial rotation in radians.
  74391. */
  74392. minInitialRotation: number;
  74393. /**
  74394. * Gets or sets the maximal initial rotation in radians.
  74395. */
  74396. maxInitialRotation: number;
  74397. /**
  74398. * The particle emitter type defines the emitter used by the particle system.
  74399. * It can be for example box, sphere, or cone...
  74400. */
  74401. particleEmitterType: Nullable<IParticleEmitterType>;
  74402. /**
  74403. * Defines the delay in milliseconds before starting the system (0 by default)
  74404. */
  74405. startDelay: number;
  74406. /**
  74407. * 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
  74408. */
  74409. preWarmCycles: number;
  74410. /**
  74411. * Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1)
  74412. */
  74413. preWarmStepOffset: number;
  74414. /**
  74415. * 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)
  74416. */
  74417. spriteCellChangeSpeed: number;
  74418. /**
  74419. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  74420. */
  74421. startSpriteCellID: number;
  74422. /**
  74423. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  74424. */
  74425. endSpriteCellID: number;
  74426. /**
  74427. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  74428. */
  74429. spriteCellWidth: number;
  74430. /**
  74431. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  74432. */
  74433. spriteCellHeight: number;
  74434. /**
  74435. * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID
  74436. */
  74437. spriteRandomStartCell: boolean;
  74438. /**
  74439. * Gets or sets a boolean indicating if a spritesheet is used to animate the particles texture
  74440. */
  74441. isAnimationSheetEnabled: boolean;
  74442. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  74443. translationPivot: Vector2;
  74444. /**
  74445. * Gets or sets a texture used to add random noise to particle positions
  74446. */
  74447. noiseTexture: Nullable<BaseTexture>;
  74448. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  74449. noiseStrength: Vector3;
  74450. /**
  74451. * Gets or sets the billboard mode to use when isBillboardBased = true.
  74452. * Value can be: ParticleSystem.BILLBOARDMODE_ALL, ParticleSystem.BILLBOARDMODE_Y, ParticleSystem.BILLBOARDMODE_STRETCHED
  74453. */
  74454. billboardMode: number;
  74455. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  74456. limitVelocityDamping: number;
  74457. /**
  74458. * Gets or sets a boolean indicating that hosted animations (in the system.animations array) must be started when system.start() is called
  74459. */
  74460. beginAnimationOnStart: boolean;
  74461. /**
  74462. * Gets or sets the frame to start the animation from when beginAnimationOnStart is true
  74463. */
  74464. beginAnimationFrom: number;
  74465. /**
  74466. * Gets or sets the frame to end the animation on when beginAnimationOnStart is true
  74467. */
  74468. beginAnimationTo: number;
  74469. /**
  74470. * Gets or sets a boolean indicating if animations must loop when beginAnimationOnStart is true
  74471. */
  74472. beginAnimationLoop: boolean;
  74473. /**
  74474. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  74475. */
  74476. disposeOnStop: boolean;
  74477. /**
  74478. * Gets the maximum number of particles active at the same time.
  74479. * @returns The max number of active particles.
  74480. */
  74481. getCapacity(): number;
  74482. /**
  74483. * Gets if the system has been started. (Note: this will still be true after stop is called)
  74484. * @returns True if it has been started, otherwise false.
  74485. */
  74486. isStarted(): boolean;
  74487. /**
  74488. * Animates the particle system for this frame.
  74489. */
  74490. animate(): void;
  74491. /**
  74492. * Renders the particle system in its current state.
  74493. * @returns the current number of particles
  74494. */
  74495. render(): number;
  74496. /**
  74497. * Dispose the particle system and frees its associated resources.
  74498. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  74499. */
  74500. dispose(disposeTexture?: boolean): void;
  74501. /**
  74502. * Clones the particle system.
  74503. * @param name The name of the cloned object
  74504. * @param newEmitter The new emitter to use
  74505. * @returns the cloned particle system
  74506. */
  74507. clone(name: string, newEmitter: any): Nullable<IParticleSystem>;
  74508. /**
  74509. * Serializes the particle system to a JSON object.
  74510. * @returns the JSON object
  74511. */
  74512. serialize(): any;
  74513. /**
  74514. * Rebuild the particle system
  74515. */
  74516. rebuild(): void;
  74517. /**
  74518. * Starts the particle system and begins to emit
  74519. * @param delay defines the delay in milliseconds before starting the system (0 by default)
  74520. */
  74521. start(delay?: number): void;
  74522. /**
  74523. * Stops the particle system.
  74524. */
  74525. stop(): void;
  74526. /**
  74527. * Remove all active particles
  74528. */
  74529. reset(): void;
  74530. /**
  74531. * Is this system ready to be used/rendered
  74532. * @return true if the system is ready
  74533. */
  74534. isReady(): boolean;
  74535. /**
  74536. * Adds a new color gradient
  74537. * @param gradient defines the gradient to use (between 0 and 1)
  74538. * @param color1 defines the color to affect to the specified gradient
  74539. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  74540. * @returns the current particle system
  74541. */
  74542. addColorGradient(gradient: number, color1: Color4, color2?: Color4): IParticleSystem;
  74543. /**
  74544. * Remove a specific color gradient
  74545. * @param gradient defines the gradient to remove
  74546. * @returns the current particle system
  74547. */
  74548. removeColorGradient(gradient: number): IParticleSystem;
  74549. /**
  74550. * Adds a new size gradient
  74551. * @param gradient defines the gradient to use (between 0 and 1)
  74552. * @param factor defines the size factor to affect to the specified gradient
  74553. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  74554. * @returns the current particle system
  74555. */
  74556. addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  74557. /**
  74558. * Remove a specific size gradient
  74559. * @param gradient defines the gradient to remove
  74560. * @returns the current particle system
  74561. */
  74562. removeSizeGradient(gradient: number): IParticleSystem;
  74563. /**
  74564. * Gets the current list of color gradients.
  74565. * You must use addColorGradient and removeColorGradient to udpate this list
  74566. * @returns the list of color gradients
  74567. */
  74568. getColorGradients(): Nullable<Array<ColorGradient>>;
  74569. /**
  74570. * Gets the current list of size gradients.
  74571. * You must use addSizeGradient and removeSizeGradient to udpate this list
  74572. * @returns the list of size gradients
  74573. */
  74574. getSizeGradients(): Nullable<Array<FactorGradient>>;
  74575. /**
  74576. * Gets the current list of angular speed gradients.
  74577. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  74578. * @returns the list of angular speed gradients
  74579. */
  74580. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  74581. /**
  74582. * Adds a new angular speed gradient
  74583. * @param gradient defines the gradient to use (between 0 and 1)
  74584. * @param factor defines the angular speed to affect to the specified gradient
  74585. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  74586. * @returns the current particle system
  74587. */
  74588. addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  74589. /**
  74590. * Remove a specific angular speed gradient
  74591. * @param gradient defines the gradient to remove
  74592. * @returns the current particle system
  74593. */
  74594. removeAngularSpeedGradient(gradient: number): IParticleSystem;
  74595. /**
  74596. * Gets the current list of velocity gradients.
  74597. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  74598. * @returns the list of velocity gradients
  74599. */
  74600. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  74601. /**
  74602. * Adds a new velocity gradient
  74603. * @param gradient defines the gradient to use (between 0 and 1)
  74604. * @param factor defines the velocity to affect to the specified gradient
  74605. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  74606. * @returns the current particle system
  74607. */
  74608. addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  74609. /**
  74610. * Remove a specific velocity gradient
  74611. * @param gradient defines the gradient to remove
  74612. * @returns the current particle system
  74613. */
  74614. removeVelocityGradient(gradient: number): IParticleSystem;
  74615. /**
  74616. * Gets the current list of limit velocity gradients.
  74617. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to udpate this list
  74618. * @returns the list of limit velocity gradients
  74619. */
  74620. getLimitVelocityGradients(): Nullable<Array<FactorGradient>>;
  74621. /**
  74622. * Adds a new limit velocity gradient
  74623. * @param gradient defines the gradient to use (between 0 and 1)
  74624. * @param factor defines the limit velocity to affect to the specified gradient
  74625. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  74626. * @returns the current particle system
  74627. */
  74628. addLimitVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  74629. /**
  74630. * Remove a specific limit velocity gradient
  74631. * @param gradient defines the gradient to remove
  74632. * @returns the current particle system
  74633. */
  74634. removeLimitVelocityGradient(gradient: number): IParticleSystem;
  74635. /**
  74636. * Adds a new drag gradient
  74637. * @param gradient defines the gradient to use (between 0 and 1)
  74638. * @param factor defines the drag to affect to the specified gradient
  74639. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  74640. * @returns the current particle system
  74641. */
  74642. addDragGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  74643. /**
  74644. * Remove a specific drag gradient
  74645. * @param gradient defines the gradient to remove
  74646. * @returns the current particle system
  74647. */
  74648. removeDragGradient(gradient: number): IParticleSystem;
  74649. /**
  74650. * Gets the current list of drag gradients.
  74651. * You must use addDragGradient and removeDragGradient to udpate this list
  74652. * @returns the list of drag gradients
  74653. */
  74654. getDragGradients(): Nullable<Array<FactorGradient>>;
  74655. /**
  74656. * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
  74657. * @param gradient defines the gradient to use (between 0 and 1)
  74658. * @param factor defines the emit rate to affect to the specified gradient
  74659. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  74660. * @returns the current particle system
  74661. */
  74662. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  74663. /**
  74664. * Remove a specific emit rate gradient
  74665. * @param gradient defines the gradient to remove
  74666. * @returns the current particle system
  74667. */
  74668. removeEmitRateGradient(gradient: number): IParticleSystem;
  74669. /**
  74670. * Gets the current list of emit rate gradients.
  74671. * You must use addEmitRateGradient and removeEmitRateGradient to udpate this list
  74672. * @returns the list of emit rate gradients
  74673. */
  74674. getEmitRateGradients(): Nullable<Array<FactorGradient>>;
  74675. /**
  74676. * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property)
  74677. * @param gradient defines the gradient to use (between 0 and 1)
  74678. * @param factor defines the start size to affect to the specified gradient
  74679. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  74680. * @returns the current particle system
  74681. */
  74682. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  74683. /**
  74684. * Remove a specific start size gradient
  74685. * @param gradient defines the gradient to remove
  74686. * @returns the current particle system
  74687. */
  74688. removeStartSizeGradient(gradient: number): IParticleSystem;
  74689. /**
  74690. * Gets the current list of start size gradients.
  74691. * You must use addStartSizeGradient and removeStartSizeGradient to udpate this list
  74692. * @returns the list of start size gradients
  74693. */
  74694. getStartSizeGradients(): Nullable<Array<FactorGradient>>;
  74695. /**
  74696. * Adds a new life time gradient
  74697. * @param gradient defines the gradient to use (between 0 and 1)
  74698. * @param factor defines the life time factor to affect to the specified gradient
  74699. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  74700. * @returns the current particle system
  74701. */
  74702. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  74703. /**
  74704. * Remove a specific life time gradient
  74705. * @param gradient defines the gradient to remove
  74706. * @returns the current particle system
  74707. */
  74708. removeLifeTimeGradient(gradient: number): IParticleSystem;
  74709. /**
  74710. * Gets the current list of life time gradients.
  74711. * You must use addLifeTimeGradient and removeLifeTimeGradient to udpate this list
  74712. * @returns the list of life time gradients
  74713. */
  74714. getLifeTimeGradients(): Nullable<Array<FactorGradient>>;
  74715. /**
  74716. * Gets the current list of color gradients.
  74717. * You must use addColorGradient and removeColorGradient to udpate this list
  74718. * @returns the list of color gradients
  74719. */
  74720. getColorGradients(): Nullable<Array<ColorGradient>>;
  74721. /**
  74722. * Adds a new ramp gradient used to remap particle colors
  74723. * @param gradient defines the gradient to use (between 0 and 1)
  74724. * @param color defines the color to affect to the specified gradient
  74725. * @returns the current particle system
  74726. */
  74727. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  74728. /**
  74729. * Gets the current list of ramp gradients.
  74730. * You must use addRampGradient and removeRampGradient to udpate this list
  74731. * @returns the list of ramp gradients
  74732. */
  74733. getRampGradients(): Nullable<Array<Color3Gradient>>;
  74734. /** Gets or sets a boolean indicating that ramp gradients must be used
  74735. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  74736. */
  74737. useRampGradients: boolean;
  74738. /**
  74739. * Adds a new color remap gradient
  74740. * @param gradient defines the gradient to use (between 0 and 1)
  74741. * @param min defines the color remap minimal range
  74742. * @param max defines the color remap maximal range
  74743. * @returns the current particle system
  74744. */
  74745. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  74746. /**
  74747. * Gets the current list of color remap gradients.
  74748. * You must use addColorRemapGradient and removeColorRemapGradient to udpate this list
  74749. * @returns the list of color remap gradients
  74750. */
  74751. getColorRemapGradients(): Nullable<Array<FactorGradient>>;
  74752. /**
  74753. * Adds a new alpha remap gradient
  74754. * @param gradient defines the gradient to use (between 0 and 1)
  74755. * @param min defines the alpha remap minimal range
  74756. * @param max defines the alpha remap maximal range
  74757. * @returns the current particle system
  74758. */
  74759. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  74760. /**
  74761. * Gets the current list of alpha remap gradients.
  74762. * You must use addAlphaRemapGradient and removeAlphaRemapGradient to udpate this list
  74763. * @returns the list of alpha remap gradients
  74764. */
  74765. getAlphaRemapGradients(): Nullable<Array<FactorGradient>>;
  74766. /**
  74767. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  74768. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  74769. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  74770. * @returns the emitter
  74771. */
  74772. createPointEmitter(direction1: Vector3, direction2: Vector3): PointParticleEmitter;
  74773. /**
  74774. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  74775. * @param radius The radius of the hemisphere to emit from
  74776. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  74777. * @returns the emitter
  74778. */
  74779. createHemisphericEmitter(radius: number, radiusRange: number): HemisphericParticleEmitter;
  74780. /**
  74781. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  74782. * @param radius The radius of the sphere to emit from
  74783. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  74784. * @returns the emitter
  74785. */
  74786. createSphereEmitter(radius: number, radiusRange: number): SphereParticleEmitter;
  74787. /**
  74788. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  74789. * @param radius The radius of the sphere to emit from
  74790. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  74791. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  74792. * @returns the emitter
  74793. */
  74794. createDirectedSphereEmitter(radius: number, direction1: Vector3, direction2: Vector3): SphereDirectedParticleEmitter;
  74795. /**
  74796. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  74797. * @param radius The radius of the emission cylinder
  74798. * @param height The height of the emission cylinder
  74799. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  74800. * @param directionRandomizer How much to randomize the particle direction [0-1]
  74801. * @returns the emitter
  74802. */
  74803. createCylinderEmitter(radius: number, height: number, radiusRange: number, directionRandomizer: number): CylinderParticleEmitter;
  74804. /**
  74805. * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)
  74806. * @param radius The radius of the cylinder to emit from
  74807. * @param height The height of the emission cylinder
  74808. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  74809. * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder
  74810. * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder
  74811. * @returns the emitter
  74812. */
  74813. createDirectedCylinderEmitter(radius: number, height: number, radiusRange: number, direction1: Vector3, direction2: Vector3): SphereDirectedParticleEmitter;
  74814. /**
  74815. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  74816. * @param radius The radius of the cone to emit from
  74817. * @param angle The base angle of the cone
  74818. * @returns the emitter
  74819. */
  74820. createConeEmitter(radius: number, angle: number): ConeParticleEmitter;
  74821. /**
  74822. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  74823. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  74824. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  74825. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  74826. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  74827. * @returns the emitter
  74828. */
  74829. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  74830. /**
  74831. * Get hosting scene
  74832. * @returns the scene
  74833. */
  74834. getScene(): Scene;
  74835. }
  74836. }
  74837. declare module BABYLON {
  74838. /**
  74839. * Creates an instance based on a source mesh.
  74840. */
  74841. export class InstancedMesh extends AbstractMesh {
  74842. private _sourceMesh;
  74843. private _currentLOD;
  74844. /** @hidden */
  74845. _indexInSourceMeshInstanceArray: number;
  74846. constructor(name: string, source: Mesh);
  74847. /**
  74848. * Returns the string "InstancedMesh".
  74849. */
  74850. getClassName(): string;
  74851. /**
  74852. * If the source mesh receives shadows
  74853. */
  74854. readonly receiveShadows: boolean;
  74855. /**
  74856. * The material of the source mesh
  74857. */
  74858. readonly material: Nullable<Material>;
  74859. /**
  74860. * Visibility of the source mesh
  74861. */
  74862. readonly visibility: number;
  74863. /**
  74864. * Skeleton of the source mesh
  74865. */
  74866. readonly skeleton: Nullable<Skeleton>;
  74867. /**
  74868. * Rendering ground id of the source mesh
  74869. */
  74870. renderingGroupId: number;
  74871. /**
  74872. * Returns the total number of vertices (integer).
  74873. */
  74874. getTotalVertices(): number;
  74875. /**
  74876. * Returns a positive integer : the total number of indices in this mesh geometry.
  74877. * @returns the numner of indices or zero if the mesh has no geometry.
  74878. */
  74879. getTotalIndices(): number;
  74880. /**
  74881. * The source mesh of the instance
  74882. */
  74883. readonly sourceMesh: Mesh;
  74884. /**
  74885. * Is this node ready to be used/rendered
  74886. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  74887. * @return {boolean} is it ready
  74888. */
  74889. isReady(completeCheck?: boolean): boolean;
  74890. /**
  74891. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  74892. * @param kind kind of verticies to retreive (eg. positons, normals, uvs, etc.)
  74893. * @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.
  74894. * @returns a float array or a Float32Array of the requested kind of data : positons, normals, uvs, etc.
  74895. */
  74896. getVerticesData(kind: string, copyWhenShared?: boolean): Nullable<FloatArray>;
  74897. /**
  74898. * Sets the vertex data of the mesh geometry for the requested `kind`.
  74899. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  74900. * The `data` are either a numeric array either a Float32Array.
  74901. * The parameter `updatable` is passed as is to the underlying Geometry object constructor (if initianilly none) or updater.
  74902. * 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).
  74903. * Note that a new underlying VertexBuffer object is created each call.
  74904. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  74905. *
  74906. * Possible `kind` values :
  74907. * - VertexBuffer.PositionKind
  74908. * - VertexBuffer.UVKind
  74909. * - VertexBuffer.UV2Kind
  74910. * - VertexBuffer.UV3Kind
  74911. * - VertexBuffer.UV4Kind
  74912. * - VertexBuffer.UV5Kind
  74913. * - VertexBuffer.UV6Kind
  74914. * - VertexBuffer.ColorKind
  74915. * - VertexBuffer.MatricesIndicesKind
  74916. * - VertexBuffer.MatricesIndicesExtraKind
  74917. * - VertexBuffer.MatricesWeightsKind
  74918. * - VertexBuffer.MatricesWeightsExtraKind
  74919. *
  74920. * Returns the Mesh.
  74921. */
  74922. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): Mesh;
  74923. /**
  74924. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  74925. * If the mesh has no geometry, it is simply returned as it is.
  74926. * The `data` are either a numeric array either a Float32Array.
  74927. * No new underlying VertexBuffer object is created.
  74928. * 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.
  74929. * If the parameter `makeItUnique` is true, a new global geometry is created from this positions and is set to the mesh.
  74930. *
  74931. * Possible `kind` values :
  74932. * - VertexBuffer.PositionKind
  74933. * - VertexBuffer.UVKind
  74934. * - VertexBuffer.UV2Kind
  74935. * - VertexBuffer.UV3Kind
  74936. * - VertexBuffer.UV4Kind
  74937. * - VertexBuffer.UV5Kind
  74938. * - VertexBuffer.UV6Kind
  74939. * - VertexBuffer.ColorKind
  74940. * - VertexBuffer.MatricesIndicesKind
  74941. * - VertexBuffer.MatricesIndicesExtraKind
  74942. * - VertexBuffer.MatricesWeightsKind
  74943. * - VertexBuffer.MatricesWeightsExtraKind
  74944. *
  74945. * Returns the Mesh.
  74946. */
  74947. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): Mesh;
  74948. /**
  74949. * Sets the mesh indices.
  74950. * Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array).
  74951. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  74952. * This method creates a new index buffer each call.
  74953. * Returns the Mesh.
  74954. */
  74955. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>): Mesh;
  74956. /**
  74957. * Boolean : True if the mesh owns the requested kind of data.
  74958. */
  74959. isVerticesDataPresent(kind: string): boolean;
  74960. /**
  74961. * Returns an array of indices (IndicesArray).
  74962. */
  74963. getIndices(): Nullable<IndicesArray>;
  74964. readonly _positions: Nullable<Vector3[]>;
  74965. /**
  74966. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  74967. * This means the mesh underlying bounding box and sphere are recomputed.
  74968. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  74969. * @returns the current mesh
  74970. */
  74971. refreshBoundingInfo(applySkeleton?: boolean): InstancedMesh;
  74972. /** @hidden */
  74973. _preActivate(): InstancedMesh;
  74974. /** @hidden */
  74975. _activate(renderId: number): InstancedMesh;
  74976. /**
  74977. * Returns the current associated LOD AbstractMesh.
  74978. */
  74979. getLOD(camera: Camera): AbstractMesh;
  74980. /** @hidden */
  74981. _syncSubMeshes(): InstancedMesh;
  74982. /** @hidden */
  74983. _generatePointsArray(): boolean;
  74984. /**
  74985. * Creates a new InstancedMesh from the current mesh.
  74986. * - name (string) : the cloned mesh name
  74987. * - newParent (optional Node) : the optional Node to parent the clone to.
  74988. * - doNotCloneChildren (optional boolean, default `false`) : if `true` the model children aren't cloned.
  74989. *
  74990. * Returns the clone.
  74991. */
  74992. clone(name: string, newParent: Node, doNotCloneChildren?: boolean): InstancedMesh;
  74993. /**
  74994. * Disposes the InstancedMesh.
  74995. * Returns nothing.
  74996. */
  74997. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  74998. }
  74999. }
  75000. declare module BABYLON {
  75001. /**
  75002. * Defines the options associated with the creation of a shader material.
  75003. */
  75004. export interface IShaderMaterialOptions {
  75005. /**
  75006. * Does the material work in alpha blend mode
  75007. */
  75008. needAlphaBlending: boolean;
  75009. /**
  75010. * Does the material work in alpha test mode
  75011. */
  75012. needAlphaTesting: boolean;
  75013. /**
  75014. * The list of attribute names used in the shader
  75015. */
  75016. attributes: string[];
  75017. /**
  75018. * The list of unifrom names used in the shader
  75019. */
  75020. uniforms: string[];
  75021. /**
  75022. * The list of UBO names used in the shader
  75023. */
  75024. uniformBuffers: string[];
  75025. /**
  75026. * The list of sampler names used in the shader
  75027. */
  75028. samplers: string[];
  75029. /**
  75030. * The list of defines used in the shader
  75031. */
  75032. defines: string[];
  75033. }
  75034. /**
  75035. * 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.
  75036. *
  75037. * This returned material effects how the mesh will look based on the code in the shaders.
  75038. *
  75039. * @see http://doc.babylonjs.com/how_to/shader_material
  75040. */
  75041. export class ShaderMaterial extends Material {
  75042. private _shaderPath;
  75043. private _options;
  75044. private _textures;
  75045. private _textureArrays;
  75046. private _floats;
  75047. private _ints;
  75048. private _floatsArrays;
  75049. private _colors3;
  75050. private _colors3Arrays;
  75051. private _colors4;
  75052. private _vectors2;
  75053. private _vectors3;
  75054. private _vectors4;
  75055. private _matrices;
  75056. private _matrices3x3;
  75057. private _matrices2x2;
  75058. private _vectors2Arrays;
  75059. private _vectors3Arrays;
  75060. private _cachedWorldViewMatrix;
  75061. private _renderId;
  75062. /**
  75063. * Instantiate a new shader material.
  75064. * 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.
  75065. * This returned material effects how the mesh will look based on the code in the shaders.
  75066. * @see http://doc.babylonjs.com/how_to/shader_material
  75067. * @param name Define the name of the material in the scene
  75068. * @param scene Define the scene the material belongs to
  75069. * @param shaderPath Defines the route to the shader code in one of three ways:
  75070. * - object - { vertex: "custom", fragment: "custom" }, used with Effect.ShadersStore["customVertexShader"] and Effect.ShadersStore["customFragmentShader"]
  75071. * - object - { vertexElement: "vertexShaderCode", fragmentElement: "fragmentShaderCode" }, used with shader code in <script> tags
  75072. * - string - "./COMMON_NAME", used with external files COMMON_NAME.vertex.fx and COMMON_NAME.fragment.fx in index.html folder.
  75073. * @param options Define the options used to create the shader
  75074. */
  75075. constructor(name: string, scene: Scene, shaderPath: any, options?: Partial<IShaderMaterialOptions>);
  75076. /**
  75077. * Gets the options used to compile the shader.
  75078. * They can be modified to trigger a new compilation
  75079. */
  75080. readonly options: IShaderMaterialOptions;
  75081. /**
  75082. * Gets the current class name of the material e.g. "ShaderMaterial"
  75083. * Mainly use in serialization.
  75084. * @returns the class name
  75085. */
  75086. getClassName(): string;
  75087. /**
  75088. * Specifies if the material will require alpha blending
  75089. * @returns a boolean specifying if alpha blending is needed
  75090. */
  75091. needAlphaBlending(): boolean;
  75092. /**
  75093. * Specifies if this material should be rendered in alpha test mode
  75094. * @returns a boolean specifying if an alpha test is needed.
  75095. */
  75096. needAlphaTesting(): boolean;
  75097. private _checkUniform;
  75098. /**
  75099. * Set a texture in the shader.
  75100. * @param name Define the name of the uniform samplers as defined in the shader
  75101. * @param texture Define the texture to bind to this sampler
  75102. * @return the material itself allowing "fluent" like uniform updates
  75103. */
  75104. setTexture(name: string, texture: Texture): ShaderMaterial;
  75105. /**
  75106. * Set a texture array in the shader.
  75107. * @param name Define the name of the uniform sampler array as defined in the shader
  75108. * @param textures Define the list of textures to bind to this sampler
  75109. * @return the material itself allowing "fluent" like uniform updates
  75110. */
  75111. setTextureArray(name: string, textures: Texture[]): ShaderMaterial;
  75112. /**
  75113. * Set a float in the shader.
  75114. * @param name Define the name of the uniform as defined in the shader
  75115. * @param value Define the value to give to the uniform
  75116. * @return the material itself allowing "fluent" like uniform updates
  75117. */
  75118. setFloat(name: string, value: number): ShaderMaterial;
  75119. /**
  75120. * Set a int in the shader.
  75121. * @param name Define the name of the uniform as defined in the shader
  75122. * @param value Define the value to give to the uniform
  75123. * @return the material itself allowing "fluent" like uniform updates
  75124. */
  75125. setInt(name: string, value: number): ShaderMaterial;
  75126. /**
  75127. * Set an array of floats in the shader.
  75128. * @param name Define the name of the uniform as defined in the shader
  75129. * @param value Define the value to give to the uniform
  75130. * @return the material itself allowing "fluent" like uniform updates
  75131. */
  75132. setFloats(name: string, value: number[]): ShaderMaterial;
  75133. /**
  75134. * Set a vec3 in the shader from a Color3.
  75135. * @param name Define the name of the uniform as defined in the shader
  75136. * @param value Define the value to give to the uniform
  75137. * @return the material itself allowing "fluent" like uniform updates
  75138. */
  75139. setColor3(name: string, value: Color3): ShaderMaterial;
  75140. /**
  75141. * Set a vec3 array in the shader from a Color3 array.
  75142. * @param name Define the name of the uniform as defined in the shader
  75143. * @param value Define the value to give to the uniform
  75144. * @return the material itself allowing "fluent" like uniform updates
  75145. */
  75146. setColor3Array(name: string, value: Color3[]): ShaderMaterial;
  75147. /**
  75148. * Set a vec4 in the shader from a Color4.
  75149. * @param name Define the name of the uniform as defined in the shader
  75150. * @param value Define the value to give to the uniform
  75151. * @return the material itself allowing "fluent" like uniform updates
  75152. */
  75153. setColor4(name: string, value: Color4): ShaderMaterial;
  75154. /**
  75155. * Set a vec2 in the shader from a Vector2.
  75156. * @param name Define the name of the uniform as defined in the shader
  75157. * @param value Define the value to give to the uniform
  75158. * @return the material itself allowing "fluent" like uniform updates
  75159. */
  75160. setVector2(name: string, value: Vector2): ShaderMaterial;
  75161. /**
  75162. * Set a vec3 in the shader from a Vector3.
  75163. * @param name Define the name of the uniform as defined in the shader
  75164. * @param value Define the value to give to the uniform
  75165. * @return the material itself allowing "fluent" like uniform updates
  75166. */
  75167. setVector3(name: string, value: Vector3): ShaderMaterial;
  75168. /**
  75169. * Set a vec4 in the shader from a Vector4.
  75170. * @param name Define the name of the uniform as defined in the shader
  75171. * @param value Define the value to give to the uniform
  75172. * @return the material itself allowing "fluent" like uniform updates
  75173. */
  75174. setVector4(name: string, value: Vector4): ShaderMaterial;
  75175. /**
  75176. * Set a mat4 in the shader from a Matrix.
  75177. * @param name Define the name of the uniform as defined in the shader
  75178. * @param value Define the value to give to the uniform
  75179. * @return the material itself allowing "fluent" like uniform updates
  75180. */
  75181. setMatrix(name: string, value: Matrix): ShaderMaterial;
  75182. /**
  75183. * Set a mat3 in the shader from a Float32Array.
  75184. * @param name Define the name of the uniform as defined in the shader
  75185. * @param value Define the value to give to the uniform
  75186. * @return the material itself allowing "fluent" like uniform updates
  75187. */
  75188. setMatrix3x3(name: string, value: Float32Array): ShaderMaterial;
  75189. /**
  75190. * Set a mat2 in the shader from a Float32Array.
  75191. * @param name Define the name of the uniform as defined in the shader
  75192. * @param value Define the value to give to the uniform
  75193. * @return the material itself allowing "fluent" like uniform updates
  75194. */
  75195. setMatrix2x2(name: string, value: Float32Array): ShaderMaterial;
  75196. /**
  75197. * Set a vec2 array in the shader from a number array.
  75198. * @param name Define the name of the uniform as defined in the shader
  75199. * @param value Define the value to give to the uniform
  75200. * @return the material itself allowing "fluent" like uniform updates
  75201. */
  75202. setArray2(name: string, value: number[]): ShaderMaterial;
  75203. /**
  75204. * Set a vec3 array in the shader from a number array.
  75205. * @param name Define the name of the uniform as defined in the shader
  75206. * @param value Define the value to give to the uniform
  75207. * @return the material itself allowing "fluent" like uniform updates
  75208. */
  75209. setArray3(name: string, value: number[]): ShaderMaterial;
  75210. private _checkCache;
  75211. /**
  75212. * Checks if the material is ready to render the requested mesh
  75213. * @param mesh Define the mesh to render
  75214. * @param useInstances Define whether or not the material is used with instances
  75215. * @returns true if ready, otherwise false
  75216. */
  75217. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  75218. /**
  75219. * Binds the world matrix to the material
  75220. * @param world defines the world transformation matrix
  75221. */
  75222. bindOnlyWorldMatrix(world: Matrix): void;
  75223. /**
  75224. * Binds the material to the mesh
  75225. * @param world defines the world transformation matrix
  75226. * @param mesh defines the mesh to bind the material to
  75227. */
  75228. bind(world: Matrix, mesh?: Mesh): void;
  75229. /**
  75230. * Gets the active textures from the material
  75231. * @returns an array of textures
  75232. */
  75233. getActiveTextures(): BaseTexture[];
  75234. /**
  75235. * Specifies if the material uses a texture
  75236. * @param texture defines the texture to check against the material
  75237. * @returns a boolean specifying if the material uses the texture
  75238. */
  75239. hasTexture(texture: BaseTexture): boolean;
  75240. /**
  75241. * Makes a duplicate of the material, and gives it a new name
  75242. * @param name defines the new name for the duplicated material
  75243. * @returns the cloned material
  75244. */
  75245. clone(name: string): ShaderMaterial;
  75246. /**
  75247. * Disposes the material
  75248. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  75249. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  75250. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  75251. */
  75252. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  75253. /**
  75254. * Serializes this material in a JSON representation
  75255. * @returns the serialized material object
  75256. */
  75257. serialize(): any;
  75258. /**
  75259. * Creates a shader material from parsed shader material data
  75260. * @param source defines the JSON represnetation of the material
  75261. * @param scene defines the hosting scene
  75262. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  75263. * @returns a new material
  75264. */
  75265. static Parse(source: any, scene: Scene, rootUrl: string): ShaderMaterial;
  75266. }
  75267. }
  75268. declare module BABYLON {
  75269. /** @hidden */
  75270. export var colorPixelShader: {
  75271. name: string;
  75272. shader: string;
  75273. };
  75274. }
  75275. declare module BABYLON {
  75276. /** @hidden */
  75277. export var colorVertexShader: {
  75278. name: string;
  75279. shader: string;
  75280. };
  75281. }
  75282. declare module BABYLON {
  75283. /**
  75284. * Line mesh
  75285. * @see https://doc.babylonjs.com/babylon101/parametric_shapes
  75286. */
  75287. export class LinesMesh extends Mesh {
  75288. /**
  75289. * If vertex color should be applied to the mesh
  75290. */
  75291. useVertexColor?: boolean | undefined;
  75292. /**
  75293. * If vertex alpha should be applied to the mesh
  75294. */
  75295. useVertexAlpha?: boolean | undefined;
  75296. /**
  75297. * Color of the line (Default: White)
  75298. */
  75299. color: Color3;
  75300. /**
  75301. * Alpha of the line (Default: 1)
  75302. */
  75303. alpha: number;
  75304. /**
  75305. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  75306. * This margin is expressed in world space coordinates, so its value may vary.
  75307. * Default value is 0.1
  75308. */
  75309. intersectionThreshold: number;
  75310. private _colorShader;
  75311. /**
  75312. * Creates a new LinesMesh
  75313. * @param name defines the name
  75314. * @param scene defines the hosting scene
  75315. * @param parent defines the parent mesh if any
  75316. * @param source defines the optional source LinesMesh used to clone data from
  75317. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  75318. * When false, achieved by calling a clone(), also passing False.
  75319. * This will make creation of children, recursive.
  75320. * @param useVertexColor defines if this LinesMesh supports vertex color
  75321. * @param useVertexAlpha defines if this LinesMesh supports vertex alpha
  75322. */
  75323. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: LinesMesh, doNotCloneChildren?: boolean,
  75324. /**
  75325. * If vertex color should be applied to the mesh
  75326. */
  75327. useVertexColor?: boolean | undefined,
  75328. /**
  75329. * If vertex alpha should be applied to the mesh
  75330. */
  75331. useVertexAlpha?: boolean | undefined);
  75332. private _addClipPlaneDefine;
  75333. private _removeClipPlaneDefine;
  75334. isReady(): boolean;
  75335. /**
  75336. * Returns the string "LineMesh"
  75337. */
  75338. getClassName(): string;
  75339. /**
  75340. * @hidden
  75341. */
  75342. /**
  75343. * @hidden
  75344. */
  75345. material: Material;
  75346. /**
  75347. * @hidden
  75348. */
  75349. readonly checkCollisions: boolean;
  75350. /** @hidden */
  75351. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): LinesMesh;
  75352. /** @hidden */
  75353. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number): LinesMesh;
  75354. /**
  75355. * Disposes of the line mesh
  75356. * @param doNotRecurse If children should be disposed
  75357. */
  75358. dispose(doNotRecurse?: boolean): void;
  75359. /**
  75360. * Returns a new LineMesh object cloned from the current one.
  75361. */
  75362. clone(name: string, newParent?: Node, doNotCloneChildren?: boolean): LinesMesh;
  75363. /**
  75364. * Creates a new InstancedLinesMesh object from the mesh model.
  75365. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  75366. * @param name defines the name of the new instance
  75367. * @returns a new InstancedLinesMesh
  75368. */
  75369. createInstance(name: string): InstancedLinesMesh;
  75370. }
  75371. /**
  75372. * Creates an instance based on a source LinesMesh
  75373. */
  75374. export class InstancedLinesMesh extends InstancedMesh {
  75375. /**
  75376. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  75377. * This margin is expressed in world space coordinates, so its value may vary.
  75378. * Initilized with the intersectionThreshold value of the source LinesMesh
  75379. */
  75380. intersectionThreshold: number;
  75381. constructor(name: string, source: LinesMesh);
  75382. /**
  75383. * Returns the string "InstancedLinesMesh".
  75384. */
  75385. getClassName(): string;
  75386. }
  75387. }
  75388. declare module BABYLON {
  75389. /** @hidden */
  75390. export var linePixelShader: {
  75391. name: string;
  75392. shader: string;
  75393. };
  75394. }
  75395. declare module BABYLON {
  75396. /** @hidden */
  75397. export var lineVertexShader: {
  75398. name: string;
  75399. shader: string;
  75400. };
  75401. }
  75402. declare module BABYLON {
  75403. interface AbstractMesh {
  75404. /**
  75405. * Disables the mesh edge rendering mode
  75406. * @returns the currentAbstractMesh
  75407. */
  75408. disableEdgesRendering(): AbstractMesh;
  75409. /**
  75410. * Enables the edge rendering mode on the mesh.
  75411. * This mode makes the mesh edges visible
  75412. * @param epsilon defines the maximal distance between two angles to detect a face
  75413. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  75414. * @returns the currentAbstractMesh
  75415. * @see https://www.babylonjs-playground.com/#19O9TU#0
  75416. */
  75417. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  75418. /**
  75419. * Gets the edgesRenderer associated with the mesh
  75420. */
  75421. edgesRenderer: Nullable<EdgesRenderer>;
  75422. }
  75423. interface LinesMesh {
  75424. /**
  75425. * Enables the edge rendering mode on the mesh.
  75426. * This mode makes the mesh edges visible
  75427. * @param epsilon defines the maximal distance between two angles to detect a face
  75428. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  75429. * @returns the currentAbstractMesh
  75430. * @see https://www.babylonjs-playground.com/#19O9TU#0
  75431. */
  75432. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  75433. }
  75434. interface InstancedLinesMesh {
  75435. /**
  75436. * Enables the edge rendering mode on the mesh.
  75437. * This mode makes the mesh edges visible
  75438. * @param epsilon defines the maximal distance between two angles to detect a face
  75439. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  75440. * @returns the current InstancedLinesMesh
  75441. * @see https://www.babylonjs-playground.com/#19O9TU#0
  75442. */
  75443. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): InstancedLinesMesh;
  75444. }
  75445. /**
  75446. * Defines the minimum contract an Edges renderer should follow.
  75447. */
  75448. export interface IEdgesRenderer extends IDisposable {
  75449. /**
  75450. * Gets or sets a boolean indicating if the edgesRenderer is active
  75451. */
  75452. isEnabled: boolean;
  75453. /**
  75454. * Renders the edges of the attached mesh,
  75455. */
  75456. render(): void;
  75457. /**
  75458. * Checks wether or not the edges renderer is ready to render.
  75459. * @return true if ready, otherwise false.
  75460. */
  75461. isReady(): boolean;
  75462. }
  75463. /**
  75464. * This class is used to generate edges of the mesh that could then easily be rendered in a scene.
  75465. */
  75466. export class EdgesRenderer implements IEdgesRenderer {
  75467. /**
  75468. * Define the size of the edges with an orthographic camera
  75469. */
  75470. edgesWidthScalerForOrthographic: number;
  75471. /**
  75472. * Define the size of the edges with a perspective camera
  75473. */
  75474. edgesWidthScalerForPerspective: number;
  75475. protected _source: AbstractMesh;
  75476. protected _linesPositions: number[];
  75477. protected _linesNormals: number[];
  75478. protected _linesIndices: number[];
  75479. protected _epsilon: number;
  75480. protected _indicesCount: number;
  75481. protected _lineShader: ShaderMaterial;
  75482. protected _ib: WebGLBuffer;
  75483. protected _buffers: {
  75484. [key: string]: Nullable<VertexBuffer>;
  75485. };
  75486. protected _checkVerticesInsteadOfIndices: boolean;
  75487. private _meshRebuildObserver;
  75488. private _meshDisposeObserver;
  75489. /** Gets or sets a boolean indicating if the edgesRenderer is active */
  75490. isEnabled: boolean;
  75491. /**
  75492. * Creates an instance of the EdgesRenderer. It is primarily use to display edges of a mesh.
  75493. * Beware when you use this class with complex objects as the adjacencies computation can be really long
  75494. * @param source Mesh used to create edges
  75495. * @param epsilon sum of angles in adjacency to check for edge
  75496. * @param checkVerticesInsteadOfIndices bases the edges detection on vertices vs indices
  75497. * @param generateEdgesLines - should generate Lines or only prepare resources.
  75498. */
  75499. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean, generateEdgesLines?: boolean);
  75500. protected _prepareRessources(): void;
  75501. /** @hidden */
  75502. _rebuild(): void;
  75503. /**
  75504. * Releases the required resources for the edges renderer
  75505. */
  75506. dispose(): void;
  75507. protected _processEdgeForAdjacencies(pa: number, pb: number, p0: number, p1: number, p2: number): number;
  75508. protected _processEdgeForAdjacenciesWithVertices(pa: Vector3, pb: Vector3, p0: Vector3, p1: Vector3, p2: Vector3): number;
  75509. /**
  75510. * Checks if the pair of p0 and p1 is en edge
  75511. * @param faceIndex
  75512. * @param edge
  75513. * @param faceNormals
  75514. * @param p0
  75515. * @param p1
  75516. * @private
  75517. */
  75518. protected _checkEdge(faceIndex: number, edge: number, faceNormals: Array<Vector3>, p0: Vector3, p1: Vector3): void;
  75519. /**
  75520. * push line into the position, normal and index buffer
  75521. * @protected
  75522. */
  75523. protected createLine(p0: Vector3, p1: Vector3, offset: number): void;
  75524. /**
  75525. * Generates lines edges from adjacencjes
  75526. * @private
  75527. */
  75528. _generateEdgesLines(): void;
  75529. /**
  75530. * Checks wether or not the edges renderer is ready to render.
  75531. * @return true if ready, otherwise false.
  75532. */
  75533. isReady(): boolean;
  75534. /**
  75535. * Renders the edges of the attached mesh,
  75536. */
  75537. render(): void;
  75538. }
  75539. /**
  75540. * LineEdgesRenderer for LineMeshes to remove unnecessary triangulation
  75541. */
  75542. export class LineEdgesRenderer extends EdgesRenderer {
  75543. /**
  75544. * This constructor turns off auto generating edges line in Edges Renderer to make it here.
  75545. * @param source LineMesh used to generate edges
  75546. * @param epsilon not important (specified angle for edge detection)
  75547. * @param checkVerticesInsteadOfIndices not important for LineMesh
  75548. */
  75549. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean);
  75550. /**
  75551. * Generate edges for each line in LinesMesh. Every Line should be rendered as edge.
  75552. */
  75553. _generateEdgesLines(): void;
  75554. }
  75555. }
  75556. declare module BABYLON {
  75557. /**
  75558. * This represents the object necessary to create a rendering group.
  75559. * This is exclusively used and created by the rendering manager.
  75560. * To modify the behavior, you use the available helpers in your scene or meshes.
  75561. * @hidden
  75562. */
  75563. export class RenderingGroup {
  75564. index: number;
  75565. private _scene;
  75566. private _opaqueSubMeshes;
  75567. private _transparentSubMeshes;
  75568. private _alphaTestSubMeshes;
  75569. private _depthOnlySubMeshes;
  75570. private _particleSystems;
  75571. private _spriteManagers;
  75572. private _opaqueSortCompareFn;
  75573. private _alphaTestSortCompareFn;
  75574. private _transparentSortCompareFn;
  75575. private _renderOpaque;
  75576. private _renderAlphaTest;
  75577. private _renderTransparent;
  75578. private _edgesRenderers;
  75579. onBeforeTransparentRendering: () => void;
  75580. /**
  75581. * Set the opaque sort comparison function.
  75582. * If null the sub meshes will be render in the order they were created
  75583. */
  75584. opaqueSortCompareFn: Nullable<(a: SubMesh, b: SubMesh) => number>;
  75585. /**
  75586. * Set the alpha test sort comparison function.
  75587. * If null the sub meshes will be render in the order they were created
  75588. */
  75589. alphaTestSortCompareFn: Nullable<(a: SubMesh, b: SubMesh) => number>;
  75590. /**
  75591. * Set the transparent sort comparison function.
  75592. * If null the sub meshes will be render in the order they were created
  75593. */
  75594. transparentSortCompareFn: Nullable<(a: SubMesh, b: SubMesh) => number>;
  75595. /**
  75596. * Creates a new rendering group.
  75597. * @param index The rendering group index
  75598. * @param opaqueSortCompareFn The opaque sort comparison function. If null no order is applied
  75599. * @param alphaTestSortCompareFn The alpha test sort comparison function. If null no order is applied
  75600. * @param transparentSortCompareFn The transparent sort comparison function. If null back to front + alpha index sort is applied
  75601. */
  75602. 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>);
  75603. /**
  75604. * Render all the sub meshes contained in the group.
  75605. * @param customRenderFunction Used to override the default render behaviour of the group.
  75606. * @returns true if rendered some submeshes.
  75607. */
  75608. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, renderSprites: boolean, renderParticles: boolean, activeMeshes: Nullable<AbstractMesh[]>): void;
  75609. /**
  75610. * Renders the opaque submeshes in the order from the opaqueSortCompareFn.
  75611. * @param subMeshes The submeshes to render
  75612. */
  75613. private renderOpaqueSorted;
  75614. /**
  75615. * Renders the opaque submeshes in the order from the alphatestSortCompareFn.
  75616. * @param subMeshes The submeshes to render
  75617. */
  75618. private renderAlphaTestSorted;
  75619. /**
  75620. * Renders the opaque submeshes in the order from the transparentSortCompareFn.
  75621. * @param subMeshes The submeshes to render
  75622. */
  75623. private renderTransparentSorted;
  75624. /**
  75625. * Renders the submeshes in a specified order.
  75626. * @param subMeshes The submeshes to sort before render
  75627. * @param sortCompareFn The comparison function use to sort
  75628. * @param cameraPosition The camera position use to preprocess the submeshes to help sorting
  75629. * @param transparent Specifies to activate blending if true
  75630. */
  75631. private static renderSorted;
  75632. /**
  75633. * Renders the submeshes in the order they were dispatched (no sort applied).
  75634. * @param subMeshes The submeshes to render
  75635. */
  75636. private static renderUnsorted;
  75637. /**
  75638. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  75639. * are rendered back to front if in the same alpha index.
  75640. *
  75641. * @param a The first submesh
  75642. * @param b The second submesh
  75643. * @returns The result of the comparison
  75644. */
  75645. static defaultTransparentSortCompare(a: SubMesh, b: SubMesh): number;
  75646. /**
  75647. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  75648. * are rendered back to front.
  75649. *
  75650. * @param a The first submesh
  75651. * @param b The second submesh
  75652. * @returns The result of the comparison
  75653. */
  75654. static backToFrontSortCompare(a: SubMesh, b: SubMesh): number;
  75655. /**
  75656. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  75657. * are rendered front to back (prevent overdraw).
  75658. *
  75659. * @param a The first submesh
  75660. * @param b The second submesh
  75661. * @returns The result of the comparison
  75662. */
  75663. static frontToBackSortCompare(a: SubMesh, b: SubMesh): number;
  75664. /**
  75665. * Resets the different lists of submeshes to prepare a new frame.
  75666. */
  75667. prepare(): void;
  75668. dispose(): void;
  75669. /**
  75670. * Inserts the submesh in its correct queue depending on its material.
  75671. * @param subMesh The submesh to dispatch
  75672. * @param [mesh] Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  75673. * @param [material] Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  75674. */
  75675. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  75676. dispatchSprites(spriteManager: ISpriteManager): void;
  75677. dispatchParticles(particleSystem: IParticleSystem): void;
  75678. private _renderParticles;
  75679. private _renderSprites;
  75680. }
  75681. }
  75682. declare module BABYLON {
  75683. /**
  75684. * Interface describing the different options available in the rendering manager
  75685. * regarding Auto Clear between groups.
  75686. */
  75687. export interface IRenderingManagerAutoClearSetup {
  75688. /**
  75689. * Defines whether or not autoclear is enable.
  75690. */
  75691. autoClear: boolean;
  75692. /**
  75693. * Defines whether or not to autoclear the depth buffer.
  75694. */
  75695. depth: boolean;
  75696. /**
  75697. * Defines whether or not to autoclear the stencil buffer.
  75698. */
  75699. stencil: boolean;
  75700. }
  75701. /**
  75702. * This class is used by the onRenderingGroupObservable
  75703. */
  75704. export class RenderingGroupInfo {
  75705. /**
  75706. * The Scene that being rendered
  75707. */
  75708. scene: Scene;
  75709. /**
  75710. * The camera currently used for the rendering pass
  75711. */
  75712. camera: Nullable<Camera>;
  75713. /**
  75714. * The ID of the renderingGroup being processed
  75715. */
  75716. renderingGroupId: number;
  75717. }
  75718. /**
  75719. * This is the manager responsible of all the rendering for meshes sprites and particles.
  75720. * It is enable to manage the different groups as well as the different necessary sort functions.
  75721. * This should not be used directly aside of the few static configurations
  75722. */
  75723. export class RenderingManager {
  75724. /**
  75725. * The max id used for rendering groups (not included)
  75726. */
  75727. static MAX_RENDERINGGROUPS: number;
  75728. /**
  75729. * The min id used for rendering groups (included)
  75730. */
  75731. static MIN_RENDERINGGROUPS: number;
  75732. /**
  75733. * Used to globally prevent autoclearing scenes.
  75734. */
  75735. static AUTOCLEAR: boolean;
  75736. /**
  75737. * @hidden
  75738. */
  75739. _useSceneAutoClearSetup: boolean;
  75740. private _scene;
  75741. private _renderingGroups;
  75742. private _depthStencilBufferAlreadyCleaned;
  75743. private _autoClearDepthStencil;
  75744. private _customOpaqueSortCompareFn;
  75745. private _customAlphaTestSortCompareFn;
  75746. private _customTransparentSortCompareFn;
  75747. private _renderingGroupInfo;
  75748. /**
  75749. * Instantiates a new rendering group for a particular scene
  75750. * @param scene Defines the scene the groups belongs to
  75751. */
  75752. constructor(scene: Scene);
  75753. private _clearDepthStencilBuffer;
  75754. /**
  75755. * Renders the entire managed groups. This is used by the scene or the different rennder targets.
  75756. * @hidden
  75757. */
  75758. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, activeMeshes: Nullable<AbstractMesh[]>, renderParticles: boolean, renderSprites: boolean): void;
  75759. /**
  75760. * Resets the different information of the group to prepare a new frame
  75761. * @hidden
  75762. */
  75763. reset(): void;
  75764. /**
  75765. * Dispose and release the group and its associated resources.
  75766. * @hidden
  75767. */
  75768. dispose(): void;
  75769. /**
  75770. * Clear the info related to rendering groups preventing retention points during dispose.
  75771. */
  75772. freeRenderingGroups(): void;
  75773. private _prepareRenderingGroup;
  75774. /**
  75775. * Add a sprite manager to the rendering manager in order to render it this frame.
  75776. * @param spriteManager Define the sprite manager to render
  75777. */
  75778. dispatchSprites(spriteManager: ISpriteManager): void;
  75779. /**
  75780. * Add a particle system to the rendering manager in order to render it this frame.
  75781. * @param particleSystem Define the particle system to render
  75782. */
  75783. dispatchParticles(particleSystem: IParticleSystem): void;
  75784. /**
  75785. * Add a submesh to the manager in order to render it this frame
  75786. * @param subMesh The submesh to dispatch
  75787. * @param mesh Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  75788. * @param material Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  75789. */
  75790. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  75791. /**
  75792. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  75793. * This allowed control for front to back rendering or reversly depending of the special needs.
  75794. *
  75795. * @param renderingGroupId The rendering group id corresponding to its index
  75796. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  75797. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  75798. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  75799. */
  75800. 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;
  75801. /**
  75802. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  75803. *
  75804. * @param renderingGroupId The rendering group id corresponding to its index
  75805. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  75806. * @param depth Automatically clears depth between groups if true and autoClear is true.
  75807. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  75808. */
  75809. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  75810. /**
  75811. * Gets the current auto clear configuration for one rendering group of the rendering
  75812. * manager.
  75813. * @param index the rendering group index to get the information for
  75814. * @returns The auto clear setup for the requested rendering group
  75815. */
  75816. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  75817. }
  75818. }
  75819. declare module BABYLON {
  75820. /**
  75821. * This Helps creating a texture that will be created from a camera in your scene.
  75822. * It is basically a dynamic texture that could be used to create special effects for instance.
  75823. * Actually, It is the base of lot of effects in the framework like post process, shadows, effect layers and rendering pipelines...
  75824. */
  75825. export class RenderTargetTexture extends Texture {
  75826. isCube: boolean;
  75827. /**
  75828. * The texture will only be rendered once which can be useful to improve performance if everything in your render is static for instance.
  75829. */
  75830. static readonly REFRESHRATE_RENDER_ONCE: number;
  75831. /**
  75832. * The texture will only be rendered rendered every frame and is recomended for dynamic contents.
  75833. */
  75834. static readonly REFRESHRATE_RENDER_ONEVERYFRAME: number;
  75835. /**
  75836. * The texture will be rendered every 2 frames which could be enough if your dynamic objects are not
  75837. * the central point of your effect and can save a lot of performances.
  75838. */
  75839. static readonly REFRESHRATE_RENDER_ONEVERYTWOFRAMES: number;
  75840. /**
  75841. * Use this predicate to dynamically define the list of mesh you want to render.
  75842. * If set, the renderList property will be overwritten.
  75843. */
  75844. renderListPredicate: (AbstractMesh: AbstractMesh) => boolean;
  75845. private _renderList;
  75846. /**
  75847. * Use this list to define the list of mesh you want to render.
  75848. */
  75849. renderList: Nullable<Array<AbstractMesh>>;
  75850. private _hookArray;
  75851. /**
  75852. * Define if particles should be rendered in your texture.
  75853. */
  75854. renderParticles: boolean;
  75855. /**
  75856. * Define if sprites should be rendered in your texture.
  75857. */
  75858. renderSprites: boolean;
  75859. /**
  75860. * Override the default coordinates mode to projection for RTT as it is the most common case for rendered textures.
  75861. */
  75862. coordinatesMode: number;
  75863. /**
  75864. * Define the camera used to render the texture.
  75865. */
  75866. activeCamera: Nullable<Camera>;
  75867. /**
  75868. * Override the render function of the texture with your own one.
  75869. */
  75870. customRenderFunction: (opaqueSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>, beforeTransparents?: () => void) => void;
  75871. /**
  75872. * Define if camera post processes should be use while rendering the texture.
  75873. */
  75874. useCameraPostProcesses: boolean;
  75875. /**
  75876. * Define if the camera viewport should be respected while rendering the texture or if the render should be done to the entire texture.
  75877. */
  75878. ignoreCameraViewport: boolean;
  75879. private _postProcessManager;
  75880. private _postProcesses;
  75881. private _resizeObserver;
  75882. /**
  75883. * An event triggered when the texture is unbind.
  75884. */
  75885. onBeforeBindObservable: Observable<RenderTargetTexture>;
  75886. /**
  75887. * An event triggered when the texture is unbind.
  75888. */
  75889. onAfterUnbindObservable: Observable<RenderTargetTexture>;
  75890. private _onAfterUnbindObserver;
  75891. /**
  75892. * Set a after unbind callback in the texture.
  75893. * This has been kept for backward compatibility and use of onAfterUnbindObservable is recommended.
  75894. */
  75895. onAfterUnbind: () => void;
  75896. /**
  75897. * An event triggered before rendering the texture
  75898. */
  75899. onBeforeRenderObservable: Observable<number>;
  75900. private _onBeforeRenderObserver;
  75901. /**
  75902. * Set a before render callback in the texture.
  75903. * This has been kept for backward compatibility and use of onBeforeRenderObservable is recommended.
  75904. */
  75905. onBeforeRender: (faceIndex: number) => void;
  75906. /**
  75907. * An event triggered after rendering the texture
  75908. */
  75909. onAfterRenderObservable: Observable<number>;
  75910. private _onAfterRenderObserver;
  75911. /**
  75912. * Set a after render callback in the texture.
  75913. * This has been kept for backward compatibility and use of onAfterRenderObservable is recommended.
  75914. */
  75915. onAfterRender: (faceIndex: number) => void;
  75916. /**
  75917. * An event triggered after the texture clear
  75918. */
  75919. onClearObservable: Observable<Engine>;
  75920. private _onClearObserver;
  75921. /**
  75922. * Set a clear callback in the texture.
  75923. * This has been kept for backward compatibility and use of onClearObservable is recommended.
  75924. */
  75925. onClear: (Engine: Engine) => void;
  75926. /**
  75927. * Define the clear color of the Render Target if it should be different from the scene.
  75928. */
  75929. clearColor: Color4;
  75930. protected _size: number | {
  75931. width: number;
  75932. height: number;
  75933. };
  75934. protected _initialSizeParameter: number | {
  75935. width: number;
  75936. height: number;
  75937. } | {
  75938. ratio: number;
  75939. };
  75940. protected _sizeRatio: Nullable<number>;
  75941. /** @hidden */
  75942. _generateMipMaps: boolean;
  75943. protected _renderingManager: RenderingManager;
  75944. /** @hidden */
  75945. _waitingRenderList: string[];
  75946. protected _doNotChangeAspectRatio: boolean;
  75947. protected _currentRefreshId: number;
  75948. protected _refreshRate: number;
  75949. protected _textureMatrix: Matrix;
  75950. protected _samples: number;
  75951. protected _renderTargetOptions: RenderTargetCreationOptions;
  75952. /**
  75953. * Gets render target creation options that were used.
  75954. */
  75955. readonly renderTargetOptions: RenderTargetCreationOptions;
  75956. protected _engine: Engine;
  75957. protected _onRatioRescale(): void;
  75958. /**
  75959. * Gets or sets the center of the bounding box associated with the texture (when in cube mode)
  75960. * It must define where the camera used to render the texture is set
  75961. */
  75962. boundingBoxPosition: Vector3;
  75963. private _boundingBoxSize;
  75964. /**
  75965. * Gets or sets the size of the bounding box associated with the texture (when in cube mode)
  75966. * When defined, the cubemap will switch to local mode
  75967. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  75968. * @example https://www.babylonjs-playground.com/#RNASML
  75969. */
  75970. boundingBoxSize: Vector3;
  75971. /**
  75972. * In case the RTT has been created with a depth texture, get the associated
  75973. * depth texture.
  75974. * Otherwise, return null.
  75975. */
  75976. depthStencilTexture: Nullable<InternalTexture>;
  75977. /**
  75978. * Instantiate a render target texture. This is mainly used to render of screen the scene to for instance apply post processse
  75979. * or used a shadow, depth texture...
  75980. * @param name The friendly name of the texture
  75981. * @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)
  75982. * @param scene The scene the RTT belongs to. The latest created scene will be used if not precised.
  75983. * @param generateMipMaps True if mip maps need to be generated after render.
  75984. * @param doNotChangeAspectRatio True to not change the aspect ratio of the scene in the RTT
  75985. * @param type The type of the buffer in the RTT (int, half float, float...)
  75986. * @param isCube True if a cube texture needs to be created
  75987. * @param samplingMode The sampling mode to be usedwith the render target (Linear, Nearest...)
  75988. * @param generateDepthBuffer True to generate a depth buffer
  75989. * @param generateStencilBuffer True to generate a stencil buffer
  75990. * @param isMulti True if multiple textures need to be created (Draw Buffers)
  75991. * @param format The internal format of the buffer in the RTT (RED, RG, RGB, RGBA, ALPHA...)
  75992. * @param delayAllocation if the texture allocation should be delayed (default: false)
  75993. */
  75994. constructor(name: string, size: number | {
  75995. width: number;
  75996. height: number;
  75997. } | {
  75998. ratio: number;
  75999. }, scene: Nullable<Scene>, generateMipMaps?: boolean, doNotChangeAspectRatio?: boolean, type?: number, isCube?: boolean, samplingMode?: number, generateDepthBuffer?: boolean, generateStencilBuffer?: boolean, isMulti?: boolean, format?: number, delayAllocation?: boolean);
  76000. /**
  76001. * Creates a depth stencil texture.
  76002. * This is only available in WebGL 2 or with the depth texture extension available.
  76003. * @param comparisonFunction Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode
  76004. * @param bilinearFiltering Specifies whether or not bilinear filtering is enable on the texture
  76005. * @param generateStencil Specifies whether or not a stencil should be allocated in the texture
  76006. */
  76007. createDepthStencilTexture(comparisonFunction?: number, bilinearFiltering?: boolean, generateStencil?: boolean): void;
  76008. private _processSizeParameter;
  76009. /**
  76010. * Define the number of samples to use in case of MSAA.
  76011. * It defaults to one meaning no MSAA has been enabled.
  76012. */
  76013. samples: number;
  76014. /**
  76015. * Resets the refresh counter of the texture and start bak from scratch.
  76016. * Could be useful to regenerate the texture if it is setup to render only once.
  76017. */
  76018. resetRefreshCounter(): void;
  76019. /**
  76020. * Define the refresh rate of the texture or the rendering frequency.
  76021. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  76022. */
  76023. refreshRate: number;
  76024. /**
  76025. * Adds a post process to the render target rendering passes.
  76026. * @param postProcess define the post process to add
  76027. */
  76028. addPostProcess(postProcess: PostProcess): void;
  76029. /**
  76030. * Clear all the post processes attached to the render target
  76031. * @param dispose define if the cleared post processesshould also be disposed (false by default)
  76032. */
  76033. clearPostProcesses(dispose?: boolean): void;
  76034. /**
  76035. * Remove one of the post process from the list of attached post processes to the texture
  76036. * @param postProcess define the post process to remove from the list
  76037. */
  76038. removePostProcess(postProcess: PostProcess): void;
  76039. /** @hidden */
  76040. _shouldRender(): boolean;
  76041. /**
  76042. * Gets the actual render size of the texture.
  76043. * @returns the width of the render size
  76044. */
  76045. getRenderSize(): number;
  76046. /**
  76047. * Gets the actual render width of the texture.
  76048. * @returns the width of the render size
  76049. */
  76050. getRenderWidth(): number;
  76051. /**
  76052. * Gets the actual render height of the texture.
  76053. * @returns the height of the render size
  76054. */
  76055. getRenderHeight(): number;
  76056. /**
  76057. * Get if the texture can be rescaled or not.
  76058. */
  76059. readonly canRescale: boolean;
  76060. /**
  76061. * Resize the texture using a ratio.
  76062. * @param ratio the ratio to apply to the texture size in order to compute the new target size
  76063. */
  76064. scale(ratio: number): void;
  76065. /**
  76066. * Get the texture reflection matrix used to rotate/transform the reflection.
  76067. * @returns the reflection matrix
  76068. */
  76069. getReflectionTextureMatrix(): Matrix;
  76070. /**
  76071. * Resize the texture to a new desired size.
  76072. * Be carrefull as it will recreate all the data in the new texture.
  76073. * @param size Define the new size. It can be:
  76074. * - a number for squared texture,
  76075. * - an object containing { width: number, height: number }
  76076. * - or an object containing a ratio { ratio: number }
  76077. */
  76078. resize(size: number | {
  76079. width: number;
  76080. height: number;
  76081. } | {
  76082. ratio: number;
  76083. }): void;
  76084. /**
  76085. * Renders all the objects from the render list into the texture.
  76086. * @param useCameraPostProcess Define if camera post processes should be used during the rendering
  76087. * @param dumpForDebug Define if the rendering result should be dumped (copied) for debugging purpose
  76088. */
  76089. render(useCameraPostProcess?: boolean, dumpForDebug?: boolean): void;
  76090. private _bestReflectionRenderTargetDimension;
  76091. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  76092. private renderToTarget;
  76093. /**
  76094. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  76095. * This allowed control for front to back rendering or reversly depending of the special needs.
  76096. *
  76097. * @param renderingGroupId The rendering group id corresponding to its index
  76098. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  76099. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  76100. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  76101. */
  76102. 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;
  76103. /**
  76104. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  76105. *
  76106. * @param renderingGroupId The rendering group id corresponding to its index
  76107. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  76108. */
  76109. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  76110. /**
  76111. * Clones the texture.
  76112. * @returns the cloned texture
  76113. */
  76114. clone(): RenderTargetTexture;
  76115. /**
  76116. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  76117. * @returns The JSON representation of the texture
  76118. */
  76119. serialize(): any;
  76120. /**
  76121. * This will remove the attached framebuffer objects. The texture will not be able to be used as render target anymore
  76122. */
  76123. disposeFramebufferObjects(): void;
  76124. /**
  76125. * Dispose the texture and release its associated resources.
  76126. */
  76127. dispose(): void;
  76128. /** @hidden */
  76129. _rebuild(): void;
  76130. /**
  76131. * Clear the info related to rendering groups preventing retention point in material dispose.
  76132. */
  76133. freeRenderingGroups(): void;
  76134. }
  76135. }
  76136. declare module BABYLON {
  76137. /**
  76138. * Mirror texture can be used to simulate the view from a mirror in a scene.
  76139. * It will dynamically be rendered every frame to adapt to the camera point of view.
  76140. * You can then easily use it as a reflectionTexture on a flat surface.
  76141. * In case the surface is not a plane, please consider relying on reflection probes.
  76142. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  76143. */
  76144. export class MirrorTexture extends RenderTargetTexture {
  76145. private scene;
  76146. /**
  76147. * Define the reflection plane we want to use. The mirrorPlane is usually set to the constructed reflector.
  76148. * 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.
  76149. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  76150. */
  76151. mirrorPlane: Plane;
  76152. /**
  76153. * Define the blur ratio used to blur the reflection if needed.
  76154. */
  76155. blurRatio: number;
  76156. /**
  76157. * Define the adaptive blur kernel used to blur the reflection if needed.
  76158. * This will autocompute the closest best match for the `blurKernel`
  76159. */
  76160. adaptiveBlurKernel: number;
  76161. /**
  76162. * Define the blur kernel used to blur the reflection if needed.
  76163. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  76164. */
  76165. blurKernel: number;
  76166. /**
  76167. * Define the blur kernel on the X Axis used to blur the reflection if needed.
  76168. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  76169. */
  76170. blurKernelX: number;
  76171. /**
  76172. * Define the blur kernel on the Y Axis used to blur the reflection if needed.
  76173. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  76174. */
  76175. blurKernelY: number;
  76176. private _autoComputeBlurKernel;
  76177. protected _onRatioRescale(): void;
  76178. private _updateGammaSpace;
  76179. private _imageProcessingConfigChangeObserver;
  76180. private _transformMatrix;
  76181. private _mirrorMatrix;
  76182. private _savedViewMatrix;
  76183. private _blurX;
  76184. private _blurY;
  76185. private _adaptiveBlurKernel;
  76186. private _blurKernelX;
  76187. private _blurKernelY;
  76188. private _blurRatio;
  76189. /**
  76190. * Instantiates a Mirror Texture.
  76191. * Mirror texture can be used to simulate the view from a mirror in a scene.
  76192. * It will dynamically be rendered every frame to adapt to the camera point of view.
  76193. * You can then easily use it as a reflectionTexture on a flat surface.
  76194. * In case the surface is not a plane, please consider relying on reflection probes.
  76195. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  76196. * @param name
  76197. * @param size
  76198. * @param scene
  76199. * @param generateMipMaps
  76200. * @param type
  76201. * @param samplingMode
  76202. * @param generateDepthBuffer
  76203. */
  76204. constructor(name: string, size: number | {
  76205. width: number;
  76206. height: number;
  76207. } | {
  76208. ratio: number;
  76209. }, scene: Scene, generateMipMaps?: boolean, type?: number, samplingMode?: number, generateDepthBuffer?: boolean);
  76210. private _preparePostProcesses;
  76211. /**
  76212. * Clone the mirror texture.
  76213. * @returns the cloned texture
  76214. */
  76215. clone(): MirrorTexture;
  76216. /**
  76217. * Serialize the texture to a JSON representation you could use in Parse later on
  76218. * @returns the serialized JSON representation
  76219. */
  76220. serialize(): any;
  76221. /**
  76222. * Dispose the texture and release its associated resources.
  76223. */
  76224. dispose(): void;
  76225. }
  76226. }
  76227. declare module BABYLON {
  76228. /**
  76229. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  76230. * @see http://doc.babylonjs.com/babylon101/materials#texture
  76231. */
  76232. export class Texture extends BaseTexture {
  76233. /** @hidden */
  76234. static _CubeTextureParser: (jsonTexture: any, scene: Scene, rootUrl: string) => CubeTexture;
  76235. /** @hidden */
  76236. static _CreateMirror: (name: string, renderTargetSize: number, scene: Scene, generateMipMaps: boolean) => MirrorTexture;
  76237. /** @hidden */
  76238. static _CreateRenderTargetTexture: (name: string, renderTargetSize: number, scene: Scene, generateMipMaps: boolean) => RenderTargetTexture;
  76239. /** nearest is mag = nearest and min = nearest and mip = linear */
  76240. static readonly NEAREST_SAMPLINGMODE: number;
  76241. /** nearest is mag = nearest and min = nearest and mip = linear */
  76242. static readonly NEAREST_NEAREST_MIPLINEAR: number;
  76243. /** Bilinear is mag = linear and min = linear and mip = nearest */
  76244. static readonly BILINEAR_SAMPLINGMODE: number;
  76245. /** Bilinear is mag = linear and min = linear and mip = nearest */
  76246. static readonly LINEAR_LINEAR_MIPNEAREST: number;
  76247. /** Trilinear is mag = linear and min = linear and mip = linear */
  76248. static readonly TRILINEAR_SAMPLINGMODE: number;
  76249. /** Trilinear is mag = linear and min = linear and mip = linear */
  76250. static readonly LINEAR_LINEAR_MIPLINEAR: number;
  76251. /** mag = nearest and min = nearest and mip = nearest */
  76252. static readonly NEAREST_NEAREST_MIPNEAREST: number;
  76253. /** mag = nearest and min = linear and mip = nearest */
  76254. static readonly NEAREST_LINEAR_MIPNEAREST: number;
  76255. /** mag = nearest and min = linear and mip = linear */
  76256. static readonly NEAREST_LINEAR_MIPLINEAR: number;
  76257. /** mag = nearest and min = linear and mip = none */
  76258. static readonly NEAREST_LINEAR: number;
  76259. /** mag = nearest and min = nearest and mip = none */
  76260. static readonly NEAREST_NEAREST: number;
  76261. /** mag = linear and min = nearest and mip = nearest */
  76262. static readonly LINEAR_NEAREST_MIPNEAREST: number;
  76263. /** mag = linear and min = nearest and mip = linear */
  76264. static readonly LINEAR_NEAREST_MIPLINEAR: number;
  76265. /** mag = linear and min = linear and mip = none */
  76266. static readonly LINEAR_LINEAR: number;
  76267. /** mag = linear and min = nearest and mip = none */
  76268. static readonly LINEAR_NEAREST: number;
  76269. /** Explicit coordinates mode */
  76270. static readonly EXPLICIT_MODE: number;
  76271. /** Spherical coordinates mode */
  76272. static readonly SPHERICAL_MODE: number;
  76273. /** Planar coordinates mode */
  76274. static readonly PLANAR_MODE: number;
  76275. /** Cubic coordinates mode */
  76276. static readonly CUBIC_MODE: number;
  76277. /** Projection coordinates mode */
  76278. static readonly PROJECTION_MODE: number;
  76279. /** Inverse Cubic coordinates mode */
  76280. static readonly SKYBOX_MODE: number;
  76281. /** Inverse Cubic coordinates mode */
  76282. static readonly INVCUBIC_MODE: number;
  76283. /** Equirectangular coordinates mode */
  76284. static readonly EQUIRECTANGULAR_MODE: number;
  76285. /** Equirectangular Fixed coordinates mode */
  76286. static readonly FIXED_EQUIRECTANGULAR_MODE: number;
  76287. /** Equirectangular Fixed Mirrored coordinates mode */
  76288. static readonly FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  76289. /** Texture is not repeating outside of 0..1 UVs */
  76290. static readonly CLAMP_ADDRESSMODE: number;
  76291. /** Texture is repeating outside of 0..1 UVs */
  76292. static readonly WRAP_ADDRESSMODE: number;
  76293. /** Texture is repeating and mirrored */
  76294. static readonly MIRROR_ADDRESSMODE: number;
  76295. /**
  76296. * 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
  76297. */
  76298. static UseSerializedUrlIfAny: boolean;
  76299. /**
  76300. * Define the url of the texture.
  76301. */
  76302. url: Nullable<string>;
  76303. /**
  76304. * Define an offset on the texture to offset the u coordinates of the UVs
  76305. * @see http://doc.babylonjs.com/how_to/more_materials#offsetting
  76306. */
  76307. uOffset: number;
  76308. /**
  76309. * Define an offset on the texture to offset the v coordinates of the UVs
  76310. * @see http://doc.babylonjs.com/how_to/more_materials#offsetting
  76311. */
  76312. vOffset: number;
  76313. /**
  76314. * Define an offset on the texture to scale the u coordinates of the UVs
  76315. * @see http://doc.babylonjs.com/how_to/more_materials#tiling
  76316. */
  76317. uScale: number;
  76318. /**
  76319. * Define an offset on the texture to scale the v coordinates of the UVs
  76320. * @see http://doc.babylonjs.com/how_to/more_materials#tiling
  76321. */
  76322. vScale: number;
  76323. /**
  76324. * Define an offset on the texture to rotate around the u coordinates of the UVs
  76325. * @see http://doc.babylonjs.com/how_to/more_materials
  76326. */
  76327. uAng: number;
  76328. /**
  76329. * Define an offset on the texture to rotate around the v coordinates of the UVs
  76330. * @see http://doc.babylonjs.com/how_to/more_materials
  76331. */
  76332. vAng: number;
  76333. /**
  76334. * Define an offset on the texture to rotate around the w coordinates of the UVs (in case of 3d texture)
  76335. * @see http://doc.babylonjs.com/how_to/more_materials
  76336. */
  76337. wAng: number;
  76338. /**
  76339. * Defines the center of rotation (U)
  76340. */
  76341. uRotationCenter: number;
  76342. /**
  76343. * Defines the center of rotation (V)
  76344. */
  76345. vRotationCenter: number;
  76346. /**
  76347. * Defines the center of rotation (W)
  76348. */
  76349. wRotationCenter: number;
  76350. /**
  76351. * Are mip maps generated for this texture or not.
  76352. */
  76353. readonly noMipmap: boolean;
  76354. /**
  76355. * List of inspectable custom properties (used by the Inspector)
  76356. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  76357. */
  76358. inspectableCustomProperties: IInspectable[];
  76359. private _noMipmap;
  76360. /** @hidden */
  76361. _invertY: boolean;
  76362. private _rowGenerationMatrix;
  76363. private _cachedTextureMatrix;
  76364. private _projectionModeMatrix;
  76365. private _t0;
  76366. private _t1;
  76367. private _t2;
  76368. private _cachedUOffset;
  76369. private _cachedVOffset;
  76370. private _cachedUScale;
  76371. private _cachedVScale;
  76372. private _cachedUAng;
  76373. private _cachedVAng;
  76374. private _cachedWAng;
  76375. private _cachedProjectionMatrixId;
  76376. private _cachedCoordinatesMode;
  76377. /** @hidden */
  76378. protected _initialSamplingMode: number;
  76379. /** @hidden */
  76380. _buffer: Nullable<string | ArrayBuffer | HTMLImageElement | Blob>;
  76381. private _deleteBuffer;
  76382. protected _format: Nullable<number>;
  76383. private _delayedOnLoad;
  76384. private _delayedOnError;
  76385. /**
  76386. * Observable triggered once the texture has been loaded.
  76387. */
  76388. onLoadObservable: Observable<Texture>;
  76389. protected _isBlocking: boolean;
  76390. /**
  76391. * Is the texture preventing material to render while loading.
  76392. * If false, a default texture will be used instead of the loading one during the preparation step.
  76393. */
  76394. isBlocking: boolean;
  76395. /**
  76396. * Get the current sampling mode associated with the texture.
  76397. */
  76398. readonly samplingMode: number;
  76399. /**
  76400. * Gets a boolean indicating if the texture needs to be inverted on the y axis during loading
  76401. */
  76402. readonly invertY: boolean;
  76403. /**
  76404. * Instantiates a new texture.
  76405. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  76406. * @see http://doc.babylonjs.com/babylon101/materials#texture
  76407. * @param url define the url of the picture to load as a texture
  76408. * @param scene define the scene the texture will belong to
  76409. * @param noMipmap define if the texture will require mip maps or not
  76410. * @param invertY define if the texture needs to be inverted on the y axis during loading
  76411. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  76412. * @param onLoad define a callback triggered when the texture has been loaded
  76413. * @param onError define a callback triggered when an error occurred during the loading session
  76414. * @param buffer define the buffer to load the texture from in case the texture is loaded from a buffer representation
  76415. * @param deleteBuffer define if the buffer we are loading the texture from should be deleted after load
  76416. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  76417. */
  76418. 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);
  76419. /**
  76420. * Update the url (and optional buffer) of this texture if url was null during construction.
  76421. * @param url the url of the texture
  76422. * @param buffer the buffer of the texture (defaults to null)
  76423. * @param onLoad callback called when the texture is loaded (defaults to null)
  76424. */
  76425. updateURL(url: string, buffer?: Nullable<string | ArrayBuffer | HTMLImageElement | Blob>, onLoad?: () => void): void;
  76426. /**
  76427. * Finish the loading sequence of a texture flagged as delayed load.
  76428. * @hidden
  76429. */
  76430. delayLoad(): void;
  76431. private _prepareRowForTextureGeneration;
  76432. /**
  76433. * Get the current texture matrix which includes the requested offsetting, tiling and rotation components.
  76434. * @returns the transform matrix of the texture.
  76435. */
  76436. getTextureMatrix(): Matrix;
  76437. /**
  76438. * Get the current matrix used to apply reflection. This is useful to rotate an environment texture for instance.
  76439. * @returns The reflection texture transform
  76440. */
  76441. getReflectionTextureMatrix(): Matrix;
  76442. /**
  76443. * Clones the texture.
  76444. * @returns the cloned texture
  76445. */
  76446. clone(): Texture;
  76447. /**
  76448. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  76449. * @returns The JSON representation of the texture
  76450. */
  76451. serialize(): any;
  76452. /**
  76453. * Get the current class name of the texture useful for serialization or dynamic coding.
  76454. * @returns "Texture"
  76455. */
  76456. getClassName(): string;
  76457. /**
  76458. * Dispose the texture and release its associated resources.
  76459. */
  76460. dispose(): void;
  76461. /**
  76462. * Parse the JSON representation of a texture in order to recreate the texture in the given scene.
  76463. * @param parsedTexture Define the JSON representation of the texture
  76464. * @param scene Define the scene the parsed texture should be instantiated in
  76465. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  76466. * @returns The parsed texture if successful
  76467. */
  76468. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<BaseTexture>;
  76469. /**
  76470. * Creates a texture from its base 64 representation.
  76471. * @param data Define the base64 payload without the data: prefix
  76472. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  76473. * @param scene Define the scene the texture should belong to
  76474. * @param noMipmap Forces the texture to not create mip map information if true
  76475. * @param invertY define if the texture needs to be inverted on the y axis during loading
  76476. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  76477. * @param onLoad define a callback triggered when the texture has been loaded
  76478. * @param onError define a callback triggered when an error occurred during the loading session
  76479. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  76480. * @returns the created texture
  76481. */
  76482. static CreateFromBase64String(data: string, name: string, scene: Scene, noMipmap?: boolean, invertY?: boolean, samplingMode?: number, onLoad?: Nullable<() => void>, onError?: Nullable<() => void>, format?: number): Texture;
  76483. /**
  76484. * Creates a texture from its data: representation. (data: will be added in case only the payload has been passed in)
  76485. * @param data Define the base64 payload without the data: prefix
  76486. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  76487. * @param buffer define the buffer to load the texture from in case the texture is loaded from a buffer representation
  76488. * @param scene Define the scene the texture should belong to
  76489. * @param deleteBuffer define if the buffer we are loading the texture from should be deleted after load
  76490. * @param noMipmap Forces the texture to not create mip map information if true
  76491. * @param invertY define if the texture needs to be inverted on the y axis during loading
  76492. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  76493. * @param onLoad define a callback triggered when the texture has been loaded
  76494. * @param onError define a callback triggered when an error occurred during the loading session
  76495. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  76496. * @returns the created texture
  76497. */
  76498. 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;
  76499. }
  76500. }
  76501. declare module BABYLON {
  76502. /**
  76503. * Raw texture can help creating a texture directly from an array of data.
  76504. * This can be super useful if you either get the data from an uncompressed source or
  76505. * if you wish to create your texture pixel by pixel.
  76506. */
  76507. export class RawTexture extends Texture {
  76508. /**
  76509. * Define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  76510. */
  76511. format: number;
  76512. private _engine;
  76513. /**
  76514. * Instantiates a new RawTexture.
  76515. * Raw texture can help creating a texture directly from an array of data.
  76516. * This can be super useful if you either get the data from an uncompressed source or
  76517. * if you wish to create your texture pixel by pixel.
  76518. * @param data define the array of data to use to create the texture
  76519. * @param width define the width of the texture
  76520. * @param height define the height of the texture
  76521. * @param format define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  76522. * @param scene define the scene the texture belongs to
  76523. * @param generateMipMaps define whether mip maps should be generated or not
  76524. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  76525. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  76526. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  76527. */
  76528. constructor(data: ArrayBufferView, width: number, height: number,
  76529. /**
  76530. * Define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  76531. */
  76532. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number);
  76533. /**
  76534. * Updates the texture underlying data.
  76535. * @param data Define the new data of the texture
  76536. */
  76537. update(data: ArrayBufferView): void;
  76538. /**
  76539. * Creates a luminance texture from some data.
  76540. * @param data Define the texture data
  76541. * @param width Define the width of the texture
  76542. * @param height Define the height of the texture
  76543. * @param scene Define the scene the texture belongs to
  76544. * @param generateMipMaps Define whether or not to create mip maps for the texture
  76545. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  76546. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  76547. * @returns the luminance texture
  76548. */
  76549. static CreateLuminanceTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  76550. /**
  76551. * Creates a luminance alpha texture from some data.
  76552. * @param data Define the texture data
  76553. * @param width Define the width of the texture
  76554. * @param height Define the height of the texture
  76555. * @param scene Define the scene the texture belongs to
  76556. * @param generateMipMaps Define whether or not to create mip maps for the texture
  76557. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  76558. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  76559. * @returns the luminance alpha texture
  76560. */
  76561. static CreateLuminanceAlphaTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  76562. /**
  76563. * Creates an alpha texture from some data.
  76564. * @param data Define the texture data
  76565. * @param width Define the width of the texture
  76566. * @param height Define the height of the texture
  76567. * @param scene Define the scene the texture belongs to
  76568. * @param generateMipMaps Define whether or not to create mip maps for the texture
  76569. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  76570. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  76571. * @returns the alpha texture
  76572. */
  76573. static CreateAlphaTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  76574. /**
  76575. * Creates a RGB texture from some data.
  76576. * @param data Define the texture data
  76577. * @param width Define the width of the texture
  76578. * @param height Define the height of the texture
  76579. * @param scene Define the scene the texture belongs to
  76580. * @param generateMipMaps Define whether or not to create mip maps for the texture
  76581. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  76582. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  76583. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  76584. * @returns the RGB alpha texture
  76585. */
  76586. static CreateRGBTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  76587. /**
  76588. * Creates a RGBA texture from some data.
  76589. * @param data Define the texture data
  76590. * @param width Define the width of the texture
  76591. * @param height Define the height of the texture
  76592. * @param scene Define the scene the texture belongs to
  76593. * @param generateMipMaps Define whether or not to create mip maps for the texture
  76594. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  76595. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  76596. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  76597. * @returns the RGBA texture
  76598. */
  76599. static CreateRGBATexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  76600. /**
  76601. * Creates a R texture from some data.
  76602. * @param data Define the texture data
  76603. * @param width Define the width of the texture
  76604. * @param height Define the height of the texture
  76605. * @param scene Define the scene the texture belongs to
  76606. * @param generateMipMaps Define whether or not to create mip maps for the texture
  76607. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  76608. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  76609. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  76610. * @returns the R texture
  76611. */
  76612. static CreateRTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  76613. }
  76614. }
  76615. declare module BABYLON {
  76616. /**
  76617. * Defines a runtime animation
  76618. */
  76619. export class RuntimeAnimation {
  76620. private _events;
  76621. /**
  76622. * The current frame of the runtime animation
  76623. */
  76624. private _currentFrame;
  76625. /**
  76626. * The animation used by the runtime animation
  76627. */
  76628. private _animation;
  76629. /**
  76630. * The target of the runtime animation
  76631. */
  76632. private _target;
  76633. /**
  76634. * The initiating animatable
  76635. */
  76636. private _host;
  76637. /**
  76638. * The original value of the runtime animation
  76639. */
  76640. private _originalValue;
  76641. /**
  76642. * The original blend value of the runtime animation
  76643. */
  76644. private _originalBlendValue;
  76645. /**
  76646. * The offsets cache of the runtime animation
  76647. */
  76648. private _offsetsCache;
  76649. /**
  76650. * The high limits cache of the runtime animation
  76651. */
  76652. private _highLimitsCache;
  76653. /**
  76654. * Specifies if the runtime animation has been stopped
  76655. */
  76656. private _stopped;
  76657. /**
  76658. * The blending factor of the runtime animation
  76659. */
  76660. private _blendingFactor;
  76661. /**
  76662. * The BabylonJS scene
  76663. */
  76664. private _scene;
  76665. /**
  76666. * The current value of the runtime animation
  76667. */
  76668. private _currentValue;
  76669. /** @hidden */
  76670. _workValue: any;
  76671. /**
  76672. * The active target of the runtime animation
  76673. */
  76674. private _activeTarget;
  76675. /**
  76676. * The target path of the runtime animation
  76677. */
  76678. private _targetPath;
  76679. /**
  76680. * The weight of the runtime animation
  76681. */
  76682. private _weight;
  76683. /**
  76684. * The ratio offset of the runtime animation
  76685. */
  76686. private _ratioOffset;
  76687. /**
  76688. * The previous delay of the runtime animation
  76689. */
  76690. private _previousDelay;
  76691. /**
  76692. * The previous ratio of the runtime animation
  76693. */
  76694. private _previousRatio;
  76695. /**
  76696. * Gets the current frame of the runtime animation
  76697. */
  76698. readonly currentFrame: number;
  76699. /**
  76700. * Gets the weight of the runtime animation
  76701. */
  76702. readonly weight: number;
  76703. /**
  76704. * Gets the current value of the runtime animation
  76705. */
  76706. readonly currentValue: any;
  76707. /**
  76708. * Gets the target path of the runtime animation
  76709. */
  76710. readonly targetPath: string;
  76711. /**
  76712. * Gets the actual target of the runtime animation
  76713. */
  76714. readonly target: any;
  76715. /**
  76716. * Create a new RuntimeAnimation object
  76717. * @param target defines the target of the animation
  76718. * @param animation defines the source animation object
  76719. * @param scene defines the hosting scene
  76720. * @param host defines the initiating Animatable
  76721. */
  76722. constructor(target: any, animation: Animation, scene: Scene, host: Animatable);
  76723. /**
  76724. * Gets the animation from the runtime animation
  76725. */
  76726. readonly animation: Animation;
  76727. /**
  76728. * Resets the runtime animation to the beginning
  76729. * @param restoreOriginal defines whether to restore the target property to the original value
  76730. */
  76731. reset(restoreOriginal?: boolean): void;
  76732. /**
  76733. * Specifies if the runtime animation is stopped
  76734. * @returns Boolean specifying if the runtime animation is stopped
  76735. */
  76736. isStopped(): boolean;
  76737. /**
  76738. * Disposes of the runtime animation
  76739. */
  76740. dispose(): void;
  76741. /**
  76742. * Interpolates the animation from the current frame
  76743. * @param currentFrame The frame to interpolate the animation to
  76744. * @param repeatCount The number of times that the animation should loop
  76745. * @param loopMode The type of looping mode to use
  76746. * @param offsetValue Animation offset value
  76747. * @param highLimitValue The high limit value
  76748. * @returns The interpolated value
  76749. */
  76750. private _interpolate;
  76751. /**
  76752. * Apply the interpolated value to the target
  76753. * @param currentValue defines the value computed by the animation
  76754. * @param weight defines the weight to apply to this value (Defaults to 1.0)
  76755. */
  76756. setValue(currentValue: any, weight?: number): void;
  76757. private _setValue;
  76758. /**
  76759. * Gets the loop pmode of the runtime animation
  76760. * @returns Loop Mode
  76761. */
  76762. private _getCorrectLoopMode;
  76763. /**
  76764. * Move the current animation to a given frame
  76765. * @param frame defines the frame to move to
  76766. */
  76767. goToFrame(frame: number): void;
  76768. /**
  76769. * @hidden Internal use only
  76770. */
  76771. _prepareForSpeedRatioChange(newSpeedRatio: number): void;
  76772. /**
  76773. * Execute the current animation
  76774. * @param delay defines the delay to add to the current frame
  76775. * @param from defines the lower bound of the animation range
  76776. * @param to defines the upper bound of the animation range
  76777. * @param loop defines if the current animation must loop
  76778. * @param speedRatio defines the current speed ratio
  76779. * @param weight defines the weight of the animation (default is -1 so no weight)
  76780. * @param onLoop optional callback called when animation loops
  76781. * @returns a boolean indicating if the animation is running
  76782. */
  76783. animate(delay: number, from: number, to: number, loop: boolean, speedRatio: number, weight?: number, onLoop?: () => void): boolean;
  76784. }
  76785. }
  76786. declare module BABYLON {
  76787. /**
  76788. * Class used to store an actual running animation
  76789. */
  76790. export class Animatable {
  76791. /** defines the target object */
  76792. target: any;
  76793. /** defines the starting frame number (default is 0) */
  76794. fromFrame: number;
  76795. /** defines the ending frame number (default is 100) */
  76796. toFrame: number;
  76797. /** defines if the animation must loop (default is false) */
  76798. loopAnimation: boolean;
  76799. /** defines a callback to call when animation ends if it is not looping */
  76800. onAnimationEnd?: (() => void) | null | undefined;
  76801. /** defines a callback to call when animation loops */
  76802. onAnimationLoop?: (() => void) | null | undefined;
  76803. private _localDelayOffset;
  76804. private _pausedDelay;
  76805. private _runtimeAnimations;
  76806. private _paused;
  76807. private _scene;
  76808. private _speedRatio;
  76809. private _weight;
  76810. private _syncRoot;
  76811. /**
  76812. * Gets or sets a boolean indicating if the animatable must be disposed and removed at the end of the animation.
  76813. * This will only apply for non looping animation (default is true)
  76814. */
  76815. disposeOnEnd: boolean;
  76816. /**
  76817. * Gets a boolean indicating if the animation has started
  76818. */
  76819. animationStarted: boolean;
  76820. /**
  76821. * Observer raised when the animation ends
  76822. */
  76823. onAnimationEndObservable: Observable<Animatable>;
  76824. /**
  76825. * Observer raised when the animation loops
  76826. */
  76827. onAnimationLoopObservable: Observable<Animatable>;
  76828. /**
  76829. * Gets the root Animatable used to synchronize and normalize animations
  76830. */
  76831. readonly syncRoot: Animatable;
  76832. /**
  76833. * Gets the current frame of the first RuntimeAnimation
  76834. * Used to synchronize Animatables
  76835. */
  76836. readonly masterFrame: number;
  76837. /**
  76838. * Gets or sets the animatable weight (-1.0 by default meaning not weighted)
  76839. */
  76840. weight: number;
  76841. /**
  76842. * Gets or sets the speed ratio to apply to the animatable (1.0 by default)
  76843. */
  76844. speedRatio: number;
  76845. /**
  76846. * Creates a new Animatable
  76847. * @param scene defines the hosting scene
  76848. * @param target defines the target object
  76849. * @param fromFrame defines the starting frame number (default is 0)
  76850. * @param toFrame defines the ending frame number (default is 100)
  76851. * @param loopAnimation defines if the animation must loop (default is false)
  76852. * @param speedRatio defines the factor to apply to animation speed (default is 1)
  76853. * @param onAnimationEnd defines a callback to call when animation ends if it is not looping
  76854. * @param animations defines a group of animation to add to the new Animatable
  76855. * @param onAnimationLoop defines a callback to call when animation loops
  76856. */
  76857. constructor(scene: Scene,
  76858. /** defines the target object */
  76859. target: any,
  76860. /** defines the starting frame number (default is 0) */
  76861. fromFrame?: number,
  76862. /** defines the ending frame number (default is 100) */
  76863. toFrame?: number,
  76864. /** defines if the animation must loop (default is false) */
  76865. loopAnimation?: boolean, speedRatio?: number,
  76866. /** defines a callback to call when animation ends if it is not looping */
  76867. onAnimationEnd?: (() => void) | null | undefined, animations?: Animation[],
  76868. /** defines a callback to call when animation loops */
  76869. onAnimationLoop?: (() => void) | null | undefined);
  76870. /**
  76871. * Synchronize and normalize current Animatable with a source Animatable
  76872. * This is useful when using animation weights and when animations are not of the same length
  76873. * @param root defines the root Animatable to synchronize with
  76874. * @returns the current Animatable
  76875. */
  76876. syncWith(root: Animatable): Animatable;
  76877. /**
  76878. * Gets the list of runtime animations
  76879. * @returns an array of RuntimeAnimation
  76880. */
  76881. getAnimations(): RuntimeAnimation[];
  76882. /**
  76883. * Adds more animations to the current animatable
  76884. * @param target defines the target of the animations
  76885. * @param animations defines the new animations to add
  76886. */
  76887. appendAnimations(target: any, animations: Animation[]): void;
  76888. /**
  76889. * Gets the source animation for a specific property
  76890. * @param property defines the propertyu to look for
  76891. * @returns null or the source animation for the given property
  76892. */
  76893. getAnimationByTargetProperty(property: string): Nullable<Animation>;
  76894. /**
  76895. * Gets the runtime animation for a specific property
  76896. * @param property defines the propertyu to look for
  76897. * @returns null or the runtime animation for the given property
  76898. */
  76899. getRuntimeAnimationByTargetProperty(property: string): Nullable<RuntimeAnimation>;
  76900. /**
  76901. * Resets the animatable to its original state
  76902. */
  76903. reset(): void;
  76904. /**
  76905. * Allows the animatable to blend with current running animations
  76906. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  76907. * @param blendingSpeed defines the blending speed to use
  76908. */
  76909. enableBlending(blendingSpeed: number): void;
  76910. /**
  76911. * Disable animation blending
  76912. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  76913. */
  76914. disableBlending(): void;
  76915. /**
  76916. * Jump directly to a given frame
  76917. * @param frame defines the frame to jump to
  76918. */
  76919. goToFrame(frame: number): void;
  76920. /**
  76921. * Pause the animation
  76922. */
  76923. pause(): void;
  76924. /**
  76925. * Restart the animation
  76926. */
  76927. restart(): void;
  76928. private _raiseOnAnimationEnd;
  76929. /**
  76930. * Stop and delete the current animation
  76931. * @param animationName defines a string used to only stop some of the runtime animations instead of all
  76932. * @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)
  76933. */
  76934. stop(animationName?: string, targetMask?: (target: any) => boolean): void;
  76935. /**
  76936. * Wait asynchronously for the animation to end
  76937. * @returns a promise which will be fullfilled when the animation ends
  76938. */
  76939. waitAsync(): Promise<Animatable>;
  76940. /** @hidden */
  76941. _animate(delay: number): boolean;
  76942. }
  76943. interface Scene {
  76944. /** @hidden */
  76945. _registerTargetForLateAnimationBinding(runtimeAnimation: RuntimeAnimation, originalValue: any): void;
  76946. /** @hidden */
  76947. _processLateAnimationBindingsForMatrices(holder: {
  76948. totalWeight: number;
  76949. animations: RuntimeAnimation[];
  76950. originalValue: Matrix;
  76951. }): any;
  76952. /** @hidden */
  76953. _processLateAnimationBindingsForQuaternions(holder: {
  76954. totalWeight: number;
  76955. animations: RuntimeAnimation[];
  76956. originalValue: Quaternion;
  76957. }, refQuaternion: Quaternion): Quaternion;
  76958. /** @hidden */
  76959. _processLateAnimationBindings(): void;
  76960. /**
  76961. * Will start the animation sequence of a given target
  76962. * @param target defines the target
  76963. * @param from defines from which frame should animation start
  76964. * @param to defines until which frame should animation run.
  76965. * @param weight defines the weight to apply to the animation (1.0 by default)
  76966. * @param loop defines if the animation loops
  76967. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  76968. * @param onAnimationEnd defines the function to be executed when the animation ends
  76969. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  76970. * @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
  76971. * @param onAnimationLoop defines the callback to call when an animation loops
  76972. * @returns the animatable object created for this animation
  76973. */
  76974. beginWeightedAnimation(target: any, from: number, to: number, weight: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, animatable?: Animatable, targetMask?: (target: any) => boolean, onAnimationLoop?: () => void): Animatable;
  76975. /**
  76976. * Will start the animation sequence of a given target
  76977. * @param target defines the target
  76978. * @param from defines from which frame should animation start
  76979. * @param to defines until which frame should animation run.
  76980. * @param loop defines if the animation loops
  76981. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  76982. * @param onAnimationEnd defines the function to be executed when the animation ends
  76983. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  76984. * @param stopCurrent defines if the current animations must be stopped first (true by default)
  76985. * @param targetMask defines if the target should be animate if animations are present (this is called recursively on descendant animatables regardless of return value)
  76986. * @param onAnimationLoop defines the callback to call when an animation loops
  76987. * @returns the animatable object created for this animation
  76988. */
  76989. beginAnimation(target: any, from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, animatable?: Animatable, stopCurrent?: boolean, targetMask?: (target: any) => boolean, onAnimationLoop?: () => void): Animatable;
  76990. /**
  76991. * Will start the animation sequence of a given target and its hierarchy
  76992. * @param target defines the target
  76993. * @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.
  76994. * @param from defines from which frame should animation start
  76995. * @param to defines until which frame should animation run.
  76996. * @param loop defines if the animation loops
  76997. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  76998. * @param onAnimationEnd defines the function to be executed when the animation ends
  76999. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  77000. * @param stopCurrent defines if the current animations must be stopped first (true by default)
  77001. * @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
  77002. * @param onAnimationLoop defines the callback to call when an animation loops
  77003. * @returns the list of created animatables
  77004. */
  77005. 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[];
  77006. /**
  77007. * Begin a new animation on a given node
  77008. * @param target defines the target where the animation will take place
  77009. * @param animations defines the list of animations to start
  77010. * @param from defines the initial value
  77011. * @param to defines the final value
  77012. * @param loop defines if you want animation to loop (off by default)
  77013. * @param speedRatio defines the speed ratio to apply to all animations
  77014. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  77015. * @param onAnimationLoop defines the callback to call when an animation loops
  77016. * @returns the list of created animatables
  77017. */
  77018. beginDirectAnimation(target: any, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, onAnimationLoop?: () => void): Animatable;
  77019. /**
  77020. * Begin a new animation on a given node and its hierarchy
  77021. * @param target defines the root node where the animation will take place
  77022. * @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.
  77023. * @param animations defines the list of animations to start
  77024. * @param from defines the initial value
  77025. * @param to defines the final value
  77026. * @param loop defines if you want animation to loop (off by default)
  77027. * @param speedRatio defines the speed ratio to apply to all animations
  77028. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  77029. * @param onAnimationLoop defines the callback to call when an animation loops
  77030. * @returns the list of animatables created for all nodes
  77031. */
  77032. beginDirectHierarchyAnimation(target: Node, directDescendantsOnly: boolean, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, onAnimationLoop?: () => void): Animatable[];
  77033. /**
  77034. * Gets the animatable associated with a specific target
  77035. * @param target defines the target of the animatable
  77036. * @returns the required animatable if found
  77037. */
  77038. getAnimatableByTarget(target: any): Nullable<Animatable>;
  77039. /**
  77040. * Gets all animatables associated with a given target
  77041. * @param target defines the target to look animatables for
  77042. * @returns an array of Animatables
  77043. */
  77044. getAllAnimatablesByTarget(target: any): Array<Animatable>;
  77045. /**
  77046. * Will stop the animation of the given target
  77047. * @param target - the target
  77048. * @param animationName - the name of the animation to stop (all animations will be stopped if both this and targetMask are empty)
  77049. * @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)
  77050. */
  77051. stopAnimation(target: any, animationName?: string, targetMask?: (target: any) => boolean): void;
  77052. /**
  77053. * Stops and removes all animations that have been applied to the scene
  77054. */
  77055. stopAllAnimations(): void;
  77056. }
  77057. interface Bone {
  77058. /**
  77059. * Copy an animation range from another bone
  77060. * @param source defines the source bone
  77061. * @param rangeName defines the range name to copy
  77062. * @param frameOffset defines the frame offset
  77063. * @param rescaleAsRequired defines if rescaling must be applied if required
  77064. * @param skelDimensionsRatio defines the scaling ratio
  77065. * @returns true if operation was successful
  77066. */
  77067. copyAnimationRange(source: Bone, rangeName: string, frameOffset: number, rescaleAsRequired: boolean, skelDimensionsRatio: Nullable<Vector3>): boolean;
  77068. }
  77069. }
  77070. declare module BABYLON {
  77071. /**
  77072. * Class used to handle skinning animations
  77073. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  77074. */
  77075. export class Skeleton implements IAnimatable {
  77076. /** defines the skeleton name */
  77077. name: string;
  77078. /** defines the skeleton Id */
  77079. id: string;
  77080. /**
  77081. * Defines the list of child bones
  77082. */
  77083. bones: Bone[];
  77084. /**
  77085. * Defines an estimate of the dimension of the skeleton at rest
  77086. */
  77087. dimensionsAtRest: Vector3;
  77088. /**
  77089. * Defines a boolean indicating if the root matrix is provided by meshes or by the current skeleton (this is the default value)
  77090. */
  77091. needInitialSkinMatrix: boolean;
  77092. /**
  77093. * Defines a mesh that override the matrix used to get the world matrix (null by default).
  77094. */
  77095. overrideMesh: Nullable<AbstractMesh>;
  77096. /**
  77097. * Gets the list of animations attached to this skeleton
  77098. */
  77099. animations: Array<Animation>;
  77100. private _scene;
  77101. private _isDirty;
  77102. private _transformMatrices;
  77103. private _transformMatrixTexture;
  77104. private _meshesWithPoseMatrix;
  77105. private _animatables;
  77106. private _identity;
  77107. private _synchronizedWithMesh;
  77108. private _ranges;
  77109. private _lastAbsoluteTransformsUpdateId;
  77110. private _canUseTextureForBones;
  77111. private _uniqueId;
  77112. /** @hidden */
  77113. _numBonesWithLinkedTransformNode: number;
  77114. /**
  77115. * Specifies if the skeleton should be serialized
  77116. */
  77117. doNotSerialize: boolean;
  77118. private _useTextureToStoreBoneMatrices;
  77119. /**
  77120. * Gets or sets a boolean indicating that bone matrices should be stored as a texture instead of using shader uniforms (default is true).
  77121. * Please note that this option is not available when needInitialSkinMatrix === true or if the hardware does not support it
  77122. */
  77123. useTextureToStoreBoneMatrices: boolean;
  77124. private _animationPropertiesOverride;
  77125. /**
  77126. * Gets or sets the animation properties override
  77127. */
  77128. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  77129. /**
  77130. * List of inspectable custom properties (used by the Inspector)
  77131. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  77132. */
  77133. inspectableCustomProperties: IInspectable[];
  77134. /**
  77135. * An observable triggered before computing the skeleton's matrices
  77136. */
  77137. onBeforeComputeObservable: Observable<Skeleton>;
  77138. /**
  77139. * Gets a boolean indicating that the skeleton effectively stores matrices into a texture
  77140. */
  77141. readonly isUsingTextureForMatrices: boolean;
  77142. /**
  77143. * Gets the unique ID of this skeleton
  77144. */
  77145. readonly uniqueId: number;
  77146. /**
  77147. * Creates a new skeleton
  77148. * @param name defines the skeleton name
  77149. * @param id defines the skeleton Id
  77150. * @param scene defines the hosting scene
  77151. */
  77152. constructor(
  77153. /** defines the skeleton name */
  77154. name: string,
  77155. /** defines the skeleton Id */
  77156. id: string, scene: Scene);
  77157. /**
  77158. * Gets the current object class name.
  77159. * @return the class name
  77160. */
  77161. getClassName(): string;
  77162. /**
  77163. * Returns an array containing the root bones
  77164. * @returns an array containing the root bones
  77165. */
  77166. getChildren(): Array<Bone>;
  77167. /**
  77168. * Gets the list of transform matrices to send to shaders (one matrix per bone)
  77169. * @param mesh defines the mesh to use to get the root matrix (if needInitialSkinMatrix === true)
  77170. * @returns a Float32Array containing matrices data
  77171. */
  77172. getTransformMatrices(mesh: AbstractMesh): Float32Array;
  77173. /**
  77174. * Gets the list of transform matrices to send to shaders inside a texture (one matrix per bone)
  77175. * @returns a raw texture containing the data
  77176. */
  77177. getTransformMatrixTexture(): Nullable<RawTexture>;
  77178. /**
  77179. * Gets the current hosting scene
  77180. * @returns a scene object
  77181. */
  77182. getScene(): Scene;
  77183. /**
  77184. * Gets a string representing the current skeleton data
  77185. * @param fullDetails defines a boolean indicating if we want a verbose version
  77186. * @returns a string representing the current skeleton data
  77187. */
  77188. toString(fullDetails?: boolean): string;
  77189. /**
  77190. * Get bone's index searching by name
  77191. * @param name defines bone's name to search for
  77192. * @return the indice of the bone. Returns -1 if not found
  77193. */
  77194. getBoneIndexByName(name: string): number;
  77195. /**
  77196. * Creater a new animation range
  77197. * @param name defines the name of the range
  77198. * @param from defines the start key
  77199. * @param to defines the end key
  77200. */
  77201. createAnimationRange(name: string, from: number, to: number): void;
  77202. /**
  77203. * Delete a specific animation range
  77204. * @param name defines the name of the range
  77205. * @param deleteFrames defines if frames must be removed as well
  77206. */
  77207. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  77208. /**
  77209. * Gets a specific animation range
  77210. * @param name defines the name of the range to look for
  77211. * @returns the requested animation range or null if not found
  77212. */
  77213. getAnimationRange(name: string): Nullable<AnimationRange>;
  77214. /**
  77215. * Gets the list of all animation ranges defined on this skeleton
  77216. * @returns an array
  77217. */
  77218. getAnimationRanges(): Nullable<AnimationRange>[];
  77219. /**
  77220. * Copy animation range from a source skeleton.
  77221. * This is not for a complete retargeting, only between very similar skeleton's with only possible bone length differences
  77222. * @param source defines the source skeleton
  77223. * @param name defines the name of the range to copy
  77224. * @param rescaleAsRequired defines if rescaling must be applied if required
  77225. * @returns true if operation was successful
  77226. */
  77227. copyAnimationRange(source: Skeleton, name: string, rescaleAsRequired?: boolean): boolean;
  77228. /**
  77229. * Forces the skeleton to go to rest pose
  77230. */
  77231. returnToRest(): void;
  77232. private _getHighestAnimationFrame;
  77233. /**
  77234. * Begin a specific animation range
  77235. * @param name defines the name of the range to start
  77236. * @param loop defines if looping must be turned on (false by default)
  77237. * @param speedRatio defines the speed ratio to apply (1 by default)
  77238. * @param onAnimationEnd defines a callback which will be called when animation will end
  77239. * @returns a new animatable
  77240. */
  77241. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  77242. /** @hidden */
  77243. _markAsDirty(): void;
  77244. /** @hidden */
  77245. _registerMeshWithPoseMatrix(mesh: AbstractMesh): void;
  77246. /** @hidden */
  77247. _unregisterMeshWithPoseMatrix(mesh: AbstractMesh): void;
  77248. private _computeTransformMatrices;
  77249. /**
  77250. * Build all resources required to render a skeleton
  77251. */
  77252. prepare(): void;
  77253. /**
  77254. * Gets the list of animatables currently running for this skeleton
  77255. * @returns an array of animatables
  77256. */
  77257. getAnimatables(): IAnimatable[];
  77258. /**
  77259. * Clone the current skeleton
  77260. * @param name defines the name of the new skeleton
  77261. * @param id defines the id of the enw skeleton
  77262. * @returns the new skeleton
  77263. */
  77264. clone(name: string, id: string): Skeleton;
  77265. /**
  77266. * Enable animation blending for this skeleton
  77267. * @param blendingSpeed defines the blending speed to apply
  77268. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  77269. */
  77270. enableBlending(blendingSpeed?: number): void;
  77271. /**
  77272. * Releases all resources associated with the current skeleton
  77273. */
  77274. dispose(): void;
  77275. /**
  77276. * Serialize the skeleton in a JSON object
  77277. * @returns a JSON object
  77278. */
  77279. serialize(): any;
  77280. /**
  77281. * Creates a new skeleton from serialized data
  77282. * @param parsedSkeleton defines the serialized data
  77283. * @param scene defines the hosting scene
  77284. * @returns a new skeleton
  77285. */
  77286. static Parse(parsedSkeleton: any, scene: Scene): Skeleton;
  77287. /**
  77288. * Compute all node absolute transforms
  77289. * @param forceUpdate defines if computation must be done even if cache is up to date
  77290. */
  77291. computeAbsoluteTransforms(forceUpdate?: boolean): void;
  77292. /**
  77293. * Gets the root pose matrix
  77294. * @returns a matrix
  77295. */
  77296. getPoseMatrix(): Nullable<Matrix>;
  77297. /**
  77298. * Sorts bones per internal index
  77299. */
  77300. sortBones(): void;
  77301. private _sortBones;
  77302. }
  77303. }
  77304. declare module BABYLON {
  77305. /**
  77306. * Defines a target to use with MorphTargetManager
  77307. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  77308. */
  77309. export class MorphTarget implements IAnimatable {
  77310. /** defines the name of the target */
  77311. name: string;
  77312. /**
  77313. * Gets or sets the list of animations
  77314. */
  77315. animations: Animation[];
  77316. private _scene;
  77317. private _positions;
  77318. private _normals;
  77319. private _tangents;
  77320. private _influence;
  77321. /**
  77322. * Observable raised when the influence changes
  77323. */
  77324. onInfluenceChanged: Observable<boolean>;
  77325. /** @hidden */
  77326. _onDataLayoutChanged: Observable<void>;
  77327. /**
  77328. * Gets or sets the influence of this target (ie. its weight in the overall morphing)
  77329. */
  77330. influence: number;
  77331. /**
  77332. * Gets or sets the id of the morph Target
  77333. */
  77334. id: string;
  77335. private _animationPropertiesOverride;
  77336. /**
  77337. * Gets or sets the animation properties override
  77338. */
  77339. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  77340. /**
  77341. * Creates a new MorphTarget
  77342. * @param name defines the name of the target
  77343. * @param influence defines the influence to use
  77344. * @param scene defines the scene the morphtarget belongs to
  77345. */
  77346. constructor(
  77347. /** defines the name of the target */
  77348. name: string, influence?: number, scene?: Nullable<Scene>);
  77349. /**
  77350. * Gets a boolean defining if the target contains position data
  77351. */
  77352. readonly hasPositions: boolean;
  77353. /**
  77354. * Gets a boolean defining if the target contains normal data
  77355. */
  77356. readonly hasNormals: boolean;
  77357. /**
  77358. * Gets a boolean defining if the target contains tangent data
  77359. */
  77360. readonly hasTangents: boolean;
  77361. /**
  77362. * Affects position data to this target
  77363. * @param data defines the position data to use
  77364. */
  77365. setPositions(data: Nullable<FloatArray>): void;
  77366. /**
  77367. * Gets the position data stored in this target
  77368. * @returns a FloatArray containing the position data (or null if not present)
  77369. */
  77370. getPositions(): Nullable<FloatArray>;
  77371. /**
  77372. * Affects normal data to this target
  77373. * @param data defines the normal data to use
  77374. */
  77375. setNormals(data: Nullable<FloatArray>): void;
  77376. /**
  77377. * Gets the normal data stored in this target
  77378. * @returns a FloatArray containing the normal data (or null if not present)
  77379. */
  77380. getNormals(): Nullable<FloatArray>;
  77381. /**
  77382. * Affects tangent data to this target
  77383. * @param data defines the tangent data to use
  77384. */
  77385. setTangents(data: Nullable<FloatArray>): void;
  77386. /**
  77387. * Gets the tangent data stored in this target
  77388. * @returns a FloatArray containing the tangent data (or null if not present)
  77389. */
  77390. getTangents(): Nullable<FloatArray>;
  77391. /**
  77392. * Serializes the current target into a Serialization object
  77393. * @returns the serialized object
  77394. */
  77395. serialize(): any;
  77396. /**
  77397. * Returns the string "MorphTarget"
  77398. * @returns "MorphTarget"
  77399. */
  77400. getClassName(): string;
  77401. /**
  77402. * Creates a new target from serialized data
  77403. * @param serializationObject defines the serialized data to use
  77404. * @returns a new MorphTarget
  77405. */
  77406. static Parse(serializationObject: any): MorphTarget;
  77407. /**
  77408. * Creates a MorphTarget from mesh data
  77409. * @param mesh defines the source mesh
  77410. * @param name defines the name to use for the new target
  77411. * @param influence defines the influence to attach to the target
  77412. * @returns a new MorphTarget
  77413. */
  77414. static FromMesh(mesh: AbstractMesh, name?: string, influence?: number): MorphTarget;
  77415. }
  77416. }
  77417. declare module BABYLON {
  77418. /**
  77419. * This class is used to deform meshes using morphing between different targets
  77420. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  77421. */
  77422. export class MorphTargetManager {
  77423. private _targets;
  77424. private _targetInfluenceChangedObservers;
  77425. private _targetDataLayoutChangedObservers;
  77426. private _activeTargets;
  77427. private _scene;
  77428. private _influences;
  77429. private _supportsNormals;
  77430. private _supportsTangents;
  77431. private _vertexCount;
  77432. private _uniqueId;
  77433. private _tempInfluences;
  77434. /**
  77435. * Creates a new MorphTargetManager
  77436. * @param scene defines the current scene
  77437. */
  77438. constructor(scene?: Nullable<Scene>);
  77439. /**
  77440. * Gets the unique ID of this manager
  77441. */
  77442. readonly uniqueId: number;
  77443. /**
  77444. * Gets the number of vertices handled by this manager
  77445. */
  77446. readonly vertexCount: number;
  77447. /**
  77448. * Gets a boolean indicating if this manager supports morphing of normals
  77449. */
  77450. readonly supportsNormals: boolean;
  77451. /**
  77452. * Gets a boolean indicating if this manager supports morphing of tangents
  77453. */
  77454. readonly supportsTangents: boolean;
  77455. /**
  77456. * Gets the number of targets stored in this manager
  77457. */
  77458. readonly numTargets: number;
  77459. /**
  77460. * Gets the number of influencers (ie. the number of targets with influences > 0)
  77461. */
  77462. readonly numInfluencers: number;
  77463. /**
  77464. * Gets the list of influences (one per target)
  77465. */
  77466. readonly influences: Float32Array;
  77467. /**
  77468. * Gets the active target at specified index. An active target is a target with an influence > 0
  77469. * @param index defines the index to check
  77470. * @returns the requested target
  77471. */
  77472. getActiveTarget(index: number): MorphTarget;
  77473. /**
  77474. * Gets the target at specified index
  77475. * @param index defines the index to check
  77476. * @returns the requested target
  77477. */
  77478. getTarget(index: number): MorphTarget;
  77479. /**
  77480. * Add a new target to this manager
  77481. * @param target defines the target to add
  77482. */
  77483. addTarget(target: MorphTarget): void;
  77484. /**
  77485. * Removes a target from the manager
  77486. * @param target defines the target to remove
  77487. */
  77488. removeTarget(target: MorphTarget): void;
  77489. /**
  77490. * Serializes the current manager into a Serialization object
  77491. * @returns the serialized object
  77492. */
  77493. serialize(): any;
  77494. private _syncActiveTargets;
  77495. /**
  77496. * Syncrhonize the targets with all the meshes using this morph target manager
  77497. */
  77498. synchronize(): void;
  77499. /**
  77500. * Creates a new MorphTargetManager from serialized data
  77501. * @param serializationObject defines the serialized data
  77502. * @param scene defines the hosting scene
  77503. * @returns the new MorphTargetManager
  77504. */
  77505. static Parse(serializationObject: any, scene: Scene): MorphTargetManager;
  77506. }
  77507. }
  77508. declare module BABYLON {
  77509. /**
  77510. * Mesh representing the gorund
  77511. */
  77512. export class GroundMesh extends Mesh {
  77513. /** If octree should be generated */
  77514. generateOctree: boolean;
  77515. private _heightQuads;
  77516. /** @hidden */
  77517. _subdivisionsX: number;
  77518. /** @hidden */
  77519. _subdivisionsY: number;
  77520. /** @hidden */
  77521. _width: number;
  77522. /** @hidden */
  77523. _height: number;
  77524. /** @hidden */
  77525. _minX: number;
  77526. /** @hidden */
  77527. _maxX: number;
  77528. /** @hidden */
  77529. _minZ: number;
  77530. /** @hidden */
  77531. _maxZ: number;
  77532. constructor(name: string, scene: Scene);
  77533. /**
  77534. * "GroundMesh"
  77535. * @returns "GroundMesh"
  77536. */
  77537. getClassName(): string;
  77538. /**
  77539. * The minimum of x and y subdivisions
  77540. */
  77541. readonly subdivisions: number;
  77542. /**
  77543. * X subdivisions
  77544. */
  77545. readonly subdivisionsX: number;
  77546. /**
  77547. * Y subdivisions
  77548. */
  77549. readonly subdivisionsY: number;
  77550. /**
  77551. * This function will update an octree to help to select the right submeshes for rendering, picking and collision computations.
  77552. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  77553. * @param chunksCount the number of subdivisions for x and y
  77554. * @param octreeBlocksSize (Default: 32)
  77555. */
  77556. optimize(chunksCount: number, octreeBlocksSize?: number): void;
  77557. /**
  77558. * Returns a height (y) value in the Worl system :
  77559. * the ground altitude at the coordinates (x, z) expressed in the World system.
  77560. * @param x x coordinate
  77561. * @param z z coordinate
  77562. * @returns the ground y position if (x, z) are outside the ground surface.
  77563. */
  77564. getHeightAtCoordinates(x: number, z: number): number;
  77565. /**
  77566. * Returns a normalized vector (Vector3) orthogonal to the ground
  77567. * at the ground coordinates (x, z) expressed in the World system.
  77568. * @param x x coordinate
  77569. * @param z z coordinate
  77570. * @returns Vector3(0.0, 1.0, 0.0) if (x, z) are outside the ground surface.
  77571. */
  77572. getNormalAtCoordinates(x: number, z: number): Vector3;
  77573. /**
  77574. * Updates the Vector3 passed a reference with a normalized vector orthogonal to the ground
  77575. * at the ground coordinates (x, z) expressed in the World system.
  77576. * Doesn't uptade the reference Vector3 if (x, z) are outside the ground surface.
  77577. * @param x x coordinate
  77578. * @param z z coordinate
  77579. * @param ref vector to store the result
  77580. * @returns the GroundMesh.
  77581. */
  77582. getNormalAtCoordinatesToRef(x: number, z: number, ref: Vector3): GroundMesh;
  77583. /**
  77584. * Force the heights to be recomputed for getHeightAtCoordinates() or getNormalAtCoordinates()
  77585. * if the ground has been updated.
  77586. * This can be used in the render loop.
  77587. * @returns the GroundMesh.
  77588. */
  77589. updateCoordinateHeights(): GroundMesh;
  77590. private _getFacetAt;
  77591. private _initHeightQuads;
  77592. private _computeHeightQuads;
  77593. /**
  77594. * Serializes this ground mesh
  77595. * @param serializationObject object to write serialization to
  77596. */
  77597. serialize(serializationObject: any): void;
  77598. /**
  77599. * Parses a serialized ground mesh
  77600. * @param parsedMesh the serialized mesh
  77601. * @param scene the scene to create the ground mesh in
  77602. * @returns the created ground mesh
  77603. */
  77604. static Parse(parsedMesh: any, scene: Scene): GroundMesh;
  77605. }
  77606. }
  77607. declare module BABYLON {
  77608. /**
  77609. * Interface for Physics-Joint data
  77610. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  77611. */
  77612. export interface PhysicsJointData {
  77613. /**
  77614. * The main pivot of the joint
  77615. */
  77616. mainPivot?: Vector3;
  77617. /**
  77618. * The connected pivot of the joint
  77619. */
  77620. connectedPivot?: Vector3;
  77621. /**
  77622. * The main axis of the joint
  77623. */
  77624. mainAxis?: Vector3;
  77625. /**
  77626. * The connected axis of the joint
  77627. */
  77628. connectedAxis?: Vector3;
  77629. /**
  77630. * The collision of the joint
  77631. */
  77632. collision?: boolean;
  77633. /**
  77634. * Native Oimo/Cannon/Energy data
  77635. */
  77636. nativeParams?: any;
  77637. }
  77638. /**
  77639. * This is a holder class for the physics joint created by the physics plugin
  77640. * It holds a set of functions to control the underlying joint
  77641. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  77642. */
  77643. export class PhysicsJoint {
  77644. /**
  77645. * The type of the physics joint
  77646. */
  77647. type: number;
  77648. /**
  77649. * The data for the physics joint
  77650. */
  77651. jointData: PhysicsJointData;
  77652. private _physicsJoint;
  77653. protected _physicsPlugin: IPhysicsEnginePlugin;
  77654. /**
  77655. * Initializes the physics joint
  77656. * @param type The type of the physics joint
  77657. * @param jointData The data for the physics joint
  77658. */
  77659. constructor(
  77660. /**
  77661. * The type of the physics joint
  77662. */
  77663. type: number,
  77664. /**
  77665. * The data for the physics joint
  77666. */
  77667. jointData: PhysicsJointData);
  77668. /**
  77669. * Gets the physics joint
  77670. */
  77671. /**
  77672. * Sets the physics joint
  77673. */
  77674. physicsJoint: any;
  77675. /**
  77676. * Sets the physics plugin
  77677. */
  77678. physicsPlugin: IPhysicsEnginePlugin;
  77679. /**
  77680. * Execute a function that is physics-plugin specific.
  77681. * @param {Function} func the function that will be executed.
  77682. * It accepts two parameters: the physics world and the physics joint
  77683. */
  77684. executeNativeFunction(func: (world: any, physicsJoint: any) => void): void;
  77685. /**
  77686. * Distance-Joint type
  77687. */
  77688. static DistanceJoint: number;
  77689. /**
  77690. * Hinge-Joint type
  77691. */
  77692. static HingeJoint: number;
  77693. /**
  77694. * Ball-and-Socket joint type
  77695. */
  77696. static BallAndSocketJoint: number;
  77697. /**
  77698. * Wheel-Joint type
  77699. */
  77700. static WheelJoint: number;
  77701. /**
  77702. * Slider-Joint type
  77703. */
  77704. static SliderJoint: number;
  77705. /**
  77706. * Prismatic-Joint type
  77707. */
  77708. static PrismaticJoint: number;
  77709. /**
  77710. * Universal-Joint type
  77711. * ENERGY FTW! (compare with this - @see http://ode-wiki.org/wiki/index.php?title=Manual:_Joint_Types_and_Functions)
  77712. */
  77713. static UniversalJoint: number;
  77714. /**
  77715. * Hinge-Joint 2 type
  77716. */
  77717. static Hinge2Joint: number;
  77718. /**
  77719. * Point to Point Joint type. Similar to a Ball-Joint. Different in parameters
  77720. */
  77721. static PointToPointJoint: number;
  77722. /**
  77723. * Spring-Joint type
  77724. */
  77725. static SpringJoint: number;
  77726. /**
  77727. * Lock-Joint type
  77728. */
  77729. static LockJoint: number;
  77730. }
  77731. /**
  77732. * A class representing a physics distance joint
  77733. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  77734. */
  77735. export class DistanceJoint extends PhysicsJoint {
  77736. /**
  77737. *
  77738. * @param jointData The data for the Distance-Joint
  77739. */
  77740. constructor(jointData: DistanceJointData);
  77741. /**
  77742. * Update the predefined distance.
  77743. * @param maxDistance The maximum preferred distance
  77744. * @param minDistance The minimum preferred distance
  77745. */
  77746. updateDistance(maxDistance: number, minDistance?: number): void;
  77747. }
  77748. /**
  77749. * Represents a Motor-Enabled Joint
  77750. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  77751. */
  77752. export class MotorEnabledJoint extends PhysicsJoint implements IMotorEnabledJoint {
  77753. /**
  77754. * Initializes the Motor-Enabled Joint
  77755. * @param type The type of the joint
  77756. * @param jointData The physica joint data for the joint
  77757. */
  77758. constructor(type: number, jointData: PhysicsJointData);
  77759. /**
  77760. * Set the motor values.
  77761. * Attention, this function is plugin specific. Engines won't react 100% the same.
  77762. * @param force the force to apply
  77763. * @param maxForce max force for this motor.
  77764. */
  77765. setMotor(force?: number, maxForce?: number): void;
  77766. /**
  77767. * Set the motor's limits.
  77768. * Attention, this function is plugin specific. Engines won't react 100% the same.
  77769. * @param upperLimit The upper limit of the motor
  77770. * @param lowerLimit The lower limit of the motor
  77771. */
  77772. setLimit(upperLimit: number, lowerLimit?: number): void;
  77773. }
  77774. /**
  77775. * This class represents a single physics Hinge-Joint
  77776. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  77777. */
  77778. export class HingeJoint extends MotorEnabledJoint {
  77779. /**
  77780. * Initializes the Hinge-Joint
  77781. * @param jointData The joint data for the Hinge-Joint
  77782. */
  77783. constructor(jointData: PhysicsJointData);
  77784. /**
  77785. * Set the motor values.
  77786. * Attention, this function is plugin specific. Engines won't react 100% the same.
  77787. * @param {number} force the force to apply
  77788. * @param {number} maxForce max force for this motor.
  77789. */
  77790. setMotor(force?: number, maxForce?: number): void;
  77791. /**
  77792. * Set the motor's limits.
  77793. * Attention, this function is plugin specific. Engines won't react 100% the same.
  77794. * @param upperLimit The upper limit of the motor
  77795. * @param lowerLimit The lower limit of the motor
  77796. */
  77797. setLimit(upperLimit: number, lowerLimit?: number): void;
  77798. }
  77799. /**
  77800. * This class represents a dual hinge physics joint (same as wheel joint)
  77801. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  77802. */
  77803. export class Hinge2Joint extends MotorEnabledJoint {
  77804. /**
  77805. * Initializes the Hinge2-Joint
  77806. * @param jointData The joint data for the Hinge2-Joint
  77807. */
  77808. constructor(jointData: PhysicsJointData);
  77809. /**
  77810. * Set the motor values.
  77811. * Attention, this function is plugin specific. Engines won't react 100% the same.
  77812. * @param {number} targetSpeed the speed the motor is to reach
  77813. * @param {number} maxForce max force for this motor.
  77814. * @param {motorIndex} the motor's index, 0 or 1.
  77815. */
  77816. setMotor(targetSpeed?: number, maxForce?: number, motorIndex?: number): void;
  77817. /**
  77818. * Set the motor limits.
  77819. * Attention, this function is plugin specific. Engines won't react 100% the same.
  77820. * @param {number} upperLimit the upper limit
  77821. * @param {number} lowerLimit lower limit
  77822. * @param {motorIndex} the motor's index, 0 or 1.
  77823. */
  77824. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  77825. }
  77826. /**
  77827. * Interface for a motor enabled joint
  77828. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  77829. */
  77830. export interface IMotorEnabledJoint {
  77831. /**
  77832. * Physics joint
  77833. */
  77834. physicsJoint: any;
  77835. /**
  77836. * Sets the motor of the motor-enabled joint
  77837. * @param force The force of the motor
  77838. * @param maxForce The maximum force of the motor
  77839. * @param motorIndex The index of the motor
  77840. */
  77841. setMotor(force?: number, maxForce?: number, motorIndex?: number): void;
  77842. /**
  77843. * Sets the limit of the motor
  77844. * @param upperLimit The upper limit of the motor
  77845. * @param lowerLimit The lower limit of the motor
  77846. * @param motorIndex The index of the motor
  77847. */
  77848. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  77849. }
  77850. /**
  77851. * Joint data for a Distance-Joint
  77852. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  77853. */
  77854. export interface DistanceJointData extends PhysicsJointData {
  77855. /**
  77856. * Max distance the 2 joint objects can be apart
  77857. */
  77858. maxDistance: number;
  77859. }
  77860. /**
  77861. * Joint data from a spring joint
  77862. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  77863. */
  77864. export interface SpringJointData extends PhysicsJointData {
  77865. /**
  77866. * Length of the spring
  77867. */
  77868. length: number;
  77869. /**
  77870. * Stiffness of the spring
  77871. */
  77872. stiffness: number;
  77873. /**
  77874. * Damping of the spring
  77875. */
  77876. damping: number;
  77877. /** this callback will be called when applying the force to the impostors. */
  77878. forceApplicationCallback: () => void;
  77879. }
  77880. }
  77881. declare module BABYLON {
  77882. /**
  77883. * Holds the data for the raycast result
  77884. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  77885. */
  77886. export class PhysicsRaycastResult {
  77887. private _hasHit;
  77888. private _hitDistance;
  77889. private _hitNormalWorld;
  77890. private _hitPointWorld;
  77891. private _rayFromWorld;
  77892. private _rayToWorld;
  77893. /**
  77894. * Gets if there was a hit
  77895. */
  77896. readonly hasHit: boolean;
  77897. /**
  77898. * Gets the distance from the hit
  77899. */
  77900. readonly hitDistance: number;
  77901. /**
  77902. * Gets the hit normal/direction in the world
  77903. */
  77904. readonly hitNormalWorld: Vector3;
  77905. /**
  77906. * Gets the hit point in the world
  77907. */
  77908. readonly hitPointWorld: Vector3;
  77909. /**
  77910. * Gets the ray "start point" of the ray in the world
  77911. */
  77912. readonly rayFromWorld: Vector3;
  77913. /**
  77914. * Gets the ray "end point" of the ray in the world
  77915. */
  77916. readonly rayToWorld: Vector3;
  77917. /**
  77918. * Sets the hit data (normal & point in world space)
  77919. * @param hitNormalWorld defines the normal in world space
  77920. * @param hitPointWorld defines the point in world space
  77921. */
  77922. setHitData(hitNormalWorld: IXYZ, hitPointWorld: IXYZ): void;
  77923. /**
  77924. * Sets the distance from the start point to the hit point
  77925. * @param distance
  77926. */
  77927. setHitDistance(distance: number): void;
  77928. /**
  77929. * Calculates the distance manually
  77930. */
  77931. calculateHitDistance(): void;
  77932. /**
  77933. * Resets all the values to default
  77934. * @param from The from point on world space
  77935. * @param to The to point on world space
  77936. */
  77937. reset(from?: Vector3, to?: Vector3): void;
  77938. }
  77939. /**
  77940. * Interface for the size containing width and height
  77941. */
  77942. interface IXYZ {
  77943. /**
  77944. * X
  77945. */
  77946. x: number;
  77947. /**
  77948. * Y
  77949. */
  77950. y: number;
  77951. /**
  77952. * Z
  77953. */
  77954. z: number;
  77955. }
  77956. }
  77957. declare module BABYLON {
  77958. /**
  77959. * Interface used to describe a physics joint
  77960. */
  77961. export interface PhysicsImpostorJoint {
  77962. /** Defines the main impostor to which the joint is linked */
  77963. mainImpostor: PhysicsImpostor;
  77964. /** Defines the impostor that is connected to the main impostor using this joint */
  77965. connectedImpostor: PhysicsImpostor;
  77966. /** Defines the joint itself */
  77967. joint: PhysicsJoint;
  77968. }
  77969. /** @hidden */
  77970. export interface IPhysicsEnginePlugin {
  77971. world: any;
  77972. name: string;
  77973. setGravity(gravity: Vector3): void;
  77974. setTimeStep(timeStep: number): void;
  77975. getTimeStep(): number;
  77976. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  77977. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  77978. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  77979. generatePhysicsBody(impostor: PhysicsImpostor): void;
  77980. removePhysicsBody(impostor: PhysicsImpostor): void;
  77981. generateJoint(joint: PhysicsImpostorJoint): void;
  77982. removeJoint(joint: PhysicsImpostorJoint): void;
  77983. isSupported(): boolean;
  77984. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  77985. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  77986. setLinearVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  77987. setAngularVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  77988. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  77989. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  77990. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  77991. getBodyMass(impostor: PhysicsImpostor): number;
  77992. getBodyFriction(impostor: PhysicsImpostor): number;
  77993. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  77994. getBodyRestitution(impostor: PhysicsImpostor): number;
  77995. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  77996. getBodyPressure?(impostor: PhysicsImpostor): number;
  77997. setBodyPressure?(impostor: PhysicsImpostor, pressure: number): void;
  77998. getBodyStiffness?(impostor: PhysicsImpostor): number;
  77999. setBodyStiffness?(impostor: PhysicsImpostor, stiffness: number): void;
  78000. getBodyVelocityIterations?(impostor: PhysicsImpostor): number;
  78001. setBodyVelocityIterations?(impostor: PhysicsImpostor, velocityIterations: number): void;
  78002. getBodyPositionIterations?(impostor: PhysicsImpostor): number;
  78003. setBodyPositionIterations?(impostor: PhysicsImpostor, positionIterations: number): void;
  78004. appendAnchor?(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, width: number, height: number, influence: number, noCollisionBetweenLinkedBodies: boolean): void;
  78005. appendHook?(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, length: number, influence: number, noCollisionBetweenLinkedBodies: boolean): void;
  78006. sleepBody(impostor: PhysicsImpostor): void;
  78007. wakeUpBody(impostor: PhysicsImpostor): void;
  78008. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  78009. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  78010. setMotor(joint: IMotorEnabledJoint, speed: number, maxForce?: number, motorIndex?: number): void;
  78011. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  78012. getRadius(impostor: PhysicsImpostor): number;
  78013. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  78014. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  78015. dispose(): void;
  78016. }
  78017. /**
  78018. * Interface used to define a physics engine
  78019. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  78020. */
  78021. export interface IPhysicsEngine {
  78022. /**
  78023. * Gets the gravity vector used by the simulation
  78024. */
  78025. gravity: Vector3;
  78026. /**
  78027. * Sets the gravity vector used by the simulation
  78028. * @param gravity defines the gravity vector to use
  78029. */
  78030. setGravity(gravity: Vector3): void;
  78031. /**
  78032. * Set the time step of the physics engine.
  78033. * Default is 1/60.
  78034. * To slow it down, enter 1/600 for example.
  78035. * To speed it up, 1/30
  78036. * @param newTimeStep the new timestep to apply to this world.
  78037. */
  78038. setTimeStep(newTimeStep: number): void;
  78039. /**
  78040. * Get the time step of the physics engine.
  78041. * @returns the current time step
  78042. */
  78043. getTimeStep(): number;
  78044. /**
  78045. * Release all resources
  78046. */
  78047. dispose(): void;
  78048. /**
  78049. * Gets the name of the current physics plugin
  78050. * @returns the name of the plugin
  78051. */
  78052. getPhysicsPluginName(): string;
  78053. /**
  78054. * Adding a new impostor for the impostor tracking.
  78055. * This will be done by the impostor itself.
  78056. * @param impostor the impostor to add
  78057. */
  78058. addImpostor(impostor: PhysicsImpostor): void;
  78059. /**
  78060. * Remove an impostor from the engine.
  78061. * This impostor and its mesh will not longer be updated by the physics engine.
  78062. * @param impostor the impostor to remove
  78063. */
  78064. removeImpostor(impostor: PhysicsImpostor): void;
  78065. /**
  78066. * Add a joint to the physics engine
  78067. * @param mainImpostor defines the main impostor to which the joint is added.
  78068. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  78069. * @param joint defines the joint that will connect both impostors.
  78070. */
  78071. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  78072. /**
  78073. * Removes a joint from the simulation
  78074. * @param mainImpostor defines the impostor used with the joint
  78075. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  78076. * @param joint defines the joint to remove
  78077. */
  78078. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  78079. /**
  78080. * Gets the current plugin used to run the simulation
  78081. * @returns current plugin
  78082. */
  78083. getPhysicsPlugin(): IPhysicsEnginePlugin;
  78084. /**
  78085. * Gets the list of physic impostors
  78086. * @returns an array of PhysicsImpostor
  78087. */
  78088. getImpostors(): Array<PhysicsImpostor>;
  78089. /**
  78090. * Gets the impostor for a physics enabled object
  78091. * @param object defines the object impersonated by the impostor
  78092. * @returns the PhysicsImpostor or null if not found
  78093. */
  78094. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  78095. /**
  78096. * Gets the impostor for a physics body object
  78097. * @param body defines physics body used by the impostor
  78098. * @returns the PhysicsImpostor or null if not found
  78099. */
  78100. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  78101. /**
  78102. * Does a raycast in the physics world
  78103. * @param from when should the ray start?
  78104. * @param to when should the ray end?
  78105. * @returns PhysicsRaycastResult
  78106. */
  78107. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  78108. /**
  78109. * Called by the scene. No need to call it.
  78110. * @param delta defines the timespam between frames
  78111. */
  78112. _step(delta: number): void;
  78113. }
  78114. }
  78115. declare module BABYLON {
  78116. /**
  78117. * The interface for the physics imposter parameters
  78118. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  78119. */
  78120. export interface PhysicsImpostorParameters {
  78121. /**
  78122. * The mass of the physics imposter
  78123. */
  78124. mass: number;
  78125. /**
  78126. * The friction of the physics imposter
  78127. */
  78128. friction?: number;
  78129. /**
  78130. * The coefficient of restitution of the physics imposter
  78131. */
  78132. restitution?: number;
  78133. /**
  78134. * The native options of the physics imposter
  78135. */
  78136. nativeOptions?: any;
  78137. /**
  78138. * Specifies if the parent should be ignored
  78139. */
  78140. ignoreParent?: boolean;
  78141. /**
  78142. * Specifies if bi-directional transformations should be disabled
  78143. */
  78144. disableBidirectionalTransformation?: boolean;
  78145. /**
  78146. * The pressure inside the physics imposter, soft object only
  78147. */
  78148. pressure?: number;
  78149. /**
  78150. * The stiffness the physics imposter, soft object only
  78151. */
  78152. stiffness?: number;
  78153. /**
  78154. * The number of iterations used in maintaining consistent vertex velocities, soft object only
  78155. */
  78156. velocityIterations?: number;
  78157. /**
  78158. * The number of iterations used in maintaining consistent vertex positions, soft object only
  78159. */
  78160. positionIterations?: number;
  78161. /**
  78162. * The number used to fix points on a cloth (0, 1, 2, 4, 8) or rope (0, 1, 2) only
  78163. * 0 None, 1, back left or top, 2, back right or bottom, 4, front left, 8, front right
  78164. * Add to fix multiple points
  78165. */
  78166. fixedPoints?: number;
  78167. /**
  78168. * The collision margin around a soft object
  78169. */
  78170. margin?: number;
  78171. /**
  78172. * The collision margin around a soft object
  78173. */
  78174. damping?: number;
  78175. /**
  78176. * The path for a rope based on an extrusion
  78177. */
  78178. path?: any;
  78179. /**
  78180. * The shape of an extrusion used for a rope based on an extrusion
  78181. */
  78182. shape?: any;
  78183. }
  78184. /**
  78185. * Interface for a physics-enabled object
  78186. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  78187. */
  78188. export interface IPhysicsEnabledObject {
  78189. /**
  78190. * The position of the physics-enabled object
  78191. */
  78192. position: Vector3;
  78193. /**
  78194. * The rotation of the physics-enabled object
  78195. */
  78196. rotationQuaternion: Nullable<Quaternion>;
  78197. /**
  78198. * The scale of the physics-enabled object
  78199. */
  78200. scaling: Vector3;
  78201. /**
  78202. * The rotation of the physics-enabled object
  78203. */
  78204. rotation?: Vector3;
  78205. /**
  78206. * The parent of the physics-enabled object
  78207. */
  78208. parent?: any;
  78209. /**
  78210. * The bounding info of the physics-enabled object
  78211. * @returns The bounding info of the physics-enabled object
  78212. */
  78213. getBoundingInfo(): BoundingInfo;
  78214. /**
  78215. * Computes the world matrix
  78216. * @param force Specifies if the world matrix should be computed by force
  78217. * @returns A world matrix
  78218. */
  78219. computeWorldMatrix(force: boolean): Matrix;
  78220. /**
  78221. * Gets the world matrix
  78222. * @returns A world matrix
  78223. */
  78224. getWorldMatrix?(): Matrix;
  78225. /**
  78226. * Gets the child meshes
  78227. * @param directDescendantsOnly Specifies if only direct-descendants should be obtained
  78228. * @returns An array of abstract meshes
  78229. */
  78230. getChildMeshes?(directDescendantsOnly?: boolean): Array<AbstractMesh>;
  78231. /**
  78232. * Gets the vertex data
  78233. * @param kind The type of vertex data
  78234. * @returns A nullable array of numbers, or a float32 array
  78235. */
  78236. getVerticesData(kind: string): Nullable<Array<number> | Float32Array>;
  78237. /**
  78238. * Gets the indices from the mesh
  78239. * @returns A nullable array of index arrays
  78240. */
  78241. getIndices?(): Nullable<IndicesArray>;
  78242. /**
  78243. * Gets the scene from the mesh
  78244. * @returns the indices array or null
  78245. */
  78246. getScene?(): Scene;
  78247. /**
  78248. * Gets the absolute position from the mesh
  78249. * @returns the absolute position
  78250. */
  78251. getAbsolutePosition(): Vector3;
  78252. /**
  78253. * Gets the absolute pivot point from the mesh
  78254. * @returns the absolute pivot point
  78255. */
  78256. getAbsolutePivotPoint(): Vector3;
  78257. /**
  78258. * Rotates the mesh
  78259. * @param axis The axis of rotation
  78260. * @param amount The amount of rotation
  78261. * @param space The space of the rotation
  78262. * @returns The rotation transform node
  78263. */
  78264. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  78265. /**
  78266. * Translates the mesh
  78267. * @param axis The axis of translation
  78268. * @param distance The distance of translation
  78269. * @param space The space of the translation
  78270. * @returns The transform node
  78271. */
  78272. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  78273. /**
  78274. * Sets the absolute position of the mesh
  78275. * @param absolutePosition The absolute position of the mesh
  78276. * @returns The transform node
  78277. */
  78278. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  78279. /**
  78280. * Gets the class name of the mesh
  78281. * @returns The class name
  78282. */
  78283. getClassName(): string;
  78284. }
  78285. /**
  78286. * Represents a physics imposter
  78287. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  78288. */
  78289. export class PhysicsImpostor {
  78290. /**
  78291. * The physics-enabled object used as the physics imposter
  78292. */
  78293. object: IPhysicsEnabledObject;
  78294. /**
  78295. * The type of the physics imposter
  78296. */
  78297. type: number;
  78298. private _options;
  78299. private _scene?;
  78300. /**
  78301. * The default object size of the imposter
  78302. */
  78303. static DEFAULT_OBJECT_SIZE: Vector3;
  78304. /**
  78305. * The identity quaternion of the imposter
  78306. */
  78307. static IDENTITY_QUATERNION: Quaternion;
  78308. /** @hidden */
  78309. _pluginData: any;
  78310. private _physicsEngine;
  78311. private _physicsBody;
  78312. private _bodyUpdateRequired;
  78313. private _onBeforePhysicsStepCallbacks;
  78314. private _onAfterPhysicsStepCallbacks;
  78315. /** @hidden */
  78316. _onPhysicsCollideCallbacks: Array<{
  78317. callback: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor) => void;
  78318. otherImpostors: Array<PhysicsImpostor>;
  78319. }>;
  78320. private _deltaPosition;
  78321. private _deltaRotation;
  78322. private _deltaRotationConjugated;
  78323. /** hidden */
  78324. _isFromLine: boolean;
  78325. private _parent;
  78326. private _isDisposed;
  78327. private static _tmpVecs;
  78328. private static _tmpQuat;
  78329. /**
  78330. * Specifies if the physics imposter is disposed
  78331. */
  78332. readonly isDisposed: boolean;
  78333. /**
  78334. * Gets the mass of the physics imposter
  78335. */
  78336. mass: number;
  78337. /**
  78338. * Gets the coefficient of friction
  78339. */
  78340. /**
  78341. * Sets the coefficient of friction
  78342. */
  78343. friction: number;
  78344. /**
  78345. * Gets the coefficient of restitution
  78346. */
  78347. /**
  78348. * Sets the coefficient of restitution
  78349. */
  78350. restitution: number;
  78351. /**
  78352. * Gets the pressure of a soft body; only supported by the AmmoJSPlugin
  78353. */
  78354. /**
  78355. * Sets the pressure of a soft body; only supported by the AmmoJSPlugin
  78356. */
  78357. pressure: number;
  78358. /**
  78359. * Gets the stiffness of a soft body; only supported by the AmmoJSPlugin
  78360. */
  78361. /**
  78362. * Sets the stiffness of a soft body; only supported by the AmmoJSPlugin
  78363. */
  78364. stiffness: number;
  78365. /**
  78366. * Gets the velocityIterations of a soft body; only supported by the AmmoJSPlugin
  78367. */
  78368. /**
  78369. * Sets the velocityIterations of a soft body; only supported by the AmmoJSPlugin
  78370. */
  78371. velocityIterations: number;
  78372. /**
  78373. * Gets the positionIterations of a soft body; only supported by the AmmoJSPlugin
  78374. */
  78375. /**
  78376. * Sets the positionIterations of a soft body; only supported by the AmmoJSPlugin
  78377. */
  78378. positionIterations: number;
  78379. /**
  78380. * The unique id of the physics imposter
  78381. * set by the physics engine when adding this impostor to the array
  78382. */
  78383. uniqueId: number;
  78384. /**
  78385. * @hidden
  78386. */
  78387. soft: boolean;
  78388. /**
  78389. * @hidden
  78390. */
  78391. segments: number;
  78392. private _joints;
  78393. /**
  78394. * Initializes the physics imposter
  78395. * @param object The physics-enabled object used as the physics imposter
  78396. * @param type The type of the physics imposter
  78397. * @param _options The options for the physics imposter
  78398. * @param _scene The Babylon scene
  78399. */
  78400. constructor(
  78401. /**
  78402. * The physics-enabled object used as the physics imposter
  78403. */
  78404. object: IPhysicsEnabledObject,
  78405. /**
  78406. * The type of the physics imposter
  78407. */
  78408. type: number, _options?: PhysicsImpostorParameters, _scene?: Scene | undefined);
  78409. /**
  78410. * This function will completly initialize this impostor.
  78411. * It will create a new body - but only if this mesh has no parent.
  78412. * If it has, this impostor will not be used other than to define the impostor
  78413. * of the child mesh.
  78414. * @hidden
  78415. */
  78416. _init(): void;
  78417. private _getPhysicsParent;
  78418. /**
  78419. * Should a new body be generated.
  78420. * @returns boolean specifying if body initialization is required
  78421. */
  78422. isBodyInitRequired(): boolean;
  78423. /**
  78424. * Sets the updated scaling
  78425. * @param updated Specifies if the scaling is updated
  78426. */
  78427. setScalingUpdated(): void;
  78428. /**
  78429. * Force a regeneration of this or the parent's impostor's body.
  78430. * Use under cautious - This will remove all joints already implemented.
  78431. */
  78432. forceUpdate(): void;
  78433. /**
  78434. * Gets the body that holds this impostor. Either its own, or its parent.
  78435. */
  78436. /**
  78437. * Set the physics body. Used mainly by the physics engine/plugin
  78438. */
  78439. physicsBody: any;
  78440. /**
  78441. * Get the parent of the physics imposter
  78442. * @returns Physics imposter or null
  78443. */
  78444. /**
  78445. * Sets the parent of the physics imposter
  78446. */
  78447. parent: Nullable<PhysicsImpostor>;
  78448. /**
  78449. * Resets the update flags
  78450. */
  78451. resetUpdateFlags(): void;
  78452. /**
  78453. * Gets the object extend size
  78454. * @returns the object extend size
  78455. */
  78456. getObjectExtendSize(): Vector3;
  78457. /**
  78458. * Gets the object center
  78459. * @returns The object center
  78460. */
  78461. getObjectCenter(): Vector3;
  78462. /**
  78463. * Get a specific parametes from the options parameter
  78464. * @param paramName The object parameter name
  78465. * @returns The object parameter
  78466. */
  78467. getParam(paramName: string): any;
  78468. /**
  78469. * Sets a specific parameter in the options given to the physics plugin
  78470. * @param paramName The parameter name
  78471. * @param value The value of the parameter
  78472. */
  78473. setParam(paramName: string, value: number): void;
  78474. /**
  78475. * Specifically change the body's mass option. Won't recreate the physics body object
  78476. * @param mass The mass of the physics imposter
  78477. */
  78478. setMass(mass: number): void;
  78479. /**
  78480. * Gets the linear velocity
  78481. * @returns linear velocity or null
  78482. */
  78483. getLinearVelocity(): Nullable<Vector3>;
  78484. /**
  78485. * Sets the linear velocity
  78486. * @param velocity linear velocity or null
  78487. */
  78488. setLinearVelocity(velocity: Nullable<Vector3>): void;
  78489. /**
  78490. * Gets the angular velocity
  78491. * @returns angular velocity or null
  78492. */
  78493. getAngularVelocity(): Nullable<Vector3>;
  78494. /**
  78495. * Sets the angular velocity
  78496. * @param velocity The velocity or null
  78497. */
  78498. setAngularVelocity(velocity: Nullable<Vector3>): void;
  78499. /**
  78500. * Execute a function with the physics plugin native code
  78501. * Provide a function the will have two variables - the world object and the physics body object
  78502. * @param func The function to execute with the physics plugin native code
  78503. */
  78504. executeNativeFunction(func: (world: any, physicsBody: any) => void): void;
  78505. /**
  78506. * Register a function that will be executed before the physics world is stepping forward
  78507. * @param func The function to execute before the physics world is stepped forward
  78508. */
  78509. registerBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  78510. /**
  78511. * Unregister a function that will be executed before the physics world is stepping forward
  78512. * @param func The function to execute before the physics world is stepped forward
  78513. */
  78514. unregisterBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  78515. /**
  78516. * Register a function that will be executed after the physics step
  78517. * @param func The function to execute after physics step
  78518. */
  78519. registerAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  78520. /**
  78521. * Unregisters a function that will be executed after the physics step
  78522. * @param func The function to execute after physics step
  78523. */
  78524. unregisterAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  78525. /**
  78526. * register a function that will be executed when this impostor collides against a different body
  78527. * @param collideAgainst Physics imposter, or array of physics imposters to collide against
  78528. * @param func Callback that is executed on collision
  78529. */
  78530. registerOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor) => void): void;
  78531. /**
  78532. * Unregisters the physics imposter on contact
  78533. * @param collideAgainst The physics object to collide against
  78534. * @param func Callback to execute on collision
  78535. */
  78536. unregisterOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor | Array<PhysicsImpostor>) => void): void;
  78537. private _tmpQuat;
  78538. private _tmpQuat2;
  78539. /**
  78540. * Get the parent rotation
  78541. * @returns The parent rotation
  78542. */
  78543. getParentsRotation(): Quaternion;
  78544. /**
  78545. * this function is executed by the physics engine.
  78546. */
  78547. beforeStep: () => void;
  78548. /**
  78549. * this function is executed by the physics engine
  78550. */
  78551. afterStep: () => void;
  78552. /**
  78553. * Legacy collision detection event support
  78554. */
  78555. onCollideEvent: Nullable<(collider: PhysicsImpostor, collidedWith: PhysicsImpostor) => void>;
  78556. /**
  78557. * event and body object due to cannon's event-based architecture.
  78558. */
  78559. onCollide: (e: {
  78560. body: any;
  78561. }) => void;
  78562. /**
  78563. * Apply a force
  78564. * @param force The force to apply
  78565. * @param contactPoint The contact point for the force
  78566. * @returns The physics imposter
  78567. */
  78568. applyForce(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  78569. /**
  78570. * Apply an impulse
  78571. * @param force The impulse force
  78572. * @param contactPoint The contact point for the impulse force
  78573. * @returns The physics imposter
  78574. */
  78575. applyImpulse(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  78576. /**
  78577. * A help function to create a joint
  78578. * @param otherImpostor A physics imposter used to create a joint
  78579. * @param jointType The type of joint
  78580. * @param jointData The data for the joint
  78581. * @returns The physics imposter
  78582. */
  78583. createJoint(otherImpostor: PhysicsImpostor, jointType: number, jointData: PhysicsJointData): PhysicsImpostor;
  78584. /**
  78585. * Add a joint to this impostor with a different impostor
  78586. * @param otherImpostor A physics imposter used to add a joint
  78587. * @param joint The joint to add
  78588. * @returns The physics imposter
  78589. */
  78590. addJoint(otherImpostor: PhysicsImpostor, joint: PhysicsJoint): PhysicsImpostor;
  78591. /**
  78592. * Add an anchor to a cloth impostor
  78593. * @param otherImpostor rigid impostor to anchor to
  78594. * @param width ratio across width from 0 to 1
  78595. * @param height ratio up height from 0 to 1
  78596. * @param influence the elasticity between cloth impostor and anchor from 0, very stretchy to 1, little strech
  78597. * @param noCollisionBetweenLinkedBodies when true collisions between cloth impostor and anchor are ignored; default false
  78598. * @returns impostor the soft imposter
  78599. */
  78600. addAnchor(otherImpostor: PhysicsImpostor, width: number, height: number, influence: number, noCollisionBetweenLinkedBodies: boolean): PhysicsImpostor;
  78601. /**
  78602. * Add a hook to a rope impostor
  78603. * @param otherImpostor rigid impostor to anchor to
  78604. * @param length ratio across rope from 0 to 1
  78605. * @param influence the elasticity between rope impostor and anchor from 0, very stretchy to 1, little strech
  78606. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  78607. * @returns impostor the rope imposter
  78608. */
  78609. addHook(otherImpostor: PhysicsImpostor, length: number, influence: number, noCollisionBetweenLinkedBodies: boolean): PhysicsImpostor;
  78610. /**
  78611. * Will keep this body still, in a sleep mode.
  78612. * @returns the physics imposter
  78613. */
  78614. sleep(): PhysicsImpostor;
  78615. /**
  78616. * Wake the body up.
  78617. * @returns The physics imposter
  78618. */
  78619. wakeUp(): PhysicsImpostor;
  78620. /**
  78621. * Clones the physics imposter
  78622. * @param newObject The physics imposter clones to this physics-enabled object
  78623. * @returns A nullable physics imposter
  78624. */
  78625. clone(newObject: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  78626. /**
  78627. * Disposes the physics imposter
  78628. */
  78629. dispose(): void;
  78630. /**
  78631. * Sets the delta position
  78632. * @param position The delta position amount
  78633. */
  78634. setDeltaPosition(position: Vector3): void;
  78635. /**
  78636. * Sets the delta rotation
  78637. * @param rotation The delta rotation amount
  78638. */
  78639. setDeltaRotation(rotation: Quaternion): void;
  78640. /**
  78641. * Gets the box size of the physics imposter and stores the result in the input parameter
  78642. * @param result Stores the box size
  78643. * @returns The physics imposter
  78644. */
  78645. getBoxSizeToRef(result: Vector3): PhysicsImpostor;
  78646. /**
  78647. * Gets the radius of the physics imposter
  78648. * @returns Radius of the physics imposter
  78649. */
  78650. getRadius(): number;
  78651. /**
  78652. * Sync a bone with this impostor
  78653. * @param bone The bone to sync to the impostor.
  78654. * @param boneMesh The mesh that the bone is influencing.
  78655. * @param jointPivot The pivot of the joint / bone in local space.
  78656. * @param distToJoint Optional distance from the impostor to the joint.
  78657. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  78658. */
  78659. syncBoneWithImpostor(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion): void;
  78660. /**
  78661. * Sync impostor to a bone
  78662. * @param bone The bone that the impostor will be synced to.
  78663. * @param boneMesh The mesh that the bone is influencing.
  78664. * @param jointPivot The pivot of the joint / bone in local space.
  78665. * @param distToJoint Optional distance from the impostor to the joint.
  78666. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  78667. * @param boneAxis Optional vector3 axis the bone is aligned with
  78668. */
  78669. syncImpostorWithBone(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion, boneAxis?: Vector3): void;
  78670. /**
  78671. * No-Imposter type
  78672. */
  78673. static NoImpostor: number;
  78674. /**
  78675. * Sphere-Imposter type
  78676. */
  78677. static SphereImpostor: number;
  78678. /**
  78679. * Box-Imposter type
  78680. */
  78681. static BoxImpostor: number;
  78682. /**
  78683. * Plane-Imposter type
  78684. */
  78685. static PlaneImpostor: number;
  78686. /**
  78687. * Mesh-imposter type
  78688. */
  78689. static MeshImpostor: number;
  78690. /**
  78691. * Cylinder-Imposter type
  78692. */
  78693. static CylinderImpostor: number;
  78694. /**
  78695. * Particle-Imposter type
  78696. */
  78697. static ParticleImpostor: number;
  78698. /**
  78699. * Heightmap-Imposter type
  78700. */
  78701. static HeightmapImpostor: number;
  78702. /**
  78703. * ConvexHull-Impostor type (Ammo.js plugin only)
  78704. */
  78705. static ConvexHullImpostor: number;
  78706. /**
  78707. * Rope-Imposter type
  78708. */
  78709. static RopeImpostor: number;
  78710. /**
  78711. * Cloth-Imposter type
  78712. */
  78713. static ClothImpostor: number;
  78714. /**
  78715. * Softbody-Imposter type
  78716. */
  78717. static SoftbodyImpostor: number;
  78718. }
  78719. }
  78720. declare module BABYLON {
  78721. /**
  78722. * Class used to represent a specific level of detail of a mesh
  78723. * @see http://doc.babylonjs.com/how_to/how_to_use_lod
  78724. */
  78725. export class MeshLODLevel {
  78726. /** Defines the distance where this level should star being displayed */
  78727. distance: number;
  78728. /** Defines the mesh to use to render this level */
  78729. mesh: Nullable<Mesh>;
  78730. /**
  78731. * Creates a new LOD level
  78732. * @param distance defines the distance where this level should star being displayed
  78733. * @param mesh defines the mesh to use to render this level
  78734. */
  78735. constructor(
  78736. /** Defines the distance where this level should star being displayed */
  78737. distance: number,
  78738. /** Defines the mesh to use to render this level */
  78739. mesh: Nullable<Mesh>);
  78740. }
  78741. /**
  78742. * @hidden
  78743. **/
  78744. export class _CreationDataStorage {
  78745. closePath?: boolean;
  78746. closeArray?: boolean;
  78747. idx: number[];
  78748. dashSize: number;
  78749. gapSize: number;
  78750. path3D: Path3D;
  78751. pathArray: Vector3[][];
  78752. arc: number;
  78753. radius: number;
  78754. cap: number;
  78755. tessellation: number;
  78756. }
  78757. /**
  78758. * @hidden
  78759. **/
  78760. class _InstanceDataStorage {
  78761. visibleInstances: any;
  78762. renderIdForInstances: number[];
  78763. batchCache: _InstancesBatch;
  78764. instancesBufferSize: number;
  78765. instancesBuffer: Nullable<Buffer>;
  78766. instancesData: Float32Array;
  78767. overridenInstanceCount: number;
  78768. }
  78769. /**
  78770. * @hidden
  78771. **/
  78772. export class _InstancesBatch {
  78773. mustReturn: boolean;
  78774. visibleInstances: Nullable<InstancedMesh[]>[];
  78775. renderSelf: boolean[];
  78776. }
  78777. /**
  78778. * Class used to represent renderable models
  78779. */
  78780. export class Mesh extends AbstractMesh implements IGetSetVerticesData {
  78781. /**
  78782. * Mesh side orientation : usually the external or front surface
  78783. */
  78784. static readonly FRONTSIDE: number;
  78785. /**
  78786. * Mesh side orientation : usually the internal or back surface
  78787. */
  78788. static readonly BACKSIDE: number;
  78789. /**
  78790. * Mesh side orientation : both internal and external or front and back surfaces
  78791. */
  78792. static readonly DOUBLESIDE: number;
  78793. /**
  78794. * Mesh side orientation : by default, `FRONTSIDE`
  78795. */
  78796. static readonly DEFAULTSIDE: number;
  78797. /**
  78798. * Mesh cap setting : no cap
  78799. */
  78800. static readonly NO_CAP: number;
  78801. /**
  78802. * Mesh cap setting : one cap at the beginning of the mesh
  78803. */
  78804. static readonly CAP_START: number;
  78805. /**
  78806. * Mesh cap setting : one cap at the end of the mesh
  78807. */
  78808. static readonly CAP_END: number;
  78809. /**
  78810. * Mesh cap setting : two caps, one at the beginning and one at the end of the mesh
  78811. */
  78812. static readonly CAP_ALL: number;
  78813. /**
  78814. * Gets the default side orientation.
  78815. * @param orientation the orientation to value to attempt to get
  78816. * @returns the default orientation
  78817. * @hidden
  78818. */
  78819. static _GetDefaultSideOrientation(orientation?: number): number;
  78820. private _onBeforeRenderObservable;
  78821. private _onBeforeBindObservable;
  78822. private _onAfterRenderObservable;
  78823. private _onBeforeDrawObservable;
  78824. /**
  78825. * An event triggered before rendering the mesh
  78826. */
  78827. readonly onBeforeRenderObservable: Observable<Mesh>;
  78828. /**
  78829. * An event triggered before binding the mesh
  78830. */
  78831. readonly onBeforeBindObservable: Observable<Mesh>;
  78832. /**
  78833. * An event triggered after rendering the mesh
  78834. */
  78835. readonly onAfterRenderObservable: Observable<Mesh>;
  78836. /**
  78837. * An event triggered before drawing the mesh
  78838. */
  78839. readonly onBeforeDrawObservable: Observable<Mesh>;
  78840. private _onBeforeDrawObserver;
  78841. /**
  78842. * Sets a callback to call before drawing the mesh. It is recommended to use onBeforeDrawObservable instead
  78843. */
  78844. onBeforeDraw: () => void;
  78845. /**
  78846. * Gets the delay loading state of the mesh (when delay loading is turned on)
  78847. * @see http://doc.babylonjs.com/how_to/using_the_incremental_loading_system
  78848. */
  78849. delayLoadState: number;
  78850. /**
  78851. * Gets the list of instances created from this mesh
  78852. * it is not supposed to be modified manually.
  78853. * Note also that the order of the InstancedMesh wihin the array is not significant and might change.
  78854. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  78855. */
  78856. instances: InstancedMesh[];
  78857. /**
  78858. * Gets the file containing delay loading data for this mesh
  78859. */
  78860. delayLoadingFile: string;
  78861. /** @hidden */
  78862. _binaryInfo: any;
  78863. private _LODLevels;
  78864. /**
  78865. * User defined function used to change how LOD level selection is done
  78866. * @see http://doc.babylonjs.com/how_to/how_to_use_lod
  78867. */
  78868. onLODLevelSelection: (distance: number, mesh: Mesh, selectedLevel: Nullable<Mesh>) => void;
  78869. private _morphTargetManager;
  78870. /**
  78871. * Gets or sets the morph target manager
  78872. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  78873. */
  78874. morphTargetManager: Nullable<MorphTargetManager>;
  78875. /** @hidden */
  78876. _creationDataStorage: Nullable<_CreationDataStorage>;
  78877. /** @hidden */
  78878. _geometry: Nullable<Geometry>;
  78879. /** @hidden */
  78880. _delayInfo: Array<string>;
  78881. /** @hidden */
  78882. _delayLoadingFunction: (any: any, mesh: Mesh) => void;
  78883. /** @hidden */
  78884. _instanceDataStorage: _InstanceDataStorage;
  78885. private _effectiveMaterial;
  78886. /** @hidden */
  78887. _shouldGenerateFlatShading: boolean;
  78888. private _preActivateId;
  78889. /** @hidden */
  78890. _originalBuilderSideOrientation: number;
  78891. /**
  78892. * Use this property to change the original side orientation defined at construction time
  78893. */
  78894. overrideMaterialSideOrientation: Nullable<number>;
  78895. private _areNormalsFrozen;
  78896. private _sourcePositions;
  78897. private _sourceNormals;
  78898. private _source;
  78899. private meshMap;
  78900. /**
  78901. * Gets the source mesh (the one used to clone this one from)
  78902. */
  78903. readonly source: Nullable<Mesh>;
  78904. /**
  78905. * Gets or sets a boolean indicating that this mesh does not use index buffer
  78906. */
  78907. isUnIndexed: boolean;
  78908. /**
  78909. * @constructor
  78910. * @param name The value used by scene.getMeshByName() to do a lookup.
  78911. * @param scene The scene to add this mesh to.
  78912. * @param parent The parent of this mesh, if it has one
  78913. * @param source An optional Mesh from which geometry is shared, cloned.
  78914. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  78915. * When false, achieved by calling a clone(), also passing False.
  78916. * This will make creation of children, recursive.
  78917. * @param clonePhysicsImpostor When cloning, include cloning mesh physics impostor, default True.
  78918. */
  78919. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: Nullable<Mesh>, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean);
  78920. /**
  78921. * Gets the class name
  78922. * @returns the string "Mesh".
  78923. */
  78924. getClassName(): string;
  78925. /** @hidden */
  78926. readonly _isMesh: boolean;
  78927. /**
  78928. * Returns a description of this mesh
  78929. * @param fullDetails define if full details about this mesh must be used
  78930. * @returns a descriptive string representing this mesh
  78931. */
  78932. toString(fullDetails?: boolean): string;
  78933. /** @hidden */
  78934. _unBindEffect(): void;
  78935. /**
  78936. * Gets a boolean indicating if this mesh has LOD
  78937. */
  78938. readonly hasLODLevels: boolean;
  78939. /**
  78940. * Gets the list of MeshLODLevel associated with the current mesh
  78941. * @returns an array of MeshLODLevel
  78942. */
  78943. getLODLevels(): MeshLODLevel[];
  78944. private _sortLODLevels;
  78945. /**
  78946. * Add a mesh as LOD level triggered at the given distance.
  78947. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  78948. * @param distance The distance from the center of the object to show this level
  78949. * @param mesh The mesh to be added as LOD level (can be null)
  78950. * @return This mesh (for chaining)
  78951. */
  78952. addLODLevel(distance: number, mesh: Nullable<Mesh>): Mesh;
  78953. /**
  78954. * Returns the LOD level mesh at the passed distance or null if not found.
  78955. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  78956. * @param distance The distance from the center of the object to show this level
  78957. * @returns a Mesh or `null`
  78958. */
  78959. getLODLevelAtDistance(distance: number): Nullable<Mesh>;
  78960. /**
  78961. * Remove a mesh from the LOD array
  78962. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  78963. * @param mesh defines the mesh to be removed
  78964. * @return This mesh (for chaining)
  78965. */
  78966. removeLODLevel(mesh: Mesh): Mesh;
  78967. /**
  78968. * Returns the registered LOD mesh distant from the parameter `camera` position if any, else returns the current mesh.
  78969. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  78970. * @param camera defines the camera to use to compute distance
  78971. * @param boundingSphere defines a custom bounding sphere to use instead of the one from this mesh
  78972. * @return This mesh (for chaining)
  78973. */
  78974. getLOD(camera: Camera, boundingSphere?: BoundingSphere): Nullable<AbstractMesh>;
  78975. /**
  78976. * Gets the mesh internal Geometry object
  78977. */
  78978. readonly geometry: Nullable<Geometry>;
  78979. /**
  78980. * Returns the total number of vertices within the mesh geometry or zero if the mesh has no geometry.
  78981. * @returns the total number of vertices
  78982. */
  78983. getTotalVertices(): number;
  78984. /**
  78985. * Returns the content of an associated vertex buffer
  78986. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  78987. * - VertexBuffer.PositionKind
  78988. * - VertexBuffer.UVKind
  78989. * - VertexBuffer.UV2Kind
  78990. * - VertexBuffer.UV3Kind
  78991. * - VertexBuffer.UV4Kind
  78992. * - VertexBuffer.UV5Kind
  78993. * - VertexBuffer.UV6Kind
  78994. * - VertexBuffer.ColorKind
  78995. * - VertexBuffer.MatricesIndicesKind
  78996. * - VertexBuffer.MatricesIndicesExtraKind
  78997. * - VertexBuffer.MatricesWeightsKind
  78998. * - VertexBuffer.MatricesWeightsExtraKind
  78999. * @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
  79000. * @param forceCopy defines a boolean forcing the copy of the buffer no matter what the value of copyWhenShared is
  79001. * @returns a FloatArray or null if the mesh has no geometry or no vertex buffer for this kind.
  79002. */
  79003. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  79004. /**
  79005. * Returns the mesh VertexBuffer object from the requested `kind`
  79006. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  79007. * - VertexBuffer.PositionKind
  79008. * - VertexBuffer.UVKind
  79009. * - VertexBuffer.UV2Kind
  79010. * - VertexBuffer.UV3Kind
  79011. * - VertexBuffer.UV4Kind
  79012. * - VertexBuffer.UV5Kind
  79013. * - VertexBuffer.UV6Kind
  79014. * - VertexBuffer.ColorKind
  79015. * - VertexBuffer.MatricesIndicesKind
  79016. * - VertexBuffer.MatricesIndicesExtraKind
  79017. * - VertexBuffer.MatricesWeightsKind
  79018. * - VertexBuffer.MatricesWeightsExtraKind
  79019. * @returns a FloatArray or null if the mesh has no vertex buffer for this kind.
  79020. */
  79021. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  79022. /**
  79023. * Tests if a specific vertex buffer is associated with this mesh
  79024. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  79025. * - VertexBuffer.PositionKind
  79026. * - VertexBuffer.UVKind
  79027. * - VertexBuffer.UV2Kind
  79028. * - VertexBuffer.UV3Kind
  79029. * - VertexBuffer.UV4Kind
  79030. * - VertexBuffer.UV5Kind
  79031. * - VertexBuffer.UV6Kind
  79032. * - VertexBuffer.ColorKind
  79033. * - VertexBuffer.MatricesIndicesKind
  79034. * - VertexBuffer.MatricesIndicesExtraKind
  79035. * - VertexBuffer.MatricesWeightsKind
  79036. * - VertexBuffer.MatricesWeightsExtraKind
  79037. * @returns a boolean
  79038. */
  79039. isVerticesDataPresent(kind: string): boolean;
  79040. /**
  79041. * Returns a boolean defining if the vertex data for the requested `kind` is updatable.
  79042. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  79043. * - VertexBuffer.PositionKind
  79044. * - VertexBuffer.UVKind
  79045. * - VertexBuffer.UV2Kind
  79046. * - VertexBuffer.UV3Kind
  79047. * - VertexBuffer.UV4Kind
  79048. * - VertexBuffer.UV5Kind
  79049. * - VertexBuffer.UV6Kind
  79050. * - VertexBuffer.ColorKind
  79051. * - VertexBuffer.MatricesIndicesKind
  79052. * - VertexBuffer.MatricesIndicesExtraKind
  79053. * - VertexBuffer.MatricesWeightsKind
  79054. * - VertexBuffer.MatricesWeightsExtraKind
  79055. * @returns a boolean
  79056. */
  79057. isVertexBufferUpdatable(kind: string): boolean;
  79058. /**
  79059. * Returns a string which contains the list of existing `kinds` of Vertex Data associated with this mesh.
  79060. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  79061. * - VertexBuffer.PositionKind
  79062. * - VertexBuffer.UVKind
  79063. * - VertexBuffer.UV2Kind
  79064. * - VertexBuffer.UV3Kind
  79065. * - VertexBuffer.UV4Kind
  79066. * - VertexBuffer.UV5Kind
  79067. * - VertexBuffer.UV6Kind
  79068. * - VertexBuffer.ColorKind
  79069. * - VertexBuffer.MatricesIndicesKind
  79070. * - VertexBuffer.MatricesIndicesExtraKind
  79071. * - VertexBuffer.MatricesWeightsKind
  79072. * - VertexBuffer.MatricesWeightsExtraKind
  79073. * @returns an array of strings
  79074. */
  79075. getVerticesDataKinds(): string[];
  79076. /**
  79077. * Returns a positive integer : the total number of indices in this mesh geometry.
  79078. * @returns the numner of indices or zero if the mesh has no geometry.
  79079. */
  79080. getTotalIndices(): number;
  79081. /**
  79082. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  79083. * @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.
  79084. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  79085. * @returns the indices array or an empty array if the mesh has no geometry
  79086. */
  79087. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  79088. readonly isBlocked: boolean;
  79089. /**
  79090. * Determine if the current mesh is ready to be rendered
  79091. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  79092. * @param forceInstanceSupport will check if the mesh will be ready when used with instances (false by default)
  79093. * @returns true if all associated assets are ready (material, textures, shaders)
  79094. */
  79095. isReady(completeCheck?: boolean, forceInstanceSupport?: boolean): boolean;
  79096. /**
  79097. * 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.
  79098. */
  79099. readonly areNormalsFrozen: boolean;
  79100. /**
  79101. * 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.
  79102. * @returns the current mesh
  79103. */
  79104. freezeNormals(): Mesh;
  79105. /**
  79106. * 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
  79107. * @returns the current mesh
  79108. */
  79109. unfreezeNormals(): Mesh;
  79110. /**
  79111. * Sets a value overriding the instance count. Only applicable when custom instanced InterleavedVertexBuffer are used rather than InstancedMeshs
  79112. */
  79113. overridenInstanceCount: number;
  79114. /** @hidden */
  79115. _preActivate(): Mesh;
  79116. /** @hidden */
  79117. _preActivateForIntermediateRendering(renderId: number): Mesh;
  79118. /** @hidden */
  79119. _registerInstanceForRenderId(instance: InstancedMesh, renderId: number): Mesh;
  79120. /**
  79121. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  79122. * This means the mesh underlying bounding box and sphere are recomputed.
  79123. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  79124. * @returns the current mesh
  79125. */
  79126. refreshBoundingInfo(applySkeleton?: boolean): Mesh;
  79127. /** @hidden */
  79128. _createGlobalSubMesh(force: boolean): Nullable<SubMesh>;
  79129. /**
  79130. * This function will subdivide the mesh into multiple submeshes
  79131. * @param count defines the expected number of submeshes
  79132. */
  79133. subdivide(count: number): void;
  79134. /**
  79135. * Copy a FloatArray into a specific associated vertex buffer
  79136. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  79137. * - VertexBuffer.PositionKind
  79138. * - VertexBuffer.UVKind
  79139. * - VertexBuffer.UV2Kind
  79140. * - VertexBuffer.UV3Kind
  79141. * - VertexBuffer.UV4Kind
  79142. * - VertexBuffer.UV5Kind
  79143. * - VertexBuffer.UV6Kind
  79144. * - VertexBuffer.ColorKind
  79145. * - VertexBuffer.MatricesIndicesKind
  79146. * - VertexBuffer.MatricesIndicesExtraKind
  79147. * - VertexBuffer.MatricesWeightsKind
  79148. * - VertexBuffer.MatricesWeightsExtraKind
  79149. * @param data defines the data source
  79150. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  79151. * @param stride defines the data stride size (can be null)
  79152. * @returns the current mesh
  79153. */
  79154. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): Mesh;
  79155. /**
  79156. * Flags an associated vertex buffer as updatable
  79157. * @param kind defines which buffer to use (positions, indices, normals, etc). Possible `kind` values :
  79158. * - VertexBuffer.PositionKind
  79159. * - VertexBuffer.UVKind
  79160. * - VertexBuffer.UV2Kind
  79161. * - VertexBuffer.UV3Kind
  79162. * - VertexBuffer.UV4Kind
  79163. * - VertexBuffer.UV5Kind
  79164. * - VertexBuffer.UV6Kind
  79165. * - VertexBuffer.ColorKind
  79166. * - VertexBuffer.MatricesIndicesKind
  79167. * - VertexBuffer.MatricesIndicesExtraKind
  79168. * - VertexBuffer.MatricesWeightsKind
  79169. * - VertexBuffer.MatricesWeightsExtraKind
  79170. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  79171. */
  79172. markVerticesDataAsUpdatable(kind: string, updatable?: boolean): void;
  79173. /**
  79174. * Sets the mesh global Vertex Buffer
  79175. * @param buffer defines the buffer to use
  79176. * @returns the current mesh
  79177. */
  79178. setVerticesBuffer(buffer: VertexBuffer): Mesh;
  79179. /**
  79180. * Update a specific associated vertex buffer
  79181. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  79182. * - VertexBuffer.PositionKind
  79183. * - VertexBuffer.UVKind
  79184. * - VertexBuffer.UV2Kind
  79185. * - VertexBuffer.UV3Kind
  79186. * - VertexBuffer.UV4Kind
  79187. * - VertexBuffer.UV5Kind
  79188. * - VertexBuffer.UV6Kind
  79189. * - VertexBuffer.ColorKind
  79190. * - VertexBuffer.MatricesIndicesKind
  79191. * - VertexBuffer.MatricesIndicesExtraKind
  79192. * - VertexBuffer.MatricesWeightsKind
  79193. * - VertexBuffer.MatricesWeightsExtraKind
  79194. * @param data defines the data source
  79195. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  79196. * @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)
  79197. * @returns the current mesh
  79198. */
  79199. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): Mesh;
  79200. /**
  79201. * This method updates the vertex positions of an updatable mesh according to the `positionFunction` returned values.
  79202. * @see http://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh#other-shapes-updatemeshpositions
  79203. * @param positionFunction is a simple JS function what is passed the mesh `positions` array. It doesn't need to return anything
  79204. * @param computeNormals is a boolean (default true) to enable/disable the mesh normal recomputation after the vertex position update
  79205. * @returns the current mesh
  79206. */
  79207. updateMeshPositions(positionFunction: (data: FloatArray) => void, computeNormals?: boolean): Mesh;
  79208. /**
  79209. * Creates a un-shared specific occurence of the geometry for the mesh.
  79210. * @returns the current mesh
  79211. */
  79212. makeGeometryUnique(): Mesh;
  79213. /**
  79214. * Set the index buffer of this mesh
  79215. * @param indices defines the source data
  79216. * @param totalVertices defines the total number of vertices referenced by this index data (can be null)
  79217. * @param updatable defines if the updated index buffer must be flagged as updatable (default is false)
  79218. * @returns the current mesh
  79219. */
  79220. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): Mesh;
  79221. /**
  79222. * Update the current index buffer
  79223. * @param indices defines the source data
  79224. * @param offset defines the offset in the index buffer where to store the new data (can be null)
  79225. * @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)
  79226. * @returns the current mesh
  79227. */
  79228. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): Mesh;
  79229. /**
  79230. * Invert the geometry to move from a right handed system to a left handed one.
  79231. * @returns the current mesh
  79232. */
  79233. toLeftHanded(): Mesh;
  79234. /** @hidden */
  79235. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): Mesh;
  79236. /** @hidden */
  79237. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number, alternate?: boolean): Mesh;
  79238. /**
  79239. * Registers for this mesh a javascript function called just before the rendering process
  79240. * @param func defines the function to call before rendering this mesh
  79241. * @returns the current mesh
  79242. */
  79243. registerBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  79244. /**
  79245. * Disposes a previously registered javascript function called before the rendering
  79246. * @param func defines the function to remove
  79247. * @returns the current mesh
  79248. */
  79249. unregisterBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  79250. /**
  79251. * Registers for this mesh a javascript function called just after the rendering is complete
  79252. * @param func defines the function to call after rendering this mesh
  79253. * @returns the current mesh
  79254. */
  79255. registerAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  79256. /**
  79257. * Disposes a previously registered javascript function called after the rendering.
  79258. * @param func defines the function to remove
  79259. * @returns the current mesh
  79260. */
  79261. unregisterAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  79262. /** @hidden */
  79263. _getInstancesRenderList(subMeshId: number): _InstancesBatch;
  79264. /** @hidden */
  79265. _renderWithInstances(subMesh: SubMesh, fillMode: number, batch: _InstancesBatch, effect: Effect, engine: Engine): Mesh;
  79266. /** @hidden */
  79267. _processRendering(subMesh: SubMesh, effect: Effect, fillMode: number, batch: _InstancesBatch, hardwareInstancedRendering: boolean, onBeforeDraw: (isInstance: boolean, world: Matrix, effectiveMaterial?: Material) => void, effectiveMaterial?: Material): Mesh;
  79268. /**
  79269. * 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
  79270. * @param subMesh defines the subMesh to render
  79271. * @param enableAlphaMode defines if alpha mode can be changed
  79272. * @returns the current mesh
  79273. */
  79274. render(subMesh: SubMesh, enableAlphaMode: boolean): Mesh;
  79275. private _onBeforeDraw;
  79276. /**
  79277. * Renormalize the mesh and patch it up if there are no weights
  79278. * Similar to normalization by adding the weights compute the reciprocal and multiply all elements, this wil ensure that everything adds to 1.
  79279. * However in the case of zero weights then we set just a single influence to 1.
  79280. * We check in the function for extra's present and if so we use the normalizeSkinWeightsWithExtras rather than the FourWeights version.
  79281. */
  79282. cleanMatrixWeights(): void;
  79283. private normalizeSkinFourWeights;
  79284. private normalizeSkinWeightsAndExtra;
  79285. /**
  79286. * ValidateSkinning is used to determine that a mesh has valid skinning data along with skin metrics, if missing weights,
  79287. * or not normalized it is returned as invalid mesh the string can be used for console logs, or on screen messages to let
  79288. * the user know there was an issue with importing the mesh
  79289. * @returns a validation object with skinned, valid and report string
  79290. */
  79291. validateSkinning(): {
  79292. skinned: boolean;
  79293. valid: boolean;
  79294. report: string;
  79295. };
  79296. /** @hidden */
  79297. _checkDelayState(): Mesh;
  79298. private _queueLoad;
  79299. /**
  79300. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  79301. * A mesh is in the frustum if its bounding box intersects the frustum
  79302. * @param frustumPlanes defines the frustum to test
  79303. * @returns true if the mesh is in the frustum planes
  79304. */
  79305. isInFrustum(frustumPlanes: Plane[]): boolean;
  79306. /**
  79307. * Sets the mesh material by the material or multiMaterial `id` property
  79308. * @param id is a string identifying the material or the multiMaterial
  79309. * @returns the current mesh
  79310. */
  79311. setMaterialByID(id: string): Mesh;
  79312. /**
  79313. * Returns as a new array populated with the mesh material and/or skeleton, if any.
  79314. * @returns an array of IAnimatable
  79315. */
  79316. getAnimatables(): IAnimatable[];
  79317. /**
  79318. * Modifies the mesh geometry according to the passed transformation matrix.
  79319. * This method returns nothing but it really modifies the mesh even if it's originally not set as updatable.
  79320. * The mesh normals are modified using the same transformation.
  79321. * Note that, under the hood, this method sets a new VertexBuffer each call.
  79322. * @param transform defines the transform matrix to use
  79323. * @see http://doc.babylonjs.com/resources/baking_transformations
  79324. * @returns the current mesh
  79325. */
  79326. bakeTransformIntoVertices(transform: Matrix): Mesh;
  79327. /**
  79328. * Modifies the mesh geometry according to its own current World Matrix.
  79329. * The mesh World Matrix is then reset.
  79330. * This method returns nothing but really modifies the mesh even if it's originally not set as updatable.
  79331. * Note that, under the hood, this method sets a new VertexBuffer each call.
  79332. * @see http://doc.babylonjs.com/resources/baking_transformations
  79333. * @returns the current mesh
  79334. */
  79335. bakeCurrentTransformIntoVertices(): Mesh;
  79336. /** @hidden */
  79337. readonly _positions: Nullable<Vector3[]>;
  79338. /** @hidden */
  79339. _resetPointsArrayCache(): Mesh;
  79340. /** @hidden */
  79341. _generatePointsArray(): boolean;
  79342. /**
  79343. * Returns a new Mesh object generated from the current mesh properties.
  79344. * This method must not get confused with createInstance()
  79345. * @param name is a string, the name given to the new mesh
  79346. * @param newParent can be any Node object (default `null`)
  79347. * @param doNotCloneChildren allows/denies the recursive cloning of the original mesh children if any (default `false`)
  79348. * @param clonePhysicsImpostor allows/denies the cloning in the same time of the original mesh `body` used by the physics engine, if any (default `true`)
  79349. * @returns a new mesh
  79350. */
  79351. clone(name?: string, newParent?: Node, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean): Mesh;
  79352. /**
  79353. * Releases resources associated with this mesh.
  79354. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  79355. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  79356. */
  79357. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  79358. /**
  79359. * Modifies the mesh geometry according to a displacement map.
  79360. * 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.
  79361. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  79362. * @param url is a string, the URL from the image file is to be downloaded.
  79363. * @param minHeight is the lower limit of the displacement.
  79364. * @param maxHeight is the upper limit of the displacement.
  79365. * @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.
  79366. * @param uvOffset is an optional vector2 used to offset UV.
  79367. * @param uvScale is an optional vector2 used to scale UV.
  79368. * @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.
  79369. * @returns the Mesh.
  79370. */
  79371. applyDisplacementMap(url: string, minHeight: number, maxHeight: number, onSuccess?: (mesh: Mesh) => void, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  79372. /**
  79373. * Modifies the mesh geometry according to a displacementMap buffer.
  79374. * 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.
  79375. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  79376. * @param buffer is a `Uint8Array` buffer containing series of `Uint8` lower than 255, the red, green, blue and alpha values of each successive pixel.
  79377. * @param heightMapWidth is the width of the buffer image.
  79378. * @param heightMapHeight is the height of the buffer image.
  79379. * @param minHeight is the lower limit of the displacement.
  79380. * @param maxHeight is the upper limit of the displacement.
  79381. * @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.
  79382. * @param uvOffset is an optional vector2 used to offset UV.
  79383. * @param uvScale is an optional vector2 used to scale UV.
  79384. * @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.
  79385. * @returns the Mesh.
  79386. */
  79387. applyDisplacementMapFromBuffer(buffer: Uint8Array, heightMapWidth: number, heightMapHeight: number, minHeight: number, maxHeight: number, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  79388. /**
  79389. * Modify the mesh to get a flat shading rendering.
  79390. * This means each mesh facet will then have its own normals. Usually new vertices are added in the mesh geometry to get this result.
  79391. * Warning : the mesh is really modified even if not set originally as updatable and, under the hood, a new VertexBuffer is allocated.
  79392. * @returns current mesh
  79393. */
  79394. convertToFlatShadedMesh(): Mesh;
  79395. /**
  79396. * This method removes all the mesh indices and add new vertices (duplication) in order to unfold facets into buffers.
  79397. * In other words, more vertices, no more indices and a single bigger VBO.
  79398. * The mesh is really modified even if not set originally as updatable. Under the hood, a new VertexBuffer is allocated.
  79399. * @returns current mesh
  79400. */
  79401. convertToUnIndexedMesh(): Mesh;
  79402. /**
  79403. * Inverses facet orientations.
  79404. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  79405. * @param flipNormals will also inverts the normals
  79406. * @returns current mesh
  79407. */
  79408. flipFaces(flipNormals?: boolean): Mesh;
  79409. /**
  79410. * Increase the number of facets and hence vertices in a mesh
  79411. * Vertex normals are interpolated from existing vertex normals
  79412. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  79413. * @param numberPerEdge the number of new vertices to add to each edge of a facet, optional default 1
  79414. */
  79415. increaseVertices(numberPerEdge: number): void;
  79416. /**
  79417. * Force adjacent facets to share vertices and remove any facets that have all vertices in a line
  79418. * This will undo any application of covertToFlatShadedMesh
  79419. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  79420. */
  79421. forceSharedVertices(): void;
  79422. /** @hidden */
  79423. static _instancedMeshFactory(name: string, mesh: Mesh): InstancedMesh;
  79424. /** @hidden */
  79425. static _PhysicsImpostorParser(scene: Scene, physicObject: IPhysicsEnabledObject, jsonObject: any): PhysicsImpostor;
  79426. /**
  79427. * Creates a new InstancedMesh object from the mesh model.
  79428. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  79429. * @param name defines the name of the new instance
  79430. * @returns a new InstancedMesh
  79431. */
  79432. createInstance(name: string): InstancedMesh;
  79433. /**
  79434. * Synchronises all the mesh instance submeshes to the current mesh submeshes, if any.
  79435. * After this call, all the mesh instances have the same submeshes than the current mesh.
  79436. * @returns the current mesh
  79437. */
  79438. synchronizeInstances(): Mesh;
  79439. /**
  79440. * Optimization of the mesh's indices, in case a mesh has duplicated vertices.
  79441. * The function will only reorder the indices and will not remove unused vertices to avoid problems with submeshes.
  79442. * This should be used together with the simplification to avoid disappearing triangles.
  79443. * @param successCallback an optional success callback to be called after the optimization finished.
  79444. * @returns the current mesh
  79445. */
  79446. optimizeIndices(successCallback?: (mesh?: Mesh) => void): Mesh;
  79447. /**
  79448. * Serialize current mesh
  79449. * @param serializationObject defines the object which will receive the serialization data
  79450. */
  79451. serialize(serializationObject: any): void;
  79452. /** @hidden */
  79453. _syncGeometryWithMorphTargetManager(): void;
  79454. /** @hidden */
  79455. static _GroundMeshParser: (parsedMesh: any, scene: Scene) => Mesh;
  79456. /**
  79457. * Returns a new Mesh object parsed from the source provided.
  79458. * @param parsedMesh is the source
  79459. * @param scene defines the hosting scene
  79460. * @param rootUrl is the root URL to prefix the `delayLoadingFile` property with
  79461. * @returns a new Mesh
  79462. */
  79463. static Parse(parsedMesh: any, scene: Scene, rootUrl: string): Mesh;
  79464. /**
  79465. * Creates a ribbon mesh. Please consider using the same method from the MeshBuilder class instead
  79466. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  79467. * @param name defines the name of the mesh to create
  79468. * @param pathArray is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry.
  79469. * @param closeArray creates a seam between the first and the last paths of the path array (default is false)
  79470. * @param closePath creates a seam between the first and the last points of each path of the path array
  79471. * @param offset is taken in account only if the `pathArray` is containing a single path
  79472. * @param scene defines the hosting scene
  79473. * @param updatable defines if the mesh must be flagged as updatable
  79474. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  79475. * @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)
  79476. * @returns a new Mesh
  79477. */
  79478. static CreateRibbon(name: string, pathArray: Vector3[][], closeArray: boolean, closePath: boolean, offset: number, scene?: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  79479. /**
  79480. * Creates a plane polygonal mesh. By default, this is a disc. Please consider using the same method from the MeshBuilder class instead
  79481. * @param name defines the name of the mesh to create
  79482. * @param radius sets the radius size (float) of the polygon (default 0.5)
  79483. * @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
  79484. * @param scene defines the hosting scene
  79485. * @param updatable defines if the mesh must be flagged as updatable
  79486. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  79487. * @returns a new Mesh
  79488. */
  79489. static CreateDisc(name: string, radius: number, tessellation: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  79490. /**
  79491. * Creates a box mesh. Please consider using the same method from the MeshBuilder class instead
  79492. * @param name defines the name of the mesh to create
  79493. * @param size sets the size (float) of each box side (default 1)
  79494. * @param scene defines the hosting scene
  79495. * @param updatable defines if the mesh must be flagged as updatable
  79496. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  79497. * @returns a new Mesh
  79498. */
  79499. static CreateBox(name: string, size: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  79500. /**
  79501. * Creates a sphere mesh. Please consider using the same method from the MeshBuilder class instead
  79502. * @param name defines the name of the mesh to create
  79503. * @param segments sets the sphere number of horizontal stripes (positive integer, default 32)
  79504. * @param diameter sets the diameter size (float) of the sphere (default 1)
  79505. * @param scene defines the hosting scene
  79506. * @param updatable defines if the mesh must be flagged as updatable
  79507. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  79508. * @returns a new Mesh
  79509. */
  79510. static CreateSphere(name: string, segments: number, diameter: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  79511. /**
  79512. * Creates a cylinder or a cone mesh. Please consider using the same method from the MeshBuilder class instead
  79513. * @param name defines the name of the mesh to create
  79514. * @param height sets the height size (float) of the cylinder/cone (float, default 2)
  79515. * @param diameterTop set the top cap diameter (floats, default 1)
  79516. * @param diameterBottom set the bottom cap diameter (floats, default 1). This value can't be zero
  79517. * @param tessellation sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance
  79518. * @param subdivisions sets the number of rings along the cylinder height (positive integer, default 1)
  79519. * @param scene defines the hosting scene
  79520. * @param updatable defines if the mesh must be flagged as updatable
  79521. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  79522. * @returns a new Mesh
  79523. */
  79524. static CreateCylinder(name: string, height: number, diameterTop: number, diameterBottom: number, tessellation: number, subdivisions: any, scene?: Scene, updatable?: any, sideOrientation?: number): Mesh;
  79525. /**
  79526. * Creates a torus mesh. Please consider using the same method from the MeshBuilder class instead
  79527. * @param name defines the name of the mesh to create
  79528. * @param diameter sets the diameter size (float) of the torus (default 1)
  79529. * @param thickness sets the diameter size of the tube of the torus (float, default 0.5)
  79530. * @param tessellation sets the number of torus sides (postive integer, default 16)
  79531. * @param scene defines the hosting scene
  79532. * @param updatable defines if the mesh must be flagged as updatable
  79533. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  79534. * @returns a new Mesh
  79535. */
  79536. static CreateTorus(name: string, diameter: number, thickness: number, tessellation: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  79537. /**
  79538. * Creates a torus knot mesh. Please consider using the same method from the MeshBuilder class instead
  79539. * @param name defines the name of the mesh to create
  79540. * @param radius sets the global radius size (float) of the torus knot (default 2)
  79541. * @param tube sets the diameter size of the tube of the torus (float, default 0.5)
  79542. * @param radialSegments sets the number of sides on each tube segments (positive integer, default 32)
  79543. * @param tubularSegments sets the number of tubes to decompose the knot into (positive integer, default 32)
  79544. * @param p the number of windings on X axis (positive integers, default 2)
  79545. * @param q the number of windings on Y axis (positive integers, default 3)
  79546. * @param scene defines the hosting scene
  79547. * @param updatable defines if the mesh must be flagged as updatable
  79548. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  79549. * @returns a new Mesh
  79550. */
  79551. static CreateTorusKnot(name: string, radius: number, tube: number, radialSegments: number, tubularSegments: number, p: number, q: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  79552. /**
  79553. * Creates a line mesh. Please consider using the same method from the MeshBuilder class instead.
  79554. * @param name defines the name of the mesh to create
  79555. * @param points is an array successive Vector3
  79556. * @param scene defines the hosting scene
  79557. * @param updatable defines if the mesh must be flagged as updatable
  79558. * @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).
  79559. * @returns a new Mesh
  79560. */
  79561. static CreateLines(name: string, points: Vector3[], scene?: Nullable<Scene>, updatable?: boolean, instance?: Nullable<LinesMesh>): LinesMesh;
  79562. /**
  79563. * Creates a dashed line mesh. Please consider using the same method from the MeshBuilder class instead
  79564. * @param name defines the name of the mesh to create
  79565. * @param points is an array successive Vector3
  79566. * @param dashSize is the size of the dashes relatively the dash number (positive float, default 3)
  79567. * @param gapSize is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  79568. * @param dashNb is the intended total number of dashes (positive integer, default 200)
  79569. * @param scene defines the hosting scene
  79570. * @param updatable defines if the mesh must be flagged as updatable
  79571. * @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)
  79572. * @returns a new Mesh
  79573. */
  79574. static CreateDashedLines(name: string, points: Vector3[], dashSize: number, gapSize: number, dashNb: number, scene?: Nullable<Scene>, updatable?: boolean, instance?: LinesMesh): LinesMesh;
  79575. /**
  79576. * Creates a polygon mesh.Please consider using the same method from the MeshBuilder class instead
  79577. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh.
  79578. * 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.
  79579. * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  79580. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  79581. * Remember you can only change the shape positions, not their number when updating a polygon.
  79582. * @see http://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  79583. * @param name defines the name of the mesh to create
  79584. * @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
  79585. * @param scene defines the hosting scene
  79586. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  79587. * @param updatable defines if the mesh must be flagged as updatable
  79588. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  79589. * @param earcutInjection can be used to inject your own earcut reference
  79590. * @returns a new Mesh
  79591. */
  79592. static CreatePolygon(name: string, shape: Vector3[], scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number, earcutInjection?: any): Mesh;
  79593. /**
  79594. * Creates an extruded polygon mesh, with depth in the Y direction. Please consider using the same method from the MeshBuilder class instead.
  79595. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-non-regular-polygon
  79596. * @param name defines the name of the mesh to create
  79597. * @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
  79598. * @param depth defines the height of extrusion
  79599. * @param scene defines the hosting scene
  79600. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  79601. * @param updatable defines if the mesh must be flagged as updatable
  79602. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  79603. * @param earcutInjection can be used to inject your own earcut reference
  79604. * @returns a new Mesh
  79605. */
  79606. static ExtrudePolygon(name: string, shape: Vector3[], depth: number, scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number, earcutInjection?: any): Mesh;
  79607. /**
  79608. * Creates an extruded shape mesh.
  79609. * 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
  79610. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  79611. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  79612. * @param name defines the name of the mesh to create
  79613. * @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
  79614. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  79615. * @param scale is the value to scale the shape
  79616. * @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
  79617. * @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
  79618. * @param scene defines the hosting scene
  79619. * @param updatable defines if the mesh must be flagged as updatable
  79620. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  79621. * @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)
  79622. * @returns a new Mesh
  79623. */
  79624. static ExtrudeShape(name: string, shape: Vector3[], path: Vector3[], scale: number, rotation: number, cap: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  79625. /**
  79626. * Creates an custom extruded shape mesh.
  79627. * The custom extrusion is a parametric shape.
  79628. * It has no predefined shape. Its final shape will depend on the input parameters.
  79629. * Please consider using the same method from the MeshBuilder class instead
  79630. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  79631. * @param name defines the name of the mesh to create
  79632. * @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
  79633. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  79634. * @param scaleFunction is a custom Javascript function called on each path point
  79635. * @param rotationFunction is a custom Javascript function called on each path point
  79636. * @param ribbonCloseArray forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  79637. * @param ribbonClosePath forces the extrusion underlying ribbon to close its `pathArray`
  79638. * @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
  79639. * @param scene defines the hosting scene
  79640. * @param updatable defines if the mesh must be flagged as updatable
  79641. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  79642. * @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)
  79643. * @returns a new Mesh
  79644. */
  79645. 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;
  79646. /**
  79647. * Creates lathe mesh.
  79648. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe.
  79649. * Please consider using the same method from the MeshBuilder class instead
  79650. * @param name defines the name of the mesh to create
  79651. * @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
  79652. * @param radius is the radius value of the lathe
  79653. * @param tessellation is the side number of the lathe.
  79654. * @param scene defines the hosting scene
  79655. * @param updatable defines if the mesh must be flagged as updatable
  79656. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  79657. * @returns a new Mesh
  79658. */
  79659. static CreateLathe(name: string, shape: Vector3[], radius: number, tessellation: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  79660. /**
  79661. * Creates a plane mesh. Please consider using the same method from the MeshBuilder class instead
  79662. * @param name defines the name of the mesh to create
  79663. * @param size sets the size (float) of both sides of the plane at once (default 1)
  79664. * @param scene defines the hosting scene
  79665. * @param updatable defines if the mesh must be flagged as updatable
  79666. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  79667. * @returns a new Mesh
  79668. */
  79669. static CreatePlane(name: string, size: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  79670. /**
  79671. * Creates a ground mesh.
  79672. * Please consider using the same method from the MeshBuilder class instead
  79673. * @param name defines the name of the mesh to create
  79674. * @param width set the width of the ground
  79675. * @param height set the height of the ground
  79676. * @param subdivisions sets the number of subdivisions per side
  79677. * @param scene defines the hosting scene
  79678. * @param updatable defines if the mesh must be flagged as updatable
  79679. * @returns a new Mesh
  79680. */
  79681. static CreateGround(name: string, width: number, height: number, subdivisions: number, scene?: Scene, updatable?: boolean): Mesh;
  79682. /**
  79683. * Creates a tiled ground mesh.
  79684. * Please consider using the same method from the MeshBuilder class instead
  79685. * @param name defines the name of the mesh to create
  79686. * @param xmin set the ground minimum X coordinate
  79687. * @param zmin set the ground minimum Y coordinate
  79688. * @param xmax set the ground maximum X coordinate
  79689. * @param zmax set the ground maximum Z coordinate
  79690. * @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
  79691. * @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
  79692. * @param scene defines the hosting scene
  79693. * @param updatable defines if the mesh must be flagged as updatable
  79694. * @returns a new Mesh
  79695. */
  79696. static CreateTiledGround(name: string, xmin: number, zmin: number, xmax: number, zmax: number, subdivisions: {
  79697. w: number;
  79698. h: number;
  79699. }, precision: {
  79700. w: number;
  79701. h: number;
  79702. }, scene: Scene, updatable?: boolean): Mesh;
  79703. /**
  79704. * Creates a ground mesh from a height map.
  79705. * Please consider using the same method from the MeshBuilder class instead
  79706. * @see http://doc.babylonjs.com/babylon101/height_map
  79707. * @param name defines the name of the mesh to create
  79708. * @param url sets the URL of the height map image resource
  79709. * @param width set the ground width size
  79710. * @param height set the ground height size
  79711. * @param subdivisions sets the number of subdivision per side
  79712. * @param minHeight is the minimum altitude on the ground
  79713. * @param maxHeight is the maximum altitude on the ground
  79714. * @param scene defines the hosting scene
  79715. * @param updatable defines if the mesh must be flagged as updatable
  79716. * @param onReady is a callback function that will be called once the mesh is built (the height map download can last some time)
  79717. * @param alphaFilter will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  79718. * @returns a new Mesh
  79719. */
  79720. 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;
  79721. /**
  79722. * Creates a tube mesh.
  79723. * The tube is a parametric shape.
  79724. * It has no predefined shape. Its final shape will depend on the input parameters.
  79725. * Please consider using the same method from the MeshBuilder class instead
  79726. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  79727. * @param name defines the name of the mesh to create
  79728. * @param path is a required array of successive Vector3. It is the curve used as the axis of the tube
  79729. * @param radius sets the tube radius size
  79730. * @param tessellation is the number of sides on the tubular surface
  79731. * @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
  79732. * @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
  79733. * @param scene defines the hosting scene
  79734. * @param updatable defines if the mesh must be flagged as updatable
  79735. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  79736. * @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)
  79737. * @returns a new Mesh
  79738. */
  79739. static CreateTube(name: string, path: Vector3[], radius: number, tessellation: number, radiusFunction: {
  79740. (i: number, distance: number): number;
  79741. }, cap: number, scene: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  79742. /**
  79743. * Creates a polyhedron mesh.
  79744. * Please consider using the same method from the MeshBuilder class instead.
  79745. * * 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
  79746. * * The parameter `size` (positive float, default 1) sets the polygon size
  79747. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  79748. * * 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`
  79749. * * 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
  79750. * * 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)`)
  79751. * * 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
  79752. * * 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
  79753. * * You can also set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  79754. * * If you create a double-sided mesh, you can choose what parts of 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
  79755. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  79756. * @param name defines the name of the mesh to create
  79757. * @param options defines the options used to create the mesh
  79758. * @param scene defines the hosting scene
  79759. * @returns a new Mesh
  79760. */
  79761. static CreatePolyhedron(name: string, options: {
  79762. type?: number;
  79763. size?: number;
  79764. sizeX?: number;
  79765. sizeY?: number;
  79766. sizeZ?: number;
  79767. custom?: any;
  79768. faceUV?: Vector4[];
  79769. faceColors?: Color4[];
  79770. updatable?: boolean;
  79771. sideOrientation?: number;
  79772. }, scene: Scene): Mesh;
  79773. /**
  79774. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  79775. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  79776. * * 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`)
  79777. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  79778. * * 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
  79779. * * You can also set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  79780. * * If you create a double-sided mesh, you can choose what parts of 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
  79781. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  79782. * @param name defines the name of the mesh
  79783. * @param options defines the options used to create the mesh
  79784. * @param scene defines the hosting scene
  79785. * @returns a new Mesh
  79786. * @see http://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  79787. */
  79788. static CreateIcoSphere(name: string, options: {
  79789. radius?: number;
  79790. flat?: boolean;
  79791. subdivisions?: number;
  79792. sideOrientation?: number;
  79793. updatable?: boolean;
  79794. }, scene: Scene): Mesh;
  79795. /**
  79796. * Creates a decal mesh.
  79797. * Please consider using the same method from the MeshBuilder class instead.
  79798. * A decal is a mesh usually applied as a model onto the surface of another mesh
  79799. * @param name defines the name of the mesh
  79800. * @param sourceMesh defines the mesh receiving the decal
  79801. * @param position sets the position of the decal in world coordinates
  79802. * @param normal sets the normal of the mesh where the decal is applied onto in world coordinates
  79803. * @param size sets the decal scaling
  79804. * @param angle sets the angle to rotate the decal
  79805. * @returns a new Mesh
  79806. */
  79807. static CreateDecal(name: string, sourceMesh: AbstractMesh, position: Vector3, normal: Vector3, size: Vector3, angle: number): Mesh;
  79808. /**
  79809. * Prepare internal position array for software CPU skinning
  79810. * @returns original positions used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh
  79811. */
  79812. setPositionsForCPUSkinning(): Float32Array;
  79813. /**
  79814. * Prepare internal normal array for software CPU skinning
  79815. * @returns original normals used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh.
  79816. */
  79817. setNormalsForCPUSkinning(): Float32Array;
  79818. /**
  79819. * Updates the vertex buffer by applying transformation from the bones
  79820. * @param skeleton defines the skeleton to apply to current mesh
  79821. * @returns the current mesh
  79822. */
  79823. applySkeleton(skeleton: Skeleton): Mesh;
  79824. /**
  79825. * 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
  79826. * @param meshes defines the list of meshes to scan
  79827. * @returns an object `{min:` Vector3`, max:` Vector3`}`
  79828. */
  79829. static MinMax(meshes: AbstractMesh[]): {
  79830. min: Vector3;
  79831. max: Vector3;
  79832. };
  79833. /**
  79834. * Returns the center of the `{min:` Vector3`, max:` Vector3`}` or the center of MinMax vector3 computed from a mesh array
  79835. * @param meshesOrMinMaxVector could be an array of meshes or a `{min:` Vector3`, max:` Vector3`}` object
  79836. * @returns a vector3
  79837. */
  79838. static Center(meshesOrMinMaxVector: {
  79839. min: Vector3;
  79840. max: Vector3;
  79841. } | AbstractMesh[]): Vector3;
  79842. /**
  79843. * Merge the array of meshes into a single mesh for performance reasons.
  79844. * @param meshes defines he vertices source. They should all be of the same material. Entries can empty
  79845. * @param disposeSource when true (default), dispose of the vertices from the source meshes
  79846. * @param allow32BitsIndices when the sum of the vertices > 64k, this must be set to true
  79847. * @param meshSubclass when set, vertices inserted into this Mesh. Meshes can then be merged into a Mesh sub-class.
  79848. * @param subdivideWithSubMeshes when true (false default), subdivide mesh to his subMesh array with meshes source.
  79849. * @param multiMultiMaterials when true (false default), subdivide mesh and accept multiple multi materials, ignores subdivideWithSubMeshes.
  79850. * @returns a new mesh
  79851. */
  79852. static MergeMeshes(meshes: Array<Mesh>, disposeSource?: boolean, allow32BitsIndices?: boolean, meshSubclass?: Mesh, subdivideWithSubMeshes?: boolean, multiMultiMaterials?: boolean): Nullable<Mesh>;
  79853. /** @hidden */
  79854. addInstance(instance: InstancedMesh): void;
  79855. /** @hidden */
  79856. removeInstance(instance: InstancedMesh): void;
  79857. }
  79858. }
  79859. declare module BABYLON {
  79860. /**
  79861. * Base class for the main features of a material in Babylon.js
  79862. */
  79863. export class Material implements IAnimatable {
  79864. /**
  79865. * Returns the triangle fill mode
  79866. */
  79867. static readonly TriangleFillMode: number;
  79868. /**
  79869. * Returns the wireframe mode
  79870. */
  79871. static readonly WireFrameFillMode: number;
  79872. /**
  79873. * Returns the point fill mode
  79874. */
  79875. static readonly PointFillMode: number;
  79876. /**
  79877. * Returns the point list draw mode
  79878. */
  79879. static readonly PointListDrawMode: number;
  79880. /**
  79881. * Returns the line list draw mode
  79882. */
  79883. static readonly LineListDrawMode: number;
  79884. /**
  79885. * Returns the line loop draw mode
  79886. */
  79887. static readonly LineLoopDrawMode: number;
  79888. /**
  79889. * Returns the line strip draw mode
  79890. */
  79891. static readonly LineStripDrawMode: number;
  79892. /**
  79893. * Returns the triangle strip draw mode
  79894. */
  79895. static readonly TriangleStripDrawMode: number;
  79896. /**
  79897. * Returns the triangle fan draw mode
  79898. */
  79899. static readonly TriangleFanDrawMode: number;
  79900. /**
  79901. * Stores the clock-wise side orientation
  79902. */
  79903. static readonly ClockWiseSideOrientation: number;
  79904. /**
  79905. * Stores the counter clock-wise side orientation
  79906. */
  79907. static readonly CounterClockWiseSideOrientation: number;
  79908. /**
  79909. * The dirty texture flag value
  79910. */
  79911. static readonly TextureDirtyFlag: number;
  79912. /**
  79913. * The dirty light flag value
  79914. */
  79915. static readonly LightDirtyFlag: number;
  79916. /**
  79917. * The dirty fresnel flag value
  79918. */
  79919. static readonly FresnelDirtyFlag: number;
  79920. /**
  79921. * The dirty attribute flag value
  79922. */
  79923. static readonly AttributesDirtyFlag: number;
  79924. /**
  79925. * The dirty misc flag value
  79926. */
  79927. static readonly MiscDirtyFlag: number;
  79928. /**
  79929. * The all dirty flag value
  79930. */
  79931. static readonly AllDirtyFlag: number;
  79932. /**
  79933. * The ID of the material
  79934. */
  79935. id: string;
  79936. /**
  79937. * Gets or sets the unique id of the material
  79938. */
  79939. uniqueId: number;
  79940. /**
  79941. * The name of the material
  79942. */
  79943. name: string;
  79944. /**
  79945. * Gets or sets user defined metadata
  79946. */
  79947. metadata: any;
  79948. /**
  79949. * For internal use only. Please do not use.
  79950. */
  79951. reservedDataStore: any;
  79952. /**
  79953. * Specifies if the ready state should be checked on each call
  79954. */
  79955. checkReadyOnEveryCall: boolean;
  79956. /**
  79957. * Specifies if the ready state should be checked once
  79958. */
  79959. checkReadyOnlyOnce: boolean;
  79960. /**
  79961. * The state of the material
  79962. */
  79963. state: string;
  79964. /**
  79965. * The alpha value of the material
  79966. */
  79967. protected _alpha: number;
  79968. /**
  79969. * List of inspectable custom properties (used by the Inspector)
  79970. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  79971. */
  79972. inspectableCustomProperties: IInspectable[];
  79973. /**
  79974. * Sets the alpha value of the material
  79975. */
  79976. /**
  79977. * Gets the alpha value of the material
  79978. */
  79979. alpha: number;
  79980. /**
  79981. * Specifies if back face culling is enabled
  79982. */
  79983. protected _backFaceCulling: boolean;
  79984. /**
  79985. * Sets the back-face culling state
  79986. */
  79987. /**
  79988. * Gets the back-face culling state
  79989. */
  79990. backFaceCulling: boolean;
  79991. /**
  79992. * Stores the value for side orientation
  79993. */
  79994. sideOrientation: number;
  79995. /**
  79996. * Callback triggered when the material is compiled
  79997. */
  79998. onCompiled: (effect: Effect) => void;
  79999. /**
  80000. * Callback triggered when an error occurs
  80001. */
  80002. onError: (effect: Effect, errors: string) => void;
  80003. /**
  80004. * Callback triggered to get the render target textures
  80005. */
  80006. getRenderTargetTextures: () => SmartArray<RenderTargetTexture>;
  80007. /**
  80008. * Gets a boolean indicating that current material needs to register RTT
  80009. */
  80010. readonly hasRenderTargetTextures: boolean;
  80011. /**
  80012. * Specifies if the material should be serialized
  80013. */
  80014. doNotSerialize: boolean;
  80015. /**
  80016. * @hidden
  80017. */
  80018. _storeEffectOnSubMeshes: boolean;
  80019. /**
  80020. * Stores the animations for the material
  80021. */
  80022. animations: Array<Animation>;
  80023. /**
  80024. * An event triggered when the material is disposed
  80025. */
  80026. onDisposeObservable: Observable<Material>;
  80027. /**
  80028. * An observer which watches for dispose events
  80029. */
  80030. private _onDisposeObserver;
  80031. private _onUnBindObservable;
  80032. /**
  80033. * Called during a dispose event
  80034. */
  80035. onDispose: () => void;
  80036. private _onBindObservable;
  80037. /**
  80038. * An event triggered when the material is bound
  80039. */
  80040. readonly onBindObservable: Observable<AbstractMesh>;
  80041. /**
  80042. * An observer which watches for bind events
  80043. */
  80044. private _onBindObserver;
  80045. /**
  80046. * Called during a bind event
  80047. */
  80048. onBind: (Mesh: AbstractMesh) => void;
  80049. /**
  80050. * An event triggered when the material is unbound
  80051. */
  80052. readonly onUnBindObservable: Observable<Material>;
  80053. /**
  80054. * Stores the value of the alpha mode
  80055. */
  80056. private _alphaMode;
  80057. /**
  80058. * Sets the value of the alpha mode.
  80059. *
  80060. * | Value | Type | Description |
  80061. * | --- | --- | --- |
  80062. * | 0 | ALPHA_DISABLE | |
  80063. * | 1 | ALPHA_ADD | |
  80064. * | 2 | ALPHA_COMBINE | |
  80065. * | 3 | ALPHA_SUBTRACT | |
  80066. * | 4 | ALPHA_MULTIPLY | |
  80067. * | 5 | ALPHA_MAXIMIZED | |
  80068. * | 6 | ALPHA_ONEONE | |
  80069. * | 7 | ALPHA_PREMULTIPLIED | |
  80070. * | 8 | ALPHA_PREMULTIPLIED_PORTERDUFF | |
  80071. * | 9 | ALPHA_INTERPOLATE | |
  80072. * | 10 | ALPHA_SCREENMODE | |
  80073. *
  80074. */
  80075. /**
  80076. * Gets the value of the alpha mode
  80077. */
  80078. alphaMode: number;
  80079. /**
  80080. * Stores the state of the need depth pre-pass value
  80081. */
  80082. private _needDepthPrePass;
  80083. /**
  80084. * Sets the need depth pre-pass value
  80085. */
  80086. /**
  80087. * Gets the depth pre-pass value
  80088. */
  80089. needDepthPrePass: boolean;
  80090. /**
  80091. * Specifies if depth writing should be disabled
  80092. */
  80093. disableDepthWrite: boolean;
  80094. /**
  80095. * Specifies if depth writing should be forced
  80096. */
  80097. forceDepthWrite: boolean;
  80098. /**
  80099. * Specifies if there should be a separate pass for culling
  80100. */
  80101. separateCullingPass: boolean;
  80102. /**
  80103. * Stores the state specifing if fog should be enabled
  80104. */
  80105. private _fogEnabled;
  80106. /**
  80107. * Sets the state for enabling fog
  80108. */
  80109. /**
  80110. * Gets the value of the fog enabled state
  80111. */
  80112. fogEnabled: boolean;
  80113. /**
  80114. * Stores the size of points
  80115. */
  80116. pointSize: number;
  80117. /**
  80118. * Stores the z offset value
  80119. */
  80120. zOffset: number;
  80121. /**
  80122. * Gets a value specifying if wireframe mode is enabled
  80123. */
  80124. /**
  80125. * Sets the state of wireframe mode
  80126. */
  80127. wireframe: boolean;
  80128. /**
  80129. * Gets the value specifying if point clouds are enabled
  80130. */
  80131. /**
  80132. * Sets the state of point cloud mode
  80133. */
  80134. pointsCloud: boolean;
  80135. /**
  80136. * Gets the material fill mode
  80137. */
  80138. /**
  80139. * Sets the material fill mode
  80140. */
  80141. fillMode: number;
  80142. /**
  80143. * @hidden
  80144. * Stores the effects for the material
  80145. */
  80146. _effect: Nullable<Effect>;
  80147. /**
  80148. * @hidden
  80149. * Specifies if the material was previously ready
  80150. */
  80151. _wasPreviouslyReady: boolean;
  80152. /**
  80153. * Specifies if uniform buffers should be used
  80154. */
  80155. private _useUBO;
  80156. /**
  80157. * Stores a reference to the scene
  80158. */
  80159. private _scene;
  80160. /**
  80161. * Stores the fill mode state
  80162. */
  80163. private _fillMode;
  80164. /**
  80165. * Specifies if the depth write state should be cached
  80166. */
  80167. private _cachedDepthWriteState;
  80168. /**
  80169. * Stores the uniform buffer
  80170. */
  80171. protected _uniformBuffer: UniformBuffer;
  80172. /** @hidden */
  80173. _indexInSceneMaterialArray: number;
  80174. /** @hidden */
  80175. meshMap: Nullable<{
  80176. [id: string]: AbstractMesh | undefined;
  80177. }>;
  80178. /**
  80179. * Creates a material instance
  80180. * @param name defines the name of the material
  80181. * @param scene defines the scene to reference
  80182. * @param doNotAdd specifies if the material should be added to the scene
  80183. */
  80184. constructor(name: string, scene: Scene, doNotAdd?: boolean);
  80185. /**
  80186. * Returns a string representation of the current material
  80187. * @param fullDetails defines a boolean indicating which levels of logging is desired
  80188. * @returns a string with material information
  80189. */
  80190. toString(fullDetails?: boolean): string;
  80191. /**
  80192. * Gets the class name of the material
  80193. * @returns a string with the class name of the material
  80194. */
  80195. getClassName(): string;
  80196. /**
  80197. * Specifies if updates for the material been locked
  80198. */
  80199. readonly isFrozen: boolean;
  80200. /**
  80201. * Locks updates for the material
  80202. */
  80203. freeze(): void;
  80204. /**
  80205. * Unlocks updates for the material
  80206. */
  80207. unfreeze(): void;
  80208. /**
  80209. * Specifies if the material is ready to be used
  80210. * @param mesh defines the mesh to check
  80211. * @param useInstances specifies if instances should be used
  80212. * @returns a boolean indicating if the material is ready to be used
  80213. */
  80214. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  80215. /**
  80216. * Specifies that the submesh is ready to be used
  80217. * @param mesh defines the mesh to check
  80218. * @param subMesh defines which submesh to check
  80219. * @param useInstances specifies that instances should be used
  80220. * @returns a boolean indicating that the submesh is ready or not
  80221. */
  80222. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  80223. /**
  80224. * Returns the material effect
  80225. * @returns the effect associated with the material
  80226. */
  80227. getEffect(): Nullable<Effect>;
  80228. /**
  80229. * Returns the current scene
  80230. * @returns a Scene
  80231. */
  80232. getScene(): Scene;
  80233. /**
  80234. * Specifies if the material will require alpha blending
  80235. * @returns a boolean specifying if alpha blending is needed
  80236. */
  80237. needAlphaBlending(): boolean;
  80238. /**
  80239. * Specifies if the mesh will require alpha blending
  80240. * @param mesh defines the mesh to check
  80241. * @returns a boolean specifying if alpha blending is needed for the mesh
  80242. */
  80243. needAlphaBlendingForMesh(mesh: AbstractMesh): boolean;
  80244. /**
  80245. * Specifies if this material should be rendered in alpha test mode
  80246. * @returns a boolean specifying if an alpha test is needed.
  80247. */
  80248. needAlphaTesting(): boolean;
  80249. /**
  80250. * Gets the texture used for the alpha test
  80251. * @returns the texture to use for alpha testing
  80252. */
  80253. getAlphaTestTexture(): Nullable<BaseTexture>;
  80254. /**
  80255. * Marks the material to indicate that it needs to be re-calculated
  80256. */
  80257. markDirty(): void;
  80258. /** @hidden */
  80259. _preBind(effect?: Effect, overrideOrientation?: Nullable<number>): boolean;
  80260. /**
  80261. * Binds the material to the mesh
  80262. * @param world defines the world transformation matrix
  80263. * @param mesh defines the mesh to bind the material to
  80264. */
  80265. bind(world: Matrix, mesh?: Mesh): void;
  80266. /**
  80267. * Binds the submesh to the material
  80268. * @param world defines the world transformation matrix
  80269. * @param mesh defines the mesh containing the submesh
  80270. * @param subMesh defines the submesh to bind the material to
  80271. */
  80272. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  80273. /**
  80274. * Binds the world matrix to the material
  80275. * @param world defines the world transformation matrix
  80276. */
  80277. bindOnlyWorldMatrix(world: Matrix): void;
  80278. /**
  80279. * Binds the scene's uniform buffer to the effect.
  80280. * @param effect defines the effect to bind to the scene uniform buffer
  80281. * @param sceneUbo defines the uniform buffer storing scene data
  80282. */
  80283. bindSceneUniformBuffer(effect: Effect, sceneUbo: UniformBuffer): void;
  80284. /**
  80285. * Binds the view matrix to the effect
  80286. * @param effect defines the effect to bind the view matrix to
  80287. */
  80288. bindView(effect: Effect): void;
  80289. /**
  80290. * Binds the view projection matrix to the effect
  80291. * @param effect defines the effect to bind the view projection matrix to
  80292. */
  80293. bindViewProjection(effect: Effect): void;
  80294. /**
  80295. * Specifies if material alpha testing should be turned on for the mesh
  80296. * @param mesh defines the mesh to check
  80297. */
  80298. protected _shouldTurnAlphaTestOn(mesh: AbstractMesh): boolean;
  80299. /**
  80300. * Processes to execute after binding the material to a mesh
  80301. * @param mesh defines the rendered mesh
  80302. */
  80303. protected _afterBind(mesh?: Mesh): void;
  80304. /**
  80305. * Unbinds the material from the mesh
  80306. */
  80307. unbind(): void;
  80308. /**
  80309. * Gets the active textures from the material
  80310. * @returns an array of textures
  80311. */
  80312. getActiveTextures(): BaseTexture[];
  80313. /**
  80314. * Specifies if the material uses a texture
  80315. * @param texture defines the texture to check against the material
  80316. * @returns a boolean specifying if the material uses the texture
  80317. */
  80318. hasTexture(texture: BaseTexture): boolean;
  80319. /**
  80320. * Makes a duplicate of the material, and gives it a new name
  80321. * @param name defines the new name for the duplicated material
  80322. * @returns the cloned material
  80323. */
  80324. clone(name: string): Nullable<Material>;
  80325. /**
  80326. * Gets the meshes bound to the material
  80327. * @returns an array of meshes bound to the material
  80328. */
  80329. getBindedMeshes(): AbstractMesh[];
  80330. /**
  80331. * Force shader compilation
  80332. * @param mesh defines the mesh associated with this material
  80333. * @param onCompiled defines a function to execute once the material is compiled
  80334. * @param options defines the options to configure the compilation
  80335. */
  80336. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<{
  80337. clipPlane: boolean;
  80338. }>): void;
  80339. /**
  80340. * Force shader compilation
  80341. * @param mesh defines the mesh that will use this material
  80342. * @param options defines additional options for compiling the shaders
  80343. * @returns a promise that resolves when the compilation completes
  80344. */
  80345. forceCompilationAsync(mesh: AbstractMesh, options?: Partial<{
  80346. clipPlane: boolean;
  80347. }>): Promise<void>;
  80348. private static readonly _ImageProcessingDirtyCallBack;
  80349. private static readonly _TextureDirtyCallBack;
  80350. private static readonly _FresnelDirtyCallBack;
  80351. private static readonly _MiscDirtyCallBack;
  80352. private static readonly _LightsDirtyCallBack;
  80353. private static readonly _AttributeDirtyCallBack;
  80354. private static _FresnelAndMiscDirtyCallBack;
  80355. private static _TextureAndMiscDirtyCallBack;
  80356. private static readonly _DirtyCallbackArray;
  80357. private static readonly _RunDirtyCallBacks;
  80358. /**
  80359. * Marks a define in the material to indicate that it needs to be re-computed
  80360. * @param flag defines a flag used to determine which parts of the material have to be marked as dirty
  80361. */
  80362. markAsDirty(flag: number): void;
  80363. /**
  80364. * Marks all submeshes of a material to indicate that their material defines need to be re-calculated
  80365. * @param func defines a function which checks material defines against the submeshes
  80366. */
  80367. protected _markAllSubMeshesAsDirty(func: (defines: MaterialDefines) => void): void;
  80368. /**
  80369. * Indicates that image processing needs to be re-calculated for all submeshes
  80370. */
  80371. protected _markAllSubMeshesAsImageProcessingDirty(): void;
  80372. /**
  80373. * Indicates that textures need to be re-calculated for all submeshes
  80374. */
  80375. protected _markAllSubMeshesAsTexturesDirty(): void;
  80376. /**
  80377. * Indicates that fresnel needs to be re-calculated for all submeshes
  80378. */
  80379. protected _markAllSubMeshesAsFresnelDirty(): void;
  80380. /**
  80381. * Indicates that fresnel and misc need to be re-calculated for all submeshes
  80382. */
  80383. protected _markAllSubMeshesAsFresnelAndMiscDirty(): void;
  80384. /**
  80385. * Indicates that lights need to be re-calculated for all submeshes
  80386. */
  80387. protected _markAllSubMeshesAsLightsDirty(): void;
  80388. /**
  80389. * Indicates that attributes need to be re-calculated for all submeshes
  80390. */
  80391. protected _markAllSubMeshesAsAttributesDirty(): void;
  80392. /**
  80393. * Indicates that misc needs to be re-calculated for all submeshes
  80394. */
  80395. protected _markAllSubMeshesAsMiscDirty(): void;
  80396. /**
  80397. * Indicates that textures and misc need to be re-calculated for all submeshes
  80398. */
  80399. protected _markAllSubMeshesAsTexturesAndMiscDirty(): void;
  80400. /**
  80401. * Disposes the material
  80402. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  80403. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  80404. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  80405. */
  80406. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  80407. /** @hidden */
  80408. private releaseVertexArrayObject;
  80409. /**
  80410. * Serializes this material
  80411. * @returns the serialized material object
  80412. */
  80413. serialize(): any;
  80414. /**
  80415. * Creates a material from parsed material data
  80416. * @param parsedMaterial defines parsed material data
  80417. * @param scene defines the hosting scene
  80418. * @param rootUrl defines the root URL to use to load textures
  80419. * @returns a new material
  80420. */
  80421. static Parse(parsedMaterial: any, scene: Scene, rootUrl: string): any;
  80422. }
  80423. }
  80424. declare module BABYLON {
  80425. /**
  80426. * Base class for submeshes
  80427. */
  80428. export class BaseSubMesh {
  80429. /** @hidden */
  80430. _materialDefines: Nullable<MaterialDefines>;
  80431. /** @hidden */
  80432. _materialEffect: Nullable<Effect>;
  80433. /**
  80434. * Gets associated effect
  80435. */
  80436. readonly effect: Nullable<Effect>;
  80437. /**
  80438. * Sets associated effect (effect used to render this submesh)
  80439. * @param effect defines the effect to associate with
  80440. * @param defines defines the set of defines used to compile this effect
  80441. */
  80442. setEffect(effect: Nullable<Effect>, defines?: Nullable<MaterialDefines>): void;
  80443. }
  80444. /**
  80445. * Defines a subdivision inside a mesh
  80446. */
  80447. export class SubMesh extends BaseSubMesh implements ICullable {
  80448. /** the material index to use */
  80449. materialIndex: number;
  80450. /** vertex index start */
  80451. verticesStart: number;
  80452. /** vertices count */
  80453. verticesCount: number;
  80454. /** index start */
  80455. indexStart: number;
  80456. /** indices count */
  80457. indexCount: number;
  80458. /** @hidden */
  80459. _linesIndexCount: number;
  80460. private _mesh;
  80461. private _renderingMesh;
  80462. private _boundingInfo;
  80463. private _linesIndexBuffer;
  80464. /** @hidden */
  80465. _lastColliderWorldVertices: Nullable<Vector3[]>;
  80466. /** @hidden */
  80467. _trianglePlanes: Plane[];
  80468. /** @hidden */
  80469. _lastColliderTransformMatrix: Matrix;
  80470. /** @hidden */
  80471. _renderId: number;
  80472. /** @hidden */
  80473. _alphaIndex: number;
  80474. /** @hidden */
  80475. _distanceToCamera: number;
  80476. /** @hidden */
  80477. _id: number;
  80478. private _currentMaterial;
  80479. /**
  80480. * Add a new submesh to a mesh
  80481. * @param materialIndex defines the material index to use
  80482. * @param verticesStart defines vertex index start
  80483. * @param verticesCount defines vertices count
  80484. * @param indexStart defines index start
  80485. * @param indexCount defines indices count
  80486. * @param mesh defines the parent mesh
  80487. * @param renderingMesh defines an optional rendering mesh
  80488. * @param createBoundingBox defines if bounding box should be created for this submesh
  80489. * @returns the new submesh
  80490. */
  80491. static AddToMesh(materialIndex: number, verticesStart: number, verticesCount: number, indexStart: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean): SubMesh;
  80492. /**
  80493. * Creates a new submesh
  80494. * @param materialIndex defines the material index to use
  80495. * @param verticesStart defines vertex index start
  80496. * @param verticesCount defines vertices count
  80497. * @param indexStart defines index start
  80498. * @param indexCount defines indices count
  80499. * @param mesh defines the parent mesh
  80500. * @param renderingMesh defines an optional rendering mesh
  80501. * @param createBoundingBox defines if bounding box should be created for this submesh
  80502. */
  80503. constructor(
  80504. /** the material index to use */
  80505. materialIndex: number,
  80506. /** vertex index start */
  80507. verticesStart: number,
  80508. /** vertices count */
  80509. verticesCount: number,
  80510. /** index start */
  80511. indexStart: number,
  80512. /** indices count */
  80513. indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean);
  80514. /**
  80515. * Returns true if this submesh covers the entire parent mesh
  80516. * @ignorenaming
  80517. */
  80518. readonly IsGlobal: boolean;
  80519. /**
  80520. * Returns the submesh BoudingInfo object
  80521. * @returns current bounding info (or mesh's one if the submesh is global)
  80522. */
  80523. getBoundingInfo(): BoundingInfo;
  80524. /**
  80525. * Sets the submesh BoundingInfo
  80526. * @param boundingInfo defines the new bounding info to use
  80527. * @returns the SubMesh
  80528. */
  80529. setBoundingInfo(boundingInfo: BoundingInfo): SubMesh;
  80530. /**
  80531. * Returns the mesh of the current submesh
  80532. * @return the parent mesh
  80533. */
  80534. getMesh(): AbstractMesh;
  80535. /**
  80536. * Returns the rendering mesh of the submesh
  80537. * @returns the rendering mesh (could be different from parent mesh)
  80538. */
  80539. getRenderingMesh(): Mesh;
  80540. /**
  80541. * Returns the submesh material
  80542. * @returns null or the current material
  80543. */
  80544. getMaterial(): Nullable<Material>;
  80545. /**
  80546. * Sets a new updated BoundingInfo object to the submesh
  80547. * @returns the SubMesh
  80548. */
  80549. refreshBoundingInfo(): SubMesh;
  80550. /** @hidden */
  80551. _checkCollision(collider: Collider): boolean;
  80552. /**
  80553. * Updates the submesh BoundingInfo
  80554. * @param world defines the world matrix to use to update the bounding info
  80555. * @returns the submesh
  80556. */
  80557. updateBoundingInfo(world: DeepImmutable<Matrix>): SubMesh;
  80558. /**
  80559. * True is the submesh bounding box intersects the frustum defined by the passed array of planes.
  80560. * @param frustumPlanes defines the frustum planes
  80561. * @returns true if the submesh is intersecting with the frustum
  80562. */
  80563. isInFrustum(frustumPlanes: Plane[]): boolean;
  80564. /**
  80565. * True is the submesh bounding box is completely inside the frustum defined by the passed array of planes
  80566. * @param frustumPlanes defines the frustum planes
  80567. * @returns true if the submesh is inside the frustum
  80568. */
  80569. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  80570. /**
  80571. * Renders the submesh
  80572. * @param enableAlphaMode defines if alpha needs to be used
  80573. * @returns the submesh
  80574. */
  80575. render(enableAlphaMode: boolean): SubMesh;
  80576. /**
  80577. * @hidden
  80578. */
  80579. _getLinesIndexBuffer(indices: IndicesArray, engine: Engine): WebGLBuffer;
  80580. /**
  80581. * Checks if the submesh intersects with a ray
  80582. * @param ray defines the ray to test
  80583. * @returns true is the passed ray intersects the submesh bounding box
  80584. */
  80585. canIntersects(ray: Ray): boolean;
  80586. /**
  80587. * Intersects current submesh with a ray
  80588. * @param ray defines the ray to test
  80589. * @param positions defines mesh's positions array
  80590. * @param indices defines mesh's indices array
  80591. * @param fastCheck defines if only bounding info should be used
  80592. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  80593. * @returns intersection info or null if no intersection
  80594. */
  80595. intersects(ray: Ray, positions: Vector3[], indices: IndicesArray, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<IntersectionInfo>;
  80596. /** @hidden */
  80597. private _intersectLines;
  80598. /** @hidden */
  80599. private _intersectTriangles;
  80600. /** @hidden */
  80601. _rebuild(): void;
  80602. /**
  80603. * Creates a new submesh from the passed mesh
  80604. * @param newMesh defines the new hosting mesh
  80605. * @param newRenderingMesh defines an optional rendering mesh
  80606. * @returns the new submesh
  80607. */
  80608. clone(newMesh: AbstractMesh, newRenderingMesh?: Mesh): SubMesh;
  80609. /**
  80610. * Release associated resources
  80611. */
  80612. dispose(): void;
  80613. /**
  80614. * Gets the class name
  80615. * @returns the string "SubMesh".
  80616. */
  80617. getClassName(): string;
  80618. /**
  80619. * Creates a new submesh from indices data
  80620. * @param materialIndex the index of the main mesh material
  80621. * @param startIndex the index where to start the copy in the mesh indices array
  80622. * @param indexCount the number of indices to copy then from the startIndex
  80623. * @param mesh the main mesh to create the submesh from
  80624. * @param renderingMesh the optional rendering mesh
  80625. * @returns a new submesh
  80626. */
  80627. static CreateFromIndices(materialIndex: number, startIndex: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh): SubMesh;
  80628. }
  80629. }
  80630. declare module BABYLON {
  80631. /**
  80632. * Class used to store geometry data (vertex buffers + index buffer)
  80633. */
  80634. export class Geometry implements IGetSetVerticesData {
  80635. /**
  80636. * Gets or sets the ID of the geometry
  80637. */
  80638. id: string;
  80639. /**
  80640. * Gets or sets the unique ID of the geometry
  80641. */
  80642. uniqueId: number;
  80643. /**
  80644. * Gets the delay loading state of the geometry (none by default which means not delayed)
  80645. */
  80646. delayLoadState: number;
  80647. /**
  80648. * Gets the file containing the data to load when running in delay load state
  80649. */
  80650. delayLoadingFile: Nullable<string>;
  80651. /**
  80652. * Callback called when the geometry is updated
  80653. */
  80654. onGeometryUpdated: (geometry: Geometry, kind?: string) => void;
  80655. private _scene;
  80656. private _engine;
  80657. private _meshes;
  80658. private _totalVertices;
  80659. /** @hidden */
  80660. _indices: IndicesArray;
  80661. /** @hidden */
  80662. _vertexBuffers: {
  80663. [key: string]: VertexBuffer;
  80664. };
  80665. private _isDisposed;
  80666. private _extend;
  80667. private _boundingBias;
  80668. /** @hidden */
  80669. _delayInfo: Array<string>;
  80670. private _indexBuffer;
  80671. private _indexBufferIsUpdatable;
  80672. /** @hidden */
  80673. _boundingInfo: Nullable<BoundingInfo>;
  80674. /** @hidden */
  80675. _delayLoadingFunction: Nullable<(any: any, geometry: Geometry) => void>;
  80676. /** @hidden */
  80677. _softwareSkinningFrameId: number;
  80678. private _vertexArrayObjects;
  80679. private _updatable;
  80680. /** @hidden */
  80681. _positions: Nullable<Vector3[]>;
  80682. /**
  80683. * 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
  80684. */
  80685. /**
  80686. * 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
  80687. */
  80688. boundingBias: Vector2;
  80689. /**
  80690. * Static function used to attach a new empty geometry to a mesh
  80691. * @param mesh defines the mesh to attach the geometry to
  80692. * @returns the new Geometry
  80693. */
  80694. static CreateGeometryForMesh(mesh: Mesh): Geometry;
  80695. /**
  80696. * Creates a new geometry
  80697. * @param id defines the unique ID
  80698. * @param scene defines the hosting scene
  80699. * @param vertexData defines the VertexData used to get geometry data
  80700. * @param updatable defines if geometry must be updatable (false by default)
  80701. * @param mesh defines the mesh that will be associated with the geometry
  80702. */
  80703. constructor(id: string, scene: Scene, vertexData?: VertexData, updatable?: boolean, mesh?: Nullable<Mesh>);
  80704. /**
  80705. * Gets the current extend of the geometry
  80706. */
  80707. readonly extend: {
  80708. minimum: Vector3;
  80709. maximum: Vector3;
  80710. };
  80711. /**
  80712. * Gets the hosting scene
  80713. * @returns the hosting Scene
  80714. */
  80715. getScene(): Scene;
  80716. /**
  80717. * Gets the hosting engine
  80718. * @returns the hosting Engine
  80719. */
  80720. getEngine(): Engine;
  80721. /**
  80722. * Defines if the geometry is ready to use
  80723. * @returns true if the geometry is ready to be used
  80724. */
  80725. isReady(): boolean;
  80726. /**
  80727. * Gets a value indicating that the geometry should not be serialized
  80728. */
  80729. readonly doNotSerialize: boolean;
  80730. /** @hidden */
  80731. _rebuild(): void;
  80732. /**
  80733. * Affects all geometry data in one call
  80734. * @param vertexData defines the geometry data
  80735. * @param updatable defines if the geometry must be flagged as updatable (false as default)
  80736. */
  80737. setAllVerticesData(vertexData: VertexData, updatable?: boolean): void;
  80738. /**
  80739. * Set specific vertex data
  80740. * @param kind defines the data kind (Position, normal, etc...)
  80741. * @param data defines the vertex data to use
  80742. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  80743. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  80744. */
  80745. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): void;
  80746. /**
  80747. * Removes a specific vertex data
  80748. * @param kind defines the data kind (Position, normal, etc...)
  80749. */
  80750. removeVerticesData(kind: string): void;
  80751. /**
  80752. * Affect a vertex buffer to the geometry. the vertexBuffer.getKind() function is used to determine where to store the data
  80753. * @param buffer defines the vertex buffer to use
  80754. * @param totalVertices defines the total number of vertices for position kind (could be null)
  80755. */
  80756. setVerticesBuffer(buffer: VertexBuffer, totalVertices?: Nullable<number>): void;
  80757. /**
  80758. * Update a specific vertex buffer
  80759. * This function will directly update the underlying WebGLBuffer according to the passed numeric array or Float32Array
  80760. * It will do nothing if the buffer is not updatable
  80761. * @param kind defines the data kind (Position, normal, etc...)
  80762. * @param data defines the data to use
  80763. * @param offset defines the offset in the target buffer where to store the data
  80764. * @param useBytes set to true if the offset is in bytes
  80765. */
  80766. updateVerticesDataDirectly(kind: string, data: DataArray, offset: number, useBytes?: boolean): void;
  80767. /**
  80768. * Update a specific vertex buffer
  80769. * This function will create a new buffer if the current one is not updatable
  80770. * @param kind defines the data kind (Position, normal, etc...)
  80771. * @param data defines the data to use
  80772. * @param updateExtends defines if the geometry extends must be recomputed (false by default)
  80773. */
  80774. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean): void;
  80775. private _updateBoundingInfo;
  80776. /** @hidden */
  80777. _bind(effect: Nullable<Effect>, indexToBind?: Nullable<WebGLBuffer>): void;
  80778. /**
  80779. * Gets total number of vertices
  80780. * @returns the total number of vertices
  80781. */
  80782. getTotalVertices(): number;
  80783. /**
  80784. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  80785. * @param kind defines the data kind (Position, normal, etc...)
  80786. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  80787. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  80788. * @returns a float array containing vertex data
  80789. */
  80790. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  80791. /**
  80792. * Returns a boolean defining if the vertex data for the requested `kind` is updatable
  80793. * @param kind defines the data kind (Position, normal, etc...)
  80794. * @returns true if the vertex buffer with the specified kind is updatable
  80795. */
  80796. isVertexBufferUpdatable(kind: string): boolean;
  80797. /**
  80798. * Gets a specific vertex buffer
  80799. * @param kind defines the data kind (Position, normal, etc...)
  80800. * @returns a VertexBuffer
  80801. */
  80802. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  80803. /**
  80804. * Returns all vertex buffers
  80805. * @return an object holding all vertex buffers indexed by kind
  80806. */
  80807. getVertexBuffers(): Nullable<{
  80808. [key: string]: VertexBuffer;
  80809. }>;
  80810. /**
  80811. * Gets a boolean indicating if specific vertex buffer is present
  80812. * @param kind defines the data kind (Position, normal, etc...)
  80813. * @returns true if data is present
  80814. */
  80815. isVerticesDataPresent(kind: string): boolean;
  80816. /**
  80817. * Gets a list of all attached data kinds (Position, normal, etc...)
  80818. * @returns a list of string containing all kinds
  80819. */
  80820. getVerticesDataKinds(): string[];
  80821. /**
  80822. * Update index buffer
  80823. * @param indices defines the indices to store in the index buffer
  80824. * @param offset defines the offset in the target buffer where to store the data
  80825. * @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)
  80826. */
  80827. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): void;
  80828. /**
  80829. * Creates a new index buffer
  80830. * @param indices defines the indices to store in the index buffer
  80831. * @param totalVertices defines the total number of vertices (could be null)
  80832. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  80833. */
  80834. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): void;
  80835. /**
  80836. * Return the total number of indices
  80837. * @returns the total number of indices
  80838. */
  80839. getTotalIndices(): number;
  80840. /**
  80841. * Gets the index buffer array
  80842. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  80843. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  80844. * @returns the index buffer array
  80845. */
  80846. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  80847. /**
  80848. * Gets the index buffer
  80849. * @return the index buffer
  80850. */
  80851. getIndexBuffer(): Nullable<WebGLBuffer>;
  80852. /** @hidden */
  80853. _releaseVertexArrayObject(effect?: Nullable<Effect>): void;
  80854. /**
  80855. * Release the associated resources for a specific mesh
  80856. * @param mesh defines the source mesh
  80857. * @param shouldDispose defines if the geometry must be disposed if there is no more mesh pointing to it
  80858. */
  80859. releaseForMesh(mesh: Mesh, shouldDispose?: boolean): void;
  80860. /**
  80861. * Apply current geometry to a given mesh
  80862. * @param mesh defines the mesh to apply geometry to
  80863. */
  80864. applyToMesh(mesh: Mesh): void;
  80865. private _updateExtend;
  80866. private _applyToMesh;
  80867. private notifyUpdate;
  80868. /**
  80869. * Load the geometry if it was flagged as delay loaded
  80870. * @param scene defines the hosting scene
  80871. * @param onLoaded defines a callback called when the geometry is loaded
  80872. */
  80873. load(scene: Scene, onLoaded?: () => void): void;
  80874. private _queueLoad;
  80875. /**
  80876. * Invert the geometry to move from a right handed system to a left handed one.
  80877. */
  80878. toLeftHanded(): void;
  80879. /** @hidden */
  80880. _resetPointsArrayCache(): void;
  80881. /** @hidden */
  80882. _generatePointsArray(): boolean;
  80883. /**
  80884. * Gets a value indicating if the geometry is disposed
  80885. * @returns true if the geometry was disposed
  80886. */
  80887. isDisposed(): boolean;
  80888. private _disposeVertexArrayObjects;
  80889. /**
  80890. * Free all associated resources
  80891. */
  80892. dispose(): void;
  80893. /**
  80894. * Clone the current geometry into a new geometry
  80895. * @param id defines the unique ID of the new geometry
  80896. * @returns a new geometry object
  80897. */
  80898. copy(id: string): Geometry;
  80899. /**
  80900. * Serialize the current geometry info (and not the vertices data) into a JSON object
  80901. * @return a JSON representation of the current geometry data (without the vertices data)
  80902. */
  80903. serialize(): any;
  80904. private toNumberArray;
  80905. /**
  80906. * Serialize all vertices data into a JSON oject
  80907. * @returns a JSON representation of the current geometry data
  80908. */
  80909. serializeVerticeData(): any;
  80910. /**
  80911. * Extracts a clone of a mesh geometry
  80912. * @param mesh defines the source mesh
  80913. * @param id defines the unique ID of the new geometry object
  80914. * @returns the new geometry object
  80915. */
  80916. static ExtractFromMesh(mesh: Mesh, id: string): Nullable<Geometry>;
  80917. /**
  80918. * You should now use Tools.RandomId(), this method is still here for legacy reasons.
  80919. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  80920. * Be aware Math.random() could cause collisions, but:
  80921. * "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"
  80922. * @returns a string containing a new GUID
  80923. */
  80924. static RandomId(): string;
  80925. /** @hidden */
  80926. static _ImportGeometry(parsedGeometry: any, mesh: Mesh): void;
  80927. private static _CleanMatricesWeights;
  80928. /**
  80929. * Create a new geometry from persisted data (Using .babylon file format)
  80930. * @param parsedVertexData defines the persisted data
  80931. * @param scene defines the hosting scene
  80932. * @param rootUrl defines the root url to use to load assets (like delayed data)
  80933. * @returns the new geometry object
  80934. */
  80935. static Parse(parsedVertexData: any, scene: Scene, rootUrl: string): Nullable<Geometry>;
  80936. }
  80937. }
  80938. declare module BABYLON {
  80939. /**
  80940. * Define an interface for all classes that will get and set the data on vertices
  80941. */
  80942. export interface IGetSetVerticesData {
  80943. /**
  80944. * Gets a boolean indicating if specific vertex data is present
  80945. * @param kind defines the vertex data kind to use
  80946. * @returns true is data kind is present
  80947. */
  80948. isVerticesDataPresent(kind: string): boolean;
  80949. /**
  80950. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  80951. * @param kind defines the data kind (Position, normal, etc...)
  80952. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  80953. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  80954. * @returns a float array containing vertex data
  80955. */
  80956. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  80957. /**
  80958. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  80959. * @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.
  80960. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  80961. * @returns the indices array or an empty array if the mesh has no geometry
  80962. */
  80963. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  80964. /**
  80965. * Set specific vertex data
  80966. * @param kind defines the data kind (Position, normal, etc...)
  80967. * @param data defines the vertex data to use
  80968. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  80969. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  80970. */
  80971. setVerticesData(kind: string, data: FloatArray, updatable: boolean): void;
  80972. /**
  80973. * Update a specific associated vertex buffer
  80974. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  80975. * - VertexBuffer.PositionKind
  80976. * - VertexBuffer.UVKind
  80977. * - VertexBuffer.UV2Kind
  80978. * - VertexBuffer.UV3Kind
  80979. * - VertexBuffer.UV4Kind
  80980. * - VertexBuffer.UV5Kind
  80981. * - VertexBuffer.UV6Kind
  80982. * - VertexBuffer.ColorKind
  80983. * - VertexBuffer.MatricesIndicesKind
  80984. * - VertexBuffer.MatricesIndicesExtraKind
  80985. * - VertexBuffer.MatricesWeightsKind
  80986. * - VertexBuffer.MatricesWeightsExtraKind
  80987. * @param data defines the data source
  80988. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  80989. * @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)
  80990. */
  80991. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): void;
  80992. /**
  80993. * Creates a new index buffer
  80994. * @param indices defines the indices to store in the index buffer
  80995. * @param totalVertices defines the total number of vertices (could be null)
  80996. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  80997. */
  80998. setIndices(indices: IndicesArray, totalVertices: Nullable<number>, updatable?: boolean): void;
  80999. }
  81000. /**
  81001. * This class contains the various kinds of data on every vertex of a mesh used in determining its shape and appearance
  81002. */
  81003. export class VertexData {
  81004. /**
  81005. * Mesh side orientation : usually the external or front surface
  81006. */
  81007. static readonly FRONTSIDE: number;
  81008. /**
  81009. * Mesh side orientation : usually the internal or back surface
  81010. */
  81011. static readonly BACKSIDE: number;
  81012. /**
  81013. * Mesh side orientation : both internal and external or front and back surfaces
  81014. */
  81015. static readonly DOUBLESIDE: number;
  81016. /**
  81017. * Mesh side orientation : by default, `FRONTSIDE`
  81018. */
  81019. static readonly DEFAULTSIDE: number;
  81020. /**
  81021. * An array of the x, y, z position of each vertex [...., x, y, z, .....]
  81022. */
  81023. positions: Nullable<FloatArray>;
  81024. /**
  81025. * An array of the x, y, z normal vector of each vertex [...., x, y, z, .....]
  81026. */
  81027. normals: Nullable<FloatArray>;
  81028. /**
  81029. * An array of the x, y, z tangent vector of each vertex [...., x, y, z, .....]
  81030. */
  81031. tangents: Nullable<FloatArray>;
  81032. /**
  81033. * An array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  81034. */
  81035. uvs: Nullable<FloatArray>;
  81036. /**
  81037. * A second array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  81038. */
  81039. uvs2: Nullable<FloatArray>;
  81040. /**
  81041. * A third array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  81042. */
  81043. uvs3: Nullable<FloatArray>;
  81044. /**
  81045. * A fourth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  81046. */
  81047. uvs4: Nullable<FloatArray>;
  81048. /**
  81049. * A fifth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  81050. */
  81051. uvs5: Nullable<FloatArray>;
  81052. /**
  81053. * A sixth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  81054. */
  81055. uvs6: Nullable<FloatArray>;
  81056. /**
  81057. * An array of the r, g, b, a, color of each vertex [...., r, g, b, a, .....]
  81058. */
  81059. colors: Nullable<FloatArray>;
  81060. /**
  81061. * 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).
  81062. */
  81063. matricesIndices: Nullable<FloatArray>;
  81064. /**
  81065. * An array containing the list of weights defining the weight of each indexed matrix in the final computation
  81066. */
  81067. matricesWeights: Nullable<FloatArray>;
  81068. /**
  81069. * An array extending the number of possible indices
  81070. */
  81071. matricesIndicesExtra: Nullable<FloatArray>;
  81072. /**
  81073. * An array extending the number of possible weights when the number of indices is extended
  81074. */
  81075. matricesWeightsExtra: Nullable<FloatArray>;
  81076. /**
  81077. * An array of i, j, k the three vertex indices required for each triangular facet [...., i, j, k .....]
  81078. */
  81079. indices: Nullable<IndicesArray>;
  81080. /**
  81081. * Uses the passed data array to set the set the values for the specified kind of data
  81082. * @param data a linear array of floating numbers
  81083. * @param kind the type of data that is being set, eg positions, colors etc
  81084. */
  81085. set(data: FloatArray, kind: string): void;
  81086. /**
  81087. * Associates the vertexData to the passed Mesh.
  81088. * Sets it as updatable or not (default `false`)
  81089. * @param mesh the mesh the vertexData is applied to
  81090. * @param updatable when used and having the value true allows new data to update the vertexData
  81091. * @returns the VertexData
  81092. */
  81093. applyToMesh(mesh: Mesh, updatable?: boolean): VertexData;
  81094. /**
  81095. * Associates the vertexData to the passed Geometry.
  81096. * Sets it as updatable or not (default `false`)
  81097. * @param geometry the geometry the vertexData is applied to
  81098. * @param updatable when used and having the value true allows new data to update the vertexData
  81099. * @returns VertexData
  81100. */
  81101. applyToGeometry(geometry: Geometry, updatable?: boolean): VertexData;
  81102. /**
  81103. * Updates the associated mesh
  81104. * @param mesh the mesh to be updated
  81105. * @param updateExtends when true the mesh BoundingInfo will be renewed when and if position kind is updated, optional with default false
  81106. * @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
  81107. * @returns VertexData
  81108. */
  81109. updateMesh(mesh: Mesh): VertexData;
  81110. /**
  81111. * Updates the associated geometry
  81112. * @param geometry the geometry to be updated
  81113. * @param updateExtends when true BoundingInfo will be renewed when and if position kind is updated, optional with default false
  81114. * @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
  81115. * @returns VertexData.
  81116. */
  81117. updateGeometry(geometry: Geometry): VertexData;
  81118. private _applyTo;
  81119. private _update;
  81120. /**
  81121. * Transforms each position and each normal of the vertexData according to the passed Matrix
  81122. * @param matrix the transforming matrix
  81123. * @returns the VertexData
  81124. */
  81125. transform(matrix: Matrix): VertexData;
  81126. /**
  81127. * Merges the passed VertexData into the current one
  81128. * @param other the VertexData to be merged into the current one
  81129. * @param use32BitsIndices defines a boolean indicating if indices must be store in a 32 bits array
  81130. * @returns the modified VertexData
  81131. */
  81132. merge(other: VertexData, use32BitsIndices?: boolean): VertexData;
  81133. private _mergeElement;
  81134. private _validate;
  81135. /**
  81136. * Serializes the VertexData
  81137. * @returns a serialized object
  81138. */
  81139. serialize(): any;
  81140. /**
  81141. * Extracts the vertexData from a mesh
  81142. * @param mesh the mesh from which to extract the VertexData
  81143. * @param copyWhenShared defines if the VertexData must be cloned when shared between multiple meshes, optional, default false
  81144. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  81145. * @returns the object VertexData associated to the passed mesh
  81146. */
  81147. static ExtractFromMesh(mesh: Mesh, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  81148. /**
  81149. * Extracts the vertexData from the geometry
  81150. * @param geometry the geometry from which to extract the VertexData
  81151. * @param copyWhenShared defines if the VertexData must be cloned when the geometrty is shared between multiple meshes, optional, default false
  81152. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  81153. * @returns the object VertexData associated to the passed mesh
  81154. */
  81155. static ExtractFromGeometry(geometry: Geometry, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  81156. private static _ExtractFrom;
  81157. /**
  81158. * Creates the VertexData for a Ribbon
  81159. * @param options an object used to set the following optional parameters for the ribbon, required but can be empty
  81160. * * pathArray array of paths, each of which an array of successive Vector3
  81161. * * closeArray creates a seam between the first and the last paths of the pathArray, optional, default false
  81162. * * closePath creates a seam between the first and the last points of each path of the path array, optional, default false
  81163. * * 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
  81164. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  81165. * * 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)
  81166. * * 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)
  81167. * * invertUV swaps in the U and V coordinates when applying a texture, optional, default false
  81168. * * uvs a linear array, of length 2 * number of vertices, of custom UV values, optional
  81169. * * colors a linear array, of length 4 * number of vertices, of custom color values, optional
  81170. * @returns the VertexData of the ribbon
  81171. */
  81172. static CreateRibbon(options: {
  81173. pathArray: Vector3[][];
  81174. closeArray?: boolean;
  81175. closePath?: boolean;
  81176. offset?: number;
  81177. sideOrientation?: number;
  81178. frontUVs?: Vector4;
  81179. backUVs?: Vector4;
  81180. invertUV?: boolean;
  81181. uvs?: Vector2[];
  81182. colors?: Color4[];
  81183. }): VertexData;
  81184. /**
  81185. * Creates the VertexData for a box
  81186. * @param options an object used to set the following optional parameters for the box, required but can be empty
  81187. * * size sets the width, height and depth of the box to the value of size, optional default 1
  81188. * * width sets the width (x direction) of the box, overwrites the width set by size, optional, default size
  81189. * * height sets the height (y direction) of the box, overwrites the height set by size, optional, default size
  81190. * * depth sets the depth (z direction) of the box, overwrites the depth set by size, optional, default size
  81191. * * faceUV an array of 6 Vector4 elements used to set different images to each box side
  81192. * * faceColors an array of 6 Color3 elements used to set different colors to each box side
  81193. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  81194. * * 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)
  81195. * * 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)
  81196. * @returns the VertexData of the box
  81197. */
  81198. static CreateBox(options: {
  81199. size?: number;
  81200. width?: number;
  81201. height?: number;
  81202. depth?: number;
  81203. faceUV?: Vector4[];
  81204. faceColors?: Color4[];
  81205. sideOrientation?: number;
  81206. frontUVs?: Vector4;
  81207. backUVs?: Vector4;
  81208. }): VertexData;
  81209. /**
  81210. * Creates the VertexData for an ellipsoid, defaults to a sphere
  81211. * @param options an object used to set the following optional parameters for the box, required but can be empty
  81212. * * segments sets the number of horizontal strips optional, default 32
  81213. * * diameter sets the axes dimensions, diameterX, diameterY and diameterZ to the value of diameter, optional default 1
  81214. * * diameterX sets the diameterX (x direction) of the ellipsoid, overwrites the diameterX set by diameter, optional, default diameter
  81215. * * diameterY sets the diameterY (y direction) of the ellipsoid, overwrites the diameterY set by diameter, optional, default diameter
  81216. * * diameterZ sets the diameterZ (z direction) of the ellipsoid, overwrites the diameterZ set by diameter, optional, default diameter
  81217. * * 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
  81218. * * 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
  81219. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  81220. * * 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)
  81221. * * 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)
  81222. * @returns the VertexData of the ellipsoid
  81223. */
  81224. static CreateSphere(options: {
  81225. segments?: number;
  81226. diameter?: number;
  81227. diameterX?: number;
  81228. diameterY?: number;
  81229. diameterZ?: number;
  81230. arc?: number;
  81231. slice?: number;
  81232. sideOrientation?: number;
  81233. frontUVs?: Vector4;
  81234. backUVs?: Vector4;
  81235. }): VertexData;
  81236. /**
  81237. * Creates the VertexData for a cylinder, cone or prism
  81238. * @param options an object used to set the following optional parameters for the box, required but can be empty
  81239. * * height sets the height (y direction) of the cylinder, optional, default 2
  81240. * * diameterTop sets the diameter of the top of the cone, overwrites diameter, optional, default diameter
  81241. * * diameterBottom sets the diameter of the bottom of the cone, overwrites diameter, optional, default diameter
  81242. * * diameter sets the diameter of the top and bottom of the cone, optional default 1
  81243. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  81244. * * subdivisions` the number of rings along the cylinder height, optional, default 1
  81245. * * 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
  81246. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  81247. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  81248. * * hasRings when true makes each subdivision independantly treated as a face for faceUV and faceColors, optional, default false
  81249. * * enclose when true closes an open cylinder by adding extra flat faces between the height axis and vertical edges, think cut cake
  81250. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  81251. * * 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)
  81252. * * 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)
  81253. * @returns the VertexData of the cylinder, cone or prism
  81254. */
  81255. static CreateCylinder(options: {
  81256. height?: number;
  81257. diameterTop?: number;
  81258. diameterBottom?: number;
  81259. diameter?: number;
  81260. tessellation?: number;
  81261. subdivisions?: number;
  81262. arc?: number;
  81263. faceColors?: Color4[];
  81264. faceUV?: Vector4[];
  81265. hasRings?: boolean;
  81266. enclose?: boolean;
  81267. sideOrientation?: number;
  81268. frontUVs?: Vector4;
  81269. backUVs?: Vector4;
  81270. }): VertexData;
  81271. /**
  81272. * Creates the VertexData for a torus
  81273. * @param options an object used to set the following optional parameters for the box, required but can be empty
  81274. * * diameter the diameter of the torus, optional default 1
  81275. * * thickness the diameter of the tube forming the torus, optional default 0.5
  81276. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  81277. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  81278. * * 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)
  81279. * * 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)
  81280. * @returns the VertexData of the torus
  81281. */
  81282. static CreateTorus(options: {
  81283. diameter?: number;
  81284. thickness?: number;
  81285. tessellation?: number;
  81286. sideOrientation?: number;
  81287. frontUVs?: Vector4;
  81288. backUVs?: Vector4;
  81289. }): VertexData;
  81290. /**
  81291. * Creates the VertexData of the LineSystem
  81292. * @param options an object used to set the following optional parameters for the LineSystem, required but can be empty
  81293. * - lines an array of lines, each line being an array of successive Vector3
  81294. * - colors an array of line colors, each of the line colors being an array of successive Color4, one per line point
  81295. * @returns the VertexData of the LineSystem
  81296. */
  81297. static CreateLineSystem(options: {
  81298. lines: Vector3[][];
  81299. colors?: Nullable<Color4[][]>;
  81300. }): VertexData;
  81301. /**
  81302. * Create the VertexData for a DashedLines
  81303. * @param options an object used to set the following optional parameters for the DashedLines, required but can be empty
  81304. * - points an array successive Vector3
  81305. * - dashSize the size of the dashes relative to the dash number, optional, default 3
  81306. * - gapSize the size of the gap between two successive dashes relative to the dash number, optional, default 1
  81307. * - dashNb the intended total number of dashes, optional, default 200
  81308. * @returns the VertexData for the DashedLines
  81309. */
  81310. static CreateDashedLines(options: {
  81311. points: Vector3[];
  81312. dashSize?: number;
  81313. gapSize?: number;
  81314. dashNb?: number;
  81315. }): VertexData;
  81316. /**
  81317. * Creates the VertexData for a Ground
  81318. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  81319. * - width the width (x direction) of the ground, optional, default 1
  81320. * - height the height (z direction) of the ground, optional, default 1
  81321. * - subdivisions the number of subdivisions per side, optional, default 1
  81322. * @returns the VertexData of the Ground
  81323. */
  81324. static CreateGround(options: {
  81325. width?: number;
  81326. height?: number;
  81327. subdivisions?: number;
  81328. subdivisionsX?: number;
  81329. subdivisionsY?: number;
  81330. }): VertexData;
  81331. /**
  81332. * Creates the VertexData for a TiledGround by subdividing the ground into tiles
  81333. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  81334. * * xmin the ground minimum X coordinate, optional, default -1
  81335. * * zmin the ground minimum Z coordinate, optional, default -1
  81336. * * xmax the ground maximum X coordinate, optional, default 1
  81337. * * zmax the ground maximum Z coordinate, optional, default 1
  81338. * * 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}
  81339. * * 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}
  81340. * @returns the VertexData of the TiledGround
  81341. */
  81342. static CreateTiledGround(options: {
  81343. xmin: number;
  81344. zmin: number;
  81345. xmax: number;
  81346. zmax: number;
  81347. subdivisions?: {
  81348. w: number;
  81349. h: number;
  81350. };
  81351. precision?: {
  81352. w: number;
  81353. h: number;
  81354. };
  81355. }): VertexData;
  81356. /**
  81357. * Creates the VertexData of the Ground designed from a heightmap
  81358. * @param options an object used to set the following parameters for the Ground, required and provided by MeshBuilder.CreateGroundFromHeightMap
  81359. * * width the width (x direction) of the ground
  81360. * * height the height (z direction) of the ground
  81361. * * subdivisions the number of subdivisions per side
  81362. * * minHeight the minimum altitude on the ground, optional, default 0
  81363. * * maxHeight the maximum altitude on the ground, optional default 1
  81364. * * colorFilter the filter to apply to the image pixel colors to compute the height, optional Color3, default (0.3, 0.59, 0.11)
  81365. * * buffer the array holding the image color data
  81366. * * bufferWidth the width of image
  81367. * * bufferHeight the height of image
  81368. * * alphaFilter Remove any data where the alpha channel is below this value, defaults 0 (all data visible)
  81369. * @returns the VertexData of the Ground designed from a heightmap
  81370. */
  81371. static CreateGroundFromHeightMap(options: {
  81372. width: number;
  81373. height: number;
  81374. subdivisions: number;
  81375. minHeight: number;
  81376. maxHeight: number;
  81377. colorFilter: Color3;
  81378. buffer: Uint8Array;
  81379. bufferWidth: number;
  81380. bufferHeight: number;
  81381. alphaFilter: number;
  81382. }): VertexData;
  81383. /**
  81384. * Creates the VertexData for a Plane
  81385. * @param options an object used to set the following optional parameters for the plane, required but can be empty
  81386. * * size sets the width and height of the plane to the value of size, optional default 1
  81387. * * width sets the width (x direction) of the plane, overwrites the width set by size, optional, default size
  81388. * * height sets the height (y direction) of the plane, overwrites the height set by size, optional, default size
  81389. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  81390. * * 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)
  81391. * * 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)
  81392. * @returns the VertexData of the box
  81393. */
  81394. static CreatePlane(options: {
  81395. size?: number;
  81396. width?: number;
  81397. height?: number;
  81398. sideOrientation?: number;
  81399. frontUVs?: Vector4;
  81400. backUVs?: Vector4;
  81401. }): VertexData;
  81402. /**
  81403. * Creates the VertexData of the Disc or regular Polygon
  81404. * @param options an object used to set the following optional parameters for the disc, required but can be empty
  81405. * * radius the radius of the disc, optional default 0.5
  81406. * * tessellation the number of polygon sides, optional, default 64
  81407. * * 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
  81408. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  81409. * * 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)
  81410. * * 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)
  81411. * @returns the VertexData of the box
  81412. */
  81413. static CreateDisc(options: {
  81414. radius?: number;
  81415. tessellation?: number;
  81416. arc?: number;
  81417. sideOrientation?: number;
  81418. frontUVs?: Vector4;
  81419. backUVs?: Vector4;
  81420. }): VertexData;
  81421. /**
  81422. * Creates the VertexData for an irregular Polygon in the XoZ plane using a mesh built by polygonTriangulation.build()
  81423. * All parameters are provided by MeshBuilder.CreatePolygon as needed
  81424. * @param polygon a mesh built from polygonTriangulation.build()
  81425. * @param sideOrientation takes the values Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  81426. * @param fUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  81427. * @param fColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  81428. * @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)
  81429. * @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)
  81430. * @returns the VertexData of the Polygon
  81431. */
  81432. static CreatePolygon(polygon: Mesh, sideOrientation: number, fUV?: Vector4[], fColors?: Color4[], frontUVs?: Vector4, backUVs?: Vector4): VertexData;
  81433. /**
  81434. * Creates the VertexData of the IcoSphere
  81435. * @param options an object used to set the following optional parameters for the IcoSphere, required but can be empty
  81436. * * radius the radius of the IcoSphere, optional default 1
  81437. * * radiusX allows stretching in the x direction, optional, default radius
  81438. * * radiusY allows stretching in the y direction, optional, default radius
  81439. * * radiusZ allows stretching in the z direction, optional, default radius
  81440. * * flat when true creates a flat shaded mesh, optional, default true
  81441. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  81442. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  81443. * * 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)
  81444. * * 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)
  81445. * @returns the VertexData of the IcoSphere
  81446. */
  81447. static CreateIcoSphere(options: {
  81448. radius?: number;
  81449. radiusX?: number;
  81450. radiusY?: number;
  81451. radiusZ?: number;
  81452. flat?: boolean;
  81453. subdivisions?: number;
  81454. sideOrientation?: number;
  81455. frontUVs?: Vector4;
  81456. backUVs?: Vector4;
  81457. }): VertexData;
  81458. /**
  81459. * Creates the VertexData for a Polyhedron
  81460. * @param options an object used to set the following optional parameters for the polyhedron, required but can be empty
  81461. * * type provided types are:
  81462. * * 0 : Tetrahedron, 1 : Octahedron, 2 : Dodecahedron, 3 : Icosahedron, 4 : Rhombicuboctahedron, 5 : Triangular Prism, 6 : Pentagonal Prism, 7 : Hexagonal Prism, 8 : Square Pyramid (J1)
  81463. * * 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)
  81464. * * size the size of the IcoSphere, optional default 1
  81465. * * sizeX allows stretching in the x direction, optional, default size
  81466. * * sizeY allows stretching in the y direction, optional, default size
  81467. * * sizeZ allows stretching in the z direction, optional, default size
  81468. * * 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
  81469. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  81470. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  81471. * * flat when true creates a flat shaded mesh, optional, default true
  81472. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  81473. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  81474. * * 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)
  81475. * * 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)
  81476. * @returns the VertexData of the Polyhedron
  81477. */
  81478. static CreatePolyhedron(options: {
  81479. type?: number;
  81480. size?: number;
  81481. sizeX?: number;
  81482. sizeY?: number;
  81483. sizeZ?: number;
  81484. custom?: any;
  81485. faceUV?: Vector4[];
  81486. faceColors?: Color4[];
  81487. flat?: boolean;
  81488. sideOrientation?: number;
  81489. frontUVs?: Vector4;
  81490. backUVs?: Vector4;
  81491. }): VertexData;
  81492. /**
  81493. * Creates the VertexData for a TorusKnot
  81494. * @param options an object used to set the following optional parameters for the TorusKnot, required but can be empty
  81495. * * radius the radius of the torus knot, optional, default 2
  81496. * * tube the thickness of the tube, optional, default 0.5
  81497. * * radialSegments the number of sides on each tube segments, optional, default 32
  81498. * * tubularSegments the number of tubes to decompose the knot into, optional, default 32
  81499. * * p the number of windings around the z axis, optional, default 2
  81500. * * q the number of windings around the x axis, optional, default 3
  81501. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  81502. * * 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)
  81503. * * 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)
  81504. * @returns the VertexData of the Torus Knot
  81505. */
  81506. static CreateTorusKnot(options: {
  81507. radius?: number;
  81508. tube?: number;
  81509. radialSegments?: number;
  81510. tubularSegments?: number;
  81511. p?: number;
  81512. q?: number;
  81513. sideOrientation?: number;
  81514. frontUVs?: Vector4;
  81515. backUVs?: Vector4;
  81516. }): VertexData;
  81517. /**
  81518. * Compute normals for given positions and indices
  81519. * @param positions an array of vertex positions, [...., x, y, z, ......]
  81520. * @param indices an array of indices in groups of three for each triangular facet, [...., i, j, k, ......]
  81521. * @param normals an array of vertex normals, [...., x, y, z, ......]
  81522. * @param options an object used to set the following optional parameters for the TorusKnot, optional
  81523. * * facetNormals : optional array of facet normals (vector3)
  81524. * * facetPositions : optional array of facet positions (vector3)
  81525. * * facetPartitioning : optional partitioning array. facetPositions is required for facetPartitioning computation
  81526. * * ratio : optional partitioning ratio / bounding box, required for facetPartitioning computation
  81527. * * bInfo : optional bounding info, required for facetPartitioning computation
  81528. * * bbSize : optional bounding box size data, required for facetPartitioning computation
  81529. * * subDiv : optional partitioning data about subdivsions on each axis (int), required for facetPartitioning computation
  81530. * * useRightHandedSystem: optional boolean to for right handed system computation
  81531. * * depthSort : optional boolean to enable the facet depth sort computation
  81532. * * distanceTo : optional Vector3 to compute the facet depth from this location
  81533. * * depthSortedFacets : optional array of depthSortedFacets to store the facet distances from the reference location
  81534. */
  81535. static ComputeNormals(positions: any, indices: any, normals: any, options?: {
  81536. facetNormals?: any;
  81537. facetPositions?: any;
  81538. facetPartitioning?: any;
  81539. ratio?: number;
  81540. bInfo?: any;
  81541. bbSize?: Vector3;
  81542. subDiv?: any;
  81543. useRightHandedSystem?: boolean;
  81544. depthSort?: boolean;
  81545. distanceTo?: Vector3;
  81546. depthSortedFacets?: any;
  81547. }): void;
  81548. /** @hidden */
  81549. static _ComputeSides(sideOrientation: number, positions: FloatArray, indices: FloatArray, normals: FloatArray, uvs: FloatArray, frontUVs?: Vector4, backUVs?: Vector4): void;
  81550. /**
  81551. * Applies VertexData created from the imported parameters to the geometry
  81552. * @param parsedVertexData the parsed data from an imported file
  81553. * @param geometry the geometry to apply the VertexData to
  81554. */
  81555. static ImportVertexData(parsedVertexData: any, geometry: Geometry): void;
  81556. }
  81557. }
  81558. declare module BABYLON {
  81559. /**
  81560. * Class containing static functions to help procedurally build meshes
  81561. */
  81562. export class DiscBuilder {
  81563. /**
  81564. * Creates a plane polygonal mesh. By default, this is a disc
  81565. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  81566. * * 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
  81567. * * 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
  81568. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  81569. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  81570. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  81571. * @param name defines the name of the mesh
  81572. * @param options defines the options used to create the mesh
  81573. * @param scene defines the hosting scene
  81574. * @returns the plane polygonal mesh
  81575. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  81576. */
  81577. static CreateDisc(name: string, options: {
  81578. radius?: number;
  81579. tessellation?: number;
  81580. arc?: number;
  81581. updatable?: boolean;
  81582. sideOrientation?: number;
  81583. frontUVs?: Vector4;
  81584. backUVs?: Vector4;
  81585. }, scene?: Nullable<Scene>): Mesh;
  81586. }
  81587. }
  81588. declare module BABYLON {
  81589. /**
  81590. * The SPS is a single updatable mesh. The solid particles are simply separate parts or faces fo this big mesh.
  81591. *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.
  81592. * The SPS is also a particle system. It provides some methods to manage the particles.
  81593. * However it is behavior agnostic. This means it has no emitter, no particle physics, no particle recycler. You have to implement your own behavior.
  81594. *
  81595. * Full documentation here : http://doc.babylonjs.com/overviews/Solid_Particle_System
  81596. */
  81597. export class SolidParticleSystem implements IDisposable {
  81598. /**
  81599. * The SPS array of Solid Particle objects. Just access each particle as with any classic array.
  81600. * Example : var p = SPS.particles[i];
  81601. */
  81602. particles: SolidParticle[];
  81603. /**
  81604. * The SPS total number of particles. Read only. Use SPS.counter instead if you need to set your own value.
  81605. */
  81606. nbParticles: number;
  81607. /**
  81608. * If the particles must ever face the camera (default false). Useful for planar particles.
  81609. */
  81610. billboard: boolean;
  81611. /**
  81612. * Recompute normals when adding a shape
  81613. */
  81614. recomputeNormals: boolean;
  81615. /**
  81616. * This a counter ofr your own usage. It's not set by any SPS functions.
  81617. */
  81618. counter: number;
  81619. /**
  81620. * The SPS name. This name is also given to the underlying mesh.
  81621. */
  81622. name: string;
  81623. /**
  81624. * The SPS mesh. It's a standard BJS Mesh, so all the methods from the Mesh class are avalaible.
  81625. */
  81626. mesh: Mesh;
  81627. /**
  81628. * This empty object is intended to store some SPS specific or temporary values in order to lower the Garbage Collector activity.
  81629. * Please read : http://doc.babylonjs.com/overviews/Solid_Particle_System#garbage-collector-concerns
  81630. */
  81631. vars: any;
  81632. /**
  81633. * This array is populated when the SPS is set as 'pickable'.
  81634. * Each key of this array is a `faceId` value that you can get from a pickResult object.
  81635. * Each element of this array is an object `{idx: int, faceId: int}`.
  81636. * `idx` is the picked particle index in the `SPS.particles` array
  81637. * `faceId` is the picked face index counted within this particle.
  81638. * Please read : http://doc.babylonjs.com/overviews/Solid_Particle_System#pickable-particles
  81639. */
  81640. pickedParticles: {
  81641. idx: number;
  81642. faceId: number;
  81643. }[];
  81644. /**
  81645. * This array is populated when `enableDepthSort` is set to true.
  81646. * Each element of this array is an instance of the class DepthSortedParticle.
  81647. */
  81648. depthSortedParticles: DepthSortedParticle[];
  81649. /**
  81650. * If the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster). (Internal use only)
  81651. * @hidden
  81652. */
  81653. _bSphereOnly: boolean;
  81654. /**
  81655. * A number to multiply the boundind sphere radius by in order to reduce it for instance. (Internal use only)
  81656. * @hidden
  81657. */
  81658. _bSphereRadiusFactor: number;
  81659. private _scene;
  81660. private _positions;
  81661. private _indices;
  81662. private _normals;
  81663. private _colors;
  81664. private _uvs;
  81665. private _indices32;
  81666. private _positions32;
  81667. private _normals32;
  81668. private _fixedNormal32;
  81669. private _colors32;
  81670. private _uvs32;
  81671. private _index;
  81672. private _updatable;
  81673. private _pickable;
  81674. private _isVisibilityBoxLocked;
  81675. private _alwaysVisible;
  81676. private _depthSort;
  81677. private _shapeCounter;
  81678. private _copy;
  81679. private _color;
  81680. private _computeParticleColor;
  81681. private _computeParticleTexture;
  81682. private _computeParticleRotation;
  81683. private _computeParticleVertex;
  81684. private _computeBoundingBox;
  81685. private _depthSortParticles;
  81686. private _camera;
  81687. private _mustUnrotateFixedNormals;
  81688. private _particlesIntersect;
  81689. private _needs32Bits;
  81690. /**
  81691. * Creates a SPS (Solid Particle System) object.
  81692. * @param name (String) is the SPS name, this will be the underlying mesh name.
  81693. * @param scene (Scene) is the scene in which the SPS is added.
  81694. * @param options defines the options of the sps e.g.
  81695. * * updatable (optional boolean, default true) : if the SPS must be updatable or immutable.
  81696. * * isPickable (optional boolean, default false) : if the solid particles must be pickable.
  81697. * * enableDepthSort (optional boolean, default false) : if the solid particles must be sorted in the geometry according to their distance to the camera.
  81698. * * particleIntersection (optional boolean, default false) : if the solid particle intersections must be computed.
  81699. * * boundingSphereOnly (optional boolean, default false) : if the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster).
  81700. * * bSphereRadiusFactor (optional float, default 1.0) : a number to multiply the boundind sphere radius by in order to reduce it for instance.
  81701. * @example bSphereRadiusFactor = 1.0 / Math.sqrt(3.0) => the bounding sphere exactly matches a spherical mesh.
  81702. */
  81703. constructor(name: string, scene: Scene, options?: {
  81704. updatable?: boolean;
  81705. isPickable?: boolean;
  81706. enableDepthSort?: boolean;
  81707. particleIntersection?: boolean;
  81708. boundingSphereOnly?: boolean;
  81709. bSphereRadiusFactor?: number;
  81710. });
  81711. /**
  81712. * Builds the SPS underlying mesh. Returns a standard Mesh.
  81713. * If no model shape was added to the SPS, the returned mesh is just a single triangular plane.
  81714. * @returns the created mesh
  81715. */
  81716. buildMesh(): Mesh;
  81717. /**
  81718. * Digests the mesh and generates as many solid particles in the system as wanted. Returns the SPS.
  81719. * These particles will have the same geometry than the mesh parts and will be positioned at the same localisation than the mesh original places.
  81720. * Thus the particles generated from `digest()` have their property `position` set yet.
  81721. * @param mesh ( Mesh ) is the mesh to be digested
  81722. * @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
  81723. * {delta} (optional integer, default 0) is the random extra number of facets per particle , each particle will have between `facetNb` and `facetNb + delta` facets
  81724. * {number} (optional positive integer) is the wanted number of particles : each particle is built with `mesh_total_facets / number` facets
  81725. * @returns the current SPS
  81726. */
  81727. digest(mesh: Mesh, options?: {
  81728. facetNb?: number;
  81729. number?: number;
  81730. delta?: number;
  81731. }): SolidParticleSystem;
  81732. private _unrotateFixedNormals;
  81733. private _resetCopy;
  81734. private _meshBuilder;
  81735. private _posToShape;
  81736. private _uvsToShapeUV;
  81737. private _addParticle;
  81738. /**
  81739. * Adds some particles to the SPS from the model shape. Returns the shape id.
  81740. * Please read the doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#create-an-immutable-sps
  81741. * @param mesh is any Mesh object that will be used as a model for the solid particles.
  81742. * @param nb (positive integer) the number of particles to be created from this model
  81743. * @param options {positionFunction} is an optional javascript function to called for each particle on SPS creation.
  81744. * {vertexFunction} is an optional javascript function to called for each vertex of each particle on SPS creation
  81745. * @returns the number of shapes in the system
  81746. */
  81747. addShape(mesh: Mesh, nb: number, options?: {
  81748. positionFunction?: any;
  81749. vertexFunction?: any;
  81750. }): number;
  81751. private _rebuildParticle;
  81752. /**
  81753. * Rebuilds the whole mesh and updates the VBO : custom positions and vertices are recomputed if needed.
  81754. * @returns the SPS.
  81755. */
  81756. rebuildMesh(): SolidParticleSystem;
  81757. /**
  81758. * Sets all the particles : this method actually really updates the mesh according to the particle positions, rotations, colors, textures, etc.
  81759. * This method calls `updateParticle()` for each particle of the SPS.
  81760. * For an animated SPS, it is usually called within the render loop.
  81761. * @param start The particle index in the particle array where to start to compute the particle property values _(default 0)_
  81762. * @param end The particle index in the particle array where to stop to compute the particle property values _(default nbParticle - 1)_
  81763. * @param update If the mesh must be finally updated on this call after all the particle computations _(default true)_
  81764. * @returns the SPS.
  81765. */
  81766. setParticles(start?: number, end?: number, update?: boolean): SolidParticleSystem;
  81767. /**
  81768. * Disposes the SPS.
  81769. */
  81770. dispose(): void;
  81771. /**
  81772. * Visibilty helper : Recomputes the visible size according to the mesh bounding box
  81773. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  81774. * @returns the SPS.
  81775. */
  81776. refreshVisibleSize(): SolidParticleSystem;
  81777. /**
  81778. * Visibility helper : Sets the size of a visibility box, this sets the underlying mesh bounding box.
  81779. * @param size the size (float) of the visibility box
  81780. * note : this doesn't lock the SPS mesh bounding box.
  81781. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  81782. */
  81783. setVisibilityBox(size: number): void;
  81784. /**
  81785. * Gets whether the SPS as always visible or not
  81786. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  81787. */
  81788. /**
  81789. * Sets the SPS as always visible or not
  81790. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  81791. */
  81792. isAlwaysVisible: boolean;
  81793. /**
  81794. * Sets the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  81795. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  81796. */
  81797. /**
  81798. * Gets if the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  81799. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  81800. */
  81801. isVisibilityBoxLocked: boolean;
  81802. /**
  81803. * Tells to `setParticles()` to compute the particle rotations or not.
  81804. * Default value : true. The SPS is faster when it's set to false.
  81805. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  81806. */
  81807. /**
  81808. * Gets if `setParticles()` computes the particle rotations or not.
  81809. * Default value : true. The SPS is faster when it's set to false.
  81810. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  81811. */
  81812. computeParticleRotation: boolean;
  81813. /**
  81814. * Tells to `setParticles()` to compute the particle colors or not.
  81815. * Default value : true. The SPS is faster when it's set to false.
  81816. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  81817. */
  81818. /**
  81819. * Gets if `setParticles()` computes the particle colors or not.
  81820. * Default value : true. The SPS is faster when it's set to false.
  81821. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  81822. */
  81823. computeParticleColor: boolean;
  81824. /**
  81825. * Gets if `setParticles()` computes the particle textures or not.
  81826. * Default value : true. The SPS is faster when it's set to false.
  81827. * Note : the particle textures are stored values, so setting `computeParticleTexture` to false will keep yet the last colors set.
  81828. */
  81829. computeParticleTexture: boolean;
  81830. /**
  81831. * Tells to `setParticles()` to call the vertex function for each vertex of each particle, or not.
  81832. * Default value : false. The SPS is faster when it's set to false.
  81833. * Note : the particle custom vertex positions aren't stored values.
  81834. */
  81835. /**
  81836. * Gets if `setParticles()` calls the vertex function for each vertex of each particle, or not.
  81837. * Default value : false. The SPS is faster when it's set to false.
  81838. * Note : the particle custom vertex positions aren't stored values.
  81839. */
  81840. computeParticleVertex: boolean;
  81841. /**
  81842. * Tells to `setParticles()` to compute or not the mesh bounding box when computing the particle positions.
  81843. */
  81844. /**
  81845. * Gets if `setParticles()` computes or not the mesh bounding box when computing the particle positions.
  81846. */
  81847. computeBoundingBox: boolean;
  81848. /**
  81849. * Tells to `setParticles()` to sort or not the distance between each particle and the camera.
  81850. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  81851. * Default : `true`
  81852. */
  81853. /**
  81854. * Gets if `setParticles()` sorts or not the distance between each particle and the camera.
  81855. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  81856. * Default : `true`
  81857. */
  81858. depthSortParticles: boolean;
  81859. /**
  81860. * This function does nothing. It may be overwritten to set all the particle first values.
  81861. * The SPS doesn't call this function, you may have to call it by your own.
  81862. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#particle-management
  81863. */
  81864. initParticles(): void;
  81865. /**
  81866. * This function does nothing. It may be overwritten to recycle a particle.
  81867. * The SPS doesn't call this function, you may have to call it by your own.
  81868. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#particle-management
  81869. * @param particle The particle to recycle
  81870. * @returns the recycled particle
  81871. */
  81872. recycleParticle(particle: SolidParticle): SolidParticle;
  81873. /**
  81874. * Updates a particle : this function should be overwritten by the user.
  81875. * It is called on each particle by `setParticles()`. This is the place to code each particle behavior.
  81876. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#particle-management
  81877. * @example : just set a particle position or velocity and recycle conditions
  81878. * @param particle The particle to update
  81879. * @returns the updated particle
  81880. */
  81881. updateParticle(particle: SolidParticle): SolidParticle;
  81882. /**
  81883. * Updates a vertex of a particle : it can be overwritten by the user.
  81884. * This will be called on each vertex particle by `setParticles()` if `computeParticleVertex` is set to true only.
  81885. * @param particle the current particle
  81886. * @param vertex the current index of the current particle
  81887. * @param pt the index of the current vertex in the particle shape
  81888. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#update-each-particle-shape
  81889. * @example : just set a vertex particle position
  81890. * @returns the updated vertex
  81891. */
  81892. updateParticleVertex(particle: SolidParticle, vertex: Vector3, pt: number): Vector3;
  81893. /**
  81894. * This will be called before any other treatment by `setParticles()` and will be passed three parameters.
  81895. * This does nothing and may be overwritten by the user.
  81896. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  81897. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  81898. * @param update the boolean update value actually passed to setParticles()
  81899. */
  81900. beforeUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  81901. /**
  81902. * This will be called by `setParticles()` after all the other treatments and just before the actual mesh update.
  81903. * This will be passed three parameters.
  81904. * This does nothing and may be overwritten by the user.
  81905. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  81906. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  81907. * @param update the boolean update value actually passed to setParticles()
  81908. */
  81909. afterUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  81910. }
  81911. }
  81912. declare module BABYLON {
  81913. /**
  81914. * Represents one particle of a solid particle system.
  81915. */
  81916. export class SolidParticle {
  81917. /**
  81918. * particle global index
  81919. */
  81920. idx: number;
  81921. /**
  81922. * The color of the particle
  81923. */
  81924. color: Nullable<Color4>;
  81925. /**
  81926. * The world space position of the particle.
  81927. */
  81928. position: Vector3;
  81929. /**
  81930. * The world space rotation of the particle. (Not use if rotationQuaternion is set)
  81931. */
  81932. rotation: Vector3;
  81933. /**
  81934. * The world space rotation quaternion of the particle.
  81935. */
  81936. rotationQuaternion: Nullable<Quaternion>;
  81937. /**
  81938. * The scaling of the particle.
  81939. */
  81940. scaling: Vector3;
  81941. /**
  81942. * The uvs of the particle.
  81943. */
  81944. uvs: Vector4;
  81945. /**
  81946. * The current speed of the particle.
  81947. */
  81948. velocity: Vector3;
  81949. /**
  81950. * The pivot point in the particle local space.
  81951. */
  81952. pivot: Vector3;
  81953. /**
  81954. * Must the particle be translated from its pivot point in its local space ?
  81955. * In this case, the pivot point is set at the origin of the particle local space and the particle is translated.
  81956. * Default : false
  81957. */
  81958. translateFromPivot: boolean;
  81959. /**
  81960. * Is the particle active or not ?
  81961. */
  81962. alive: boolean;
  81963. /**
  81964. * Is the particle visible or not ?
  81965. */
  81966. isVisible: boolean;
  81967. /**
  81968. * Index of this particle in the global "positions" array (Internal use)
  81969. * @hidden
  81970. */
  81971. _pos: number;
  81972. /**
  81973. * @hidden Index of this particle in the global "indices" array (Internal use)
  81974. */
  81975. _ind: number;
  81976. /**
  81977. * @hidden ModelShape of this particle (Internal use)
  81978. */
  81979. _model: ModelShape;
  81980. /**
  81981. * ModelShape id of this particle
  81982. */
  81983. shapeId: number;
  81984. /**
  81985. * Index of the particle in its shape id (Internal use)
  81986. */
  81987. idxInShape: number;
  81988. /**
  81989. * @hidden Reference to the shape model BoundingInfo object (Internal use)
  81990. */
  81991. _modelBoundingInfo: BoundingInfo;
  81992. /**
  81993. * @hidden Particle BoundingInfo object (Internal use)
  81994. */
  81995. _boundingInfo: BoundingInfo;
  81996. /**
  81997. * @hidden Reference to the SPS what the particle belongs to (Internal use)
  81998. */
  81999. _sps: SolidParticleSystem;
  82000. /**
  82001. * @hidden Still set as invisible in order to skip useless computations (Internal use)
  82002. */
  82003. _stillInvisible: boolean;
  82004. /**
  82005. * @hidden Last computed particle rotation matrix
  82006. */
  82007. _rotationMatrix: number[];
  82008. /**
  82009. * Parent particle Id, if any.
  82010. * Default null.
  82011. */
  82012. parentId: Nullable<number>;
  82013. /**
  82014. * The culling strategy to use to check whether the solid particle must be culled or not when using isInFrustum().
  82015. * The possible values are :
  82016. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  82017. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  82018. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  82019. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  82020. * The default value for solid particles is AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  82021. * Please read each static variable documentation in the class AbstractMesh to get details about the culling process.
  82022. * */
  82023. cullingStrategy: number;
  82024. /**
  82025. * @hidden Internal global position in the SPS.
  82026. */
  82027. _globalPosition: Vector3;
  82028. /**
  82029. * Creates a Solid Particle object.
  82030. * Don't create particles manually, use instead the Solid Particle System internal tools like _addParticle()
  82031. * @param particleIndex (integer) is the particle index in the Solid Particle System pool. It's also the particle identifier.
  82032. * @param positionIndex (integer) is the starting index of the particle vertices in the SPS "positions" array.
  82033. * @param indiceIndex (integer) is the starting index of the particle indices in the SPS "indices" array.
  82034. * @param model (ModelShape) is a reference to the model shape on what the particle is designed.
  82035. * @param shapeId (integer) is the model shape identifier in the SPS.
  82036. * @param idxInShape (integer) is the index of the particle in the current model (ex: the 10th box of addShape(box, 30))
  82037. * @param sps defines the sps it is associated to
  82038. * @param modelBoundingInfo is the reference to the model BoundingInfo used for intersection computations.
  82039. */
  82040. constructor(particleIndex: number, positionIndex: number, indiceIndex: number, model: Nullable<ModelShape>, shapeId: number, idxInShape: number, sps: SolidParticleSystem, modelBoundingInfo?: Nullable<BoundingInfo>);
  82041. /**
  82042. * Legacy support, changed scale to scaling
  82043. */
  82044. /**
  82045. * Legacy support, changed scale to scaling
  82046. */
  82047. scale: Vector3;
  82048. /**
  82049. * Legacy support, changed quaternion to rotationQuaternion
  82050. */
  82051. /**
  82052. * Legacy support, changed quaternion to rotationQuaternion
  82053. */
  82054. quaternion: Nullable<Quaternion>;
  82055. /**
  82056. * Returns a boolean. True if the particle intersects another particle or another mesh, else false.
  82057. * The intersection is computed on the particle bounding sphere and Axis Aligned Bounding Box (AABB)
  82058. * @param target is the object (solid particle or mesh) what the intersection is computed against.
  82059. * @returns true if it intersects
  82060. */
  82061. intersectsMesh(target: Mesh | SolidParticle): boolean;
  82062. /**
  82063. * Returns `true` if the solid particle is within the frustum defined by the passed array of planes.
  82064. * A particle is in the frustum if its bounding box intersects the frustum
  82065. * @param frustumPlanes defines the frustum to test
  82066. * @returns true if the particle is in the frustum planes
  82067. */
  82068. isInFrustum(frustumPlanes: Plane[]): boolean;
  82069. /**
  82070. * get the rotation matrix of the particle
  82071. * @hidden
  82072. */
  82073. getRotationMatrix(m: Matrix): void;
  82074. }
  82075. /**
  82076. * Represents the shape of the model used by one particle of a solid particle system.
  82077. * SPS internal tool, don't use it manually.
  82078. */
  82079. export class ModelShape {
  82080. /**
  82081. * The shape id
  82082. * @hidden
  82083. */
  82084. shapeID: number;
  82085. /**
  82086. * flat array of model positions (internal use)
  82087. * @hidden
  82088. */
  82089. _shape: Vector3[];
  82090. /**
  82091. * flat array of model UVs (internal use)
  82092. * @hidden
  82093. */
  82094. _shapeUV: number[];
  82095. /**
  82096. * length of the shape in the model indices array (internal use)
  82097. * @hidden
  82098. */
  82099. _indicesLength: number;
  82100. /**
  82101. * Custom position function (internal use)
  82102. * @hidden
  82103. */
  82104. _positionFunction: Nullable<(particle: SolidParticle, i: number, s: number) => void>;
  82105. /**
  82106. * Custom vertex function (internal use)
  82107. * @hidden
  82108. */
  82109. _vertexFunction: Nullable<(particle: SolidParticle, vertex: Vector3, i: number) => void>;
  82110. /**
  82111. * 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.
  82112. * SPS internal tool, don't use it manually.
  82113. * @hidden
  82114. */
  82115. 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>);
  82116. }
  82117. /**
  82118. * Represents a Depth Sorted Particle in the solid particle system.
  82119. */
  82120. export class DepthSortedParticle {
  82121. /**
  82122. * Index of the particle in the "indices" array
  82123. */
  82124. ind: number;
  82125. /**
  82126. * Length of the particle shape in the "indices" array
  82127. */
  82128. indicesLength: number;
  82129. /**
  82130. * Squared distance from the particle to the camera
  82131. */
  82132. sqDistance: number;
  82133. }
  82134. }
  82135. declare module BABYLON {
  82136. /**
  82137. * Class used to store all common mesh properties
  82138. */
  82139. export class AbstractMesh extends TransformNode implements IDisposable, ICullable, IGetSetVerticesData {
  82140. /** No occlusion */
  82141. static OCCLUSION_TYPE_NONE: number;
  82142. /** Occlusion set to optimisitic */
  82143. static OCCLUSION_TYPE_OPTIMISTIC: number;
  82144. /** Occlusion set to strict */
  82145. static OCCLUSION_TYPE_STRICT: number;
  82146. /** Use an accurante occlusion algorithm */
  82147. static OCCLUSION_ALGORITHM_TYPE_ACCURATE: number;
  82148. /** Use a conservative occlusion algorithm */
  82149. static OCCLUSION_ALGORITHM_TYPE_CONSERVATIVE: number;
  82150. /** Default culling strategy : this is an exclusion test and it's the more accurate.
  82151. * Test order :
  82152. * Is the bounding sphere outside the frustum ?
  82153. * If not, are the bounding box vertices outside the frustum ?
  82154. * It not, then the cullable object is in the frustum.
  82155. */
  82156. static readonly CULLINGSTRATEGY_STANDARD: number;
  82157. /** Culling strategy : Bounding Sphere Only.
  82158. * This is an exclusion test. It's faster than the standard strategy because the bounding box is not tested.
  82159. * It's also less accurate than the standard because some not visible objects can still be selected.
  82160. * Test : is the bounding sphere outside the frustum ?
  82161. * If not, then the cullable object is in the frustum.
  82162. */
  82163. static readonly CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY: number;
  82164. /** Culling strategy : Optimistic Inclusion.
  82165. * This in an inclusion test first, then the standard exclusion test.
  82166. * This can be faster when a cullable object is expected to be almost always in the camera frustum.
  82167. * 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.
  82168. * Anyway, it's as accurate as the standard strategy.
  82169. * Test :
  82170. * Is the cullable object bounding sphere center in the frustum ?
  82171. * If not, apply the default culling strategy.
  82172. */
  82173. static readonly CULLINGSTRATEGY_OPTIMISTIC_INCLUSION: number;
  82174. /** Culling strategy : Optimistic Inclusion then Bounding Sphere Only.
  82175. * This in an inclusion test first, then the bounding sphere only exclusion test.
  82176. * This can be the fastest test when a cullable object is expected to be almost always in the camera frustum.
  82177. * 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.
  82178. * It's less accurate than the standard strategy and as accurate as the BoundingSphereOnly strategy.
  82179. * Test :
  82180. * Is the cullable object bounding sphere center in the frustum ?
  82181. * If not, apply the Bounding Sphere Only strategy. No Bounding Box is tested here.
  82182. */
  82183. static readonly CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY: number;
  82184. /**
  82185. * No billboard
  82186. */
  82187. static readonly BILLBOARDMODE_NONE: number;
  82188. /** Billboard on X axis */
  82189. static readonly BILLBOARDMODE_X: number;
  82190. /** Billboard on Y axis */
  82191. static readonly BILLBOARDMODE_Y: number;
  82192. /** Billboard on Z axis */
  82193. static readonly BILLBOARDMODE_Z: number;
  82194. /** Billboard on all axes */
  82195. static readonly BILLBOARDMODE_ALL: number;
  82196. private _facetData;
  82197. /**
  82198. * The culling strategy to use to check whether the mesh must be rendered or not.
  82199. * This value can be changed at any time and will be used on the next render mesh selection.
  82200. * The possible values are :
  82201. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  82202. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  82203. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  82204. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  82205. * Please read each static variable documentation to get details about the culling process.
  82206. * */
  82207. cullingStrategy: number;
  82208. /**
  82209. * Gets the number of facets in the mesh
  82210. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  82211. */
  82212. readonly facetNb: number;
  82213. /**
  82214. * Gets or set the number (integer) of subdivisions per axis in the partioning space
  82215. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  82216. */
  82217. partitioningSubdivisions: number;
  82218. /**
  82219. * The ratio (float) to apply to the bouding box size to set to the partioning space.
  82220. * Ex : 1.01 (default) the partioning space is 1% bigger than the bounding box
  82221. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  82222. */
  82223. partitioningBBoxRatio: number;
  82224. /**
  82225. * Gets or sets a boolean indicating that the facets must be depth sorted on next call to `updateFacetData()`.
  82226. * Works only for updatable meshes.
  82227. * Doesn't work with multi-materials
  82228. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  82229. */
  82230. mustDepthSortFacets: boolean;
  82231. /**
  82232. * The location (Vector3) where the facet depth sort must be computed from.
  82233. * By default, the active camera position.
  82234. * Used only when facet depth sort is enabled
  82235. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  82236. */
  82237. facetDepthSortFrom: Vector3;
  82238. /**
  82239. * gets a boolean indicating if facetData is enabled
  82240. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  82241. */
  82242. readonly isFacetDataEnabled: boolean;
  82243. /** @hidden */
  82244. _updateNonUniformScalingState(value: boolean): boolean;
  82245. /**
  82246. * An event triggered when this mesh collides with another one
  82247. */
  82248. onCollideObservable: Observable<AbstractMesh>;
  82249. private _onCollideObserver;
  82250. /** Set a function to call when this mesh collides with another one */
  82251. onCollide: () => void;
  82252. /**
  82253. * An event triggered when the collision's position changes
  82254. */
  82255. onCollisionPositionChangeObservable: Observable<Vector3>;
  82256. private _onCollisionPositionChangeObserver;
  82257. /** Set a function to call when the collision's position changes */
  82258. onCollisionPositionChange: () => void;
  82259. /**
  82260. * An event triggered when material is changed
  82261. */
  82262. onMaterialChangedObservable: Observable<AbstractMesh>;
  82263. /**
  82264. * Gets or sets the orientation for POV movement & rotation
  82265. */
  82266. definedFacingForward: boolean;
  82267. /** @hidden */
  82268. _occlusionQuery: Nullable<WebGLQuery>;
  82269. private _visibility;
  82270. /**
  82271. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  82272. */
  82273. /**
  82274. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  82275. */
  82276. visibility: number;
  82277. /** Gets or sets the alpha index used to sort transparent meshes
  82278. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#alpha-index
  82279. */
  82280. alphaIndex: number;
  82281. /**
  82282. * Gets or sets a boolean indicating if the mesh is visible (renderable). Default is true
  82283. */
  82284. isVisible: boolean;
  82285. /**
  82286. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  82287. */
  82288. isPickable: boolean;
  82289. /** Gets or sets a boolean indicating that bounding boxes of subMeshes must be rendered as well (false by default) */
  82290. showSubMeshesBoundingBox: boolean;
  82291. /** Gets or sets a boolean indicating if the mesh must be considered as a ray blocker for lens flares (false by default)
  82292. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  82293. */
  82294. isBlocker: boolean;
  82295. /**
  82296. * Gets or sets a boolean indicating that pointer move events must be supported on this mesh (false by default)
  82297. */
  82298. enablePointerMoveEvents: boolean;
  82299. /**
  82300. * Specifies the rendering group id for this mesh (0 by default)
  82301. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  82302. */
  82303. renderingGroupId: number;
  82304. private _material;
  82305. /** Gets or sets current material */
  82306. material: Nullable<Material>;
  82307. private _receiveShadows;
  82308. /**
  82309. * Gets or sets a boolean indicating that this mesh can receive realtime shadows
  82310. * @see http://doc.babylonjs.com/babylon101/shadows
  82311. */
  82312. receiveShadows: boolean;
  82313. /** Defines color to use when rendering outline */
  82314. outlineColor: Color3;
  82315. /** Define width to use when rendering outline */
  82316. outlineWidth: number;
  82317. /** Defines color to use when rendering overlay */
  82318. overlayColor: Color3;
  82319. /** Defines alpha to use when rendering overlay */
  82320. overlayAlpha: number;
  82321. private _hasVertexAlpha;
  82322. /** Gets or sets a boolean indicating that this mesh contains vertex color data with alpha values */
  82323. hasVertexAlpha: boolean;
  82324. private _useVertexColors;
  82325. /** 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) */
  82326. useVertexColors: boolean;
  82327. private _computeBonesUsingShaders;
  82328. /**
  82329. * Gets or sets a boolean indicating that bone animations must be computed by the CPU (false by default)
  82330. */
  82331. computeBonesUsingShaders: boolean;
  82332. private _numBoneInfluencers;
  82333. /** Gets or sets the number of allowed bone influences per vertex (4 by default) */
  82334. numBoneInfluencers: number;
  82335. private _applyFog;
  82336. /** Gets or sets a boolean indicating that this mesh will allow fog to be rendered on it (true by default) */
  82337. applyFog: boolean;
  82338. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes selection (true by default) */
  82339. useOctreeForRenderingSelection: boolean;
  82340. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes picking (true by default) */
  82341. useOctreeForPicking: boolean;
  82342. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes collision (true by default) */
  82343. useOctreeForCollisions: boolean;
  82344. private _layerMask;
  82345. /**
  82346. * Gets or sets the current layer mask (default is 0x0FFFFFFF)
  82347. * @see http://doc.babylonjs.com/how_to/layermasks_and_multi-cam_textures
  82348. */
  82349. layerMask: number;
  82350. /**
  82351. * True if the mesh must be rendered in any case (this will shortcut the frustum clipping phase)
  82352. */
  82353. alwaysSelectAsActiveMesh: boolean;
  82354. /**
  82355. * Gets or sets the current action manager
  82356. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  82357. */
  82358. actionManager: Nullable<AbstractActionManager>;
  82359. private _checkCollisions;
  82360. private _collisionMask;
  82361. private _collisionGroup;
  82362. /**
  82363. * Gets or sets the ellipsoid used to impersonate this mesh when using collision engine (default is (0.5, 1, 0.5))
  82364. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  82365. */
  82366. ellipsoid: Vector3;
  82367. /**
  82368. * Gets or sets the ellipsoid offset used to impersonate this mesh when using collision engine (default is (0, 0, 0))
  82369. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  82370. */
  82371. ellipsoidOffset: Vector3;
  82372. private _collider;
  82373. private _oldPositionForCollisions;
  82374. private _diffPositionForCollisions;
  82375. /**
  82376. * Gets or sets a collision mask used to mask collisions (default is -1).
  82377. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  82378. */
  82379. collisionMask: number;
  82380. /**
  82381. * Gets or sets the current collision group mask (-1 by default).
  82382. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  82383. */
  82384. collisionGroup: number;
  82385. /**
  82386. * Defines edge width used when edgesRenderer is enabled
  82387. * @see https://www.babylonjs-playground.com/#10OJSG#13
  82388. */
  82389. edgesWidth: number;
  82390. /**
  82391. * Defines edge color used when edgesRenderer is enabled
  82392. * @see https://www.babylonjs-playground.com/#10OJSG#13
  82393. */
  82394. edgesColor: Color4;
  82395. /** @hidden */
  82396. _edgesRenderer: Nullable<IEdgesRenderer>;
  82397. /** @hidden */
  82398. _masterMesh: Nullable<AbstractMesh>;
  82399. /** @hidden */
  82400. _boundingInfo: Nullable<BoundingInfo>;
  82401. /** @hidden */
  82402. _renderId: number;
  82403. /**
  82404. * Gets or sets the list of subMeshes
  82405. * @see http://doc.babylonjs.com/how_to/multi_materials
  82406. */
  82407. subMeshes: SubMesh[];
  82408. /** @hidden */
  82409. _intersectionsInProgress: AbstractMesh[];
  82410. /** @hidden */
  82411. _unIndexed: boolean;
  82412. /** @hidden */
  82413. _lightSources: Light[];
  82414. /** @hidden */
  82415. readonly _positions: Nullable<Vector3[]>;
  82416. /** @hidden */
  82417. _waitingActions: any;
  82418. /** @hidden */
  82419. _waitingFreezeWorldMatrix: Nullable<boolean>;
  82420. private _skeleton;
  82421. /** @hidden */
  82422. _bonesTransformMatrices: Nullable<Float32Array>;
  82423. /**
  82424. * Gets or sets a skeleton to apply skining transformations
  82425. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  82426. */
  82427. skeleton: Nullable<Skeleton>;
  82428. /**
  82429. * An event triggered when the mesh is rebuilt.
  82430. */
  82431. onRebuildObservable: Observable<AbstractMesh>;
  82432. /**
  82433. * Creates a new AbstractMesh
  82434. * @param name defines the name of the mesh
  82435. * @param scene defines the hosting scene
  82436. */
  82437. constructor(name: string, scene?: Nullable<Scene>);
  82438. /**
  82439. * Returns the string "AbstractMesh"
  82440. * @returns "AbstractMesh"
  82441. */
  82442. getClassName(): string;
  82443. /**
  82444. * Gets a string representation of the current mesh
  82445. * @param fullDetails defines a boolean indicating if full details must be included
  82446. * @returns a string representation of the current mesh
  82447. */
  82448. toString(fullDetails?: boolean): string;
  82449. /** @hidden */
  82450. _getActionManagerForTrigger(trigger?: number, initialCall?: boolean): Nullable<AbstractActionManager>;
  82451. /** @hidden */
  82452. _rebuild(): void;
  82453. /** @hidden */
  82454. _resyncLightSources(): void;
  82455. /** @hidden */
  82456. _resyncLighSource(light: Light): void;
  82457. /** @hidden */
  82458. _unBindEffect(): void;
  82459. /** @hidden */
  82460. _removeLightSource(light: Light): void;
  82461. private _markSubMeshesAsDirty;
  82462. /** @hidden */
  82463. _markSubMeshesAsLightDirty(): void;
  82464. /** @hidden */
  82465. _markSubMeshesAsAttributesDirty(): void;
  82466. /** @hidden */
  82467. _markSubMeshesAsMiscDirty(): void;
  82468. /**
  82469. * Gets or sets a Vector3 depicting the mesh scaling along each local axis X, Y, Z. Default is (1.0, 1.0, 1.0)
  82470. */
  82471. scaling: Vector3;
  82472. /**
  82473. * Returns true if the mesh is blocked. Implemented by child classes
  82474. */
  82475. readonly isBlocked: boolean;
  82476. /**
  82477. * Returns the mesh itself by default. Implemented by child classes
  82478. * @param camera defines the camera to use to pick the right LOD level
  82479. * @returns the currentAbstractMesh
  82480. */
  82481. getLOD(camera: Camera): Nullable<AbstractMesh>;
  82482. /**
  82483. * Returns 0 by default. Implemented by child classes
  82484. * @returns an integer
  82485. */
  82486. getTotalVertices(): number;
  82487. /**
  82488. * Returns a positive integer : the total number of indices in this mesh geometry.
  82489. * @returns the numner of indices or zero if the mesh has no geometry.
  82490. */
  82491. getTotalIndices(): number;
  82492. /**
  82493. * Returns null by default. Implemented by child classes
  82494. * @returns null
  82495. */
  82496. getIndices(): Nullable<IndicesArray>;
  82497. /**
  82498. * Returns the array of the requested vertex data kind. Implemented by child classes
  82499. * @param kind defines the vertex data kind to use
  82500. * @returns null
  82501. */
  82502. getVerticesData(kind: string): Nullable<FloatArray>;
  82503. /**
  82504. * Sets the vertex data of the mesh geometry for the requested `kind`.
  82505. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  82506. * Note that a new underlying VertexBuffer object is created each call.
  82507. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  82508. * @param kind defines vertex data kind:
  82509. * * VertexBuffer.PositionKind
  82510. * * VertexBuffer.UVKind
  82511. * * VertexBuffer.UV2Kind
  82512. * * VertexBuffer.UV3Kind
  82513. * * VertexBuffer.UV4Kind
  82514. * * VertexBuffer.UV5Kind
  82515. * * VertexBuffer.UV6Kind
  82516. * * VertexBuffer.ColorKind
  82517. * * VertexBuffer.MatricesIndicesKind
  82518. * * VertexBuffer.MatricesIndicesExtraKind
  82519. * * VertexBuffer.MatricesWeightsKind
  82520. * * VertexBuffer.MatricesWeightsExtraKind
  82521. * @param data defines the data source
  82522. * @param updatable defines if the data must be flagged as updatable (or static)
  82523. * @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
  82524. * @returns the current mesh
  82525. */
  82526. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  82527. /**
  82528. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  82529. * If the mesh has no geometry, it is simply returned as it is.
  82530. * @param kind defines vertex data kind:
  82531. * * VertexBuffer.PositionKind
  82532. * * VertexBuffer.UVKind
  82533. * * VertexBuffer.UV2Kind
  82534. * * VertexBuffer.UV3Kind
  82535. * * VertexBuffer.UV4Kind
  82536. * * VertexBuffer.UV5Kind
  82537. * * VertexBuffer.UV6Kind
  82538. * * VertexBuffer.ColorKind
  82539. * * VertexBuffer.MatricesIndicesKind
  82540. * * VertexBuffer.MatricesIndicesExtraKind
  82541. * * VertexBuffer.MatricesWeightsKind
  82542. * * VertexBuffer.MatricesWeightsExtraKind
  82543. * @param data defines the data source
  82544. * @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
  82545. * @param makeItUnique If true, a new global geometry is created from this data and is set to the mesh
  82546. * @returns the current mesh
  82547. */
  82548. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): AbstractMesh;
  82549. /**
  82550. * Sets the mesh indices,
  82551. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  82552. * @param indices Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array)
  82553. * @param totalVertices Defines the total number of vertices
  82554. * @returns the current mesh
  82555. */
  82556. setIndices(indices: IndicesArray, totalVertices: Nullable<number>): AbstractMesh;
  82557. /**
  82558. * Gets a boolean indicating if specific vertex data is present
  82559. * @param kind defines the vertex data kind to use
  82560. * @returns true is data kind is present
  82561. */
  82562. isVerticesDataPresent(kind: string): boolean;
  82563. /**
  82564. * Returns the mesh BoundingInfo object or creates a new one and returns if it was undefined
  82565. * @returns a BoundingInfo
  82566. */
  82567. getBoundingInfo(): BoundingInfo;
  82568. /**
  82569. * Uniformly scales the mesh to fit inside of a unit cube (1 X 1 X 1 units)
  82570. * @param includeDescendants Use the hierarchy's bounding box instead of the mesh's bounding box. Default is false
  82571. * @param ignoreRotation ignore rotation when computing the scale (ie. object will be axis aligned). Default is false
  82572. * @returns the current mesh
  82573. */
  82574. normalizeToUnitCube(includeDescendants?: boolean, ignoreRotation?: boolean): AbstractMesh;
  82575. /**
  82576. * Overwrite the current bounding info
  82577. * @param boundingInfo defines the new bounding info
  82578. * @returns the current mesh
  82579. */
  82580. setBoundingInfo(boundingInfo: BoundingInfo): AbstractMesh;
  82581. /** Gets a boolean indicating if this mesh has skinning data and an attached skeleton */
  82582. readonly useBones: boolean;
  82583. /** @hidden */
  82584. _preActivate(): void;
  82585. /** @hidden */
  82586. _preActivateForIntermediateRendering(renderId: number): void;
  82587. /** @hidden */
  82588. _activate(renderId: number): void;
  82589. /**
  82590. * Gets the current world matrix
  82591. * @returns a Matrix
  82592. */
  82593. getWorldMatrix(): Matrix;
  82594. /** @hidden */
  82595. _getWorldMatrixDeterminant(): number;
  82596. /**
  82597. * Perform relative position change from the point of view of behind the front of the mesh.
  82598. * This is performed taking into account the meshes current rotation, so you do not have to care.
  82599. * Supports definition of mesh facing forward or backward
  82600. * @param amountRight defines the distance on the right axis
  82601. * @param amountUp defines the distance on the up axis
  82602. * @param amountForward defines the distance on the forward axis
  82603. * @returns the current mesh
  82604. */
  82605. movePOV(amountRight: number, amountUp: number, amountForward: number): AbstractMesh;
  82606. /**
  82607. * Calculate relative position change from the point of view of behind the front of the mesh.
  82608. * This is performed taking into account the meshes current rotation, so you do not have to care.
  82609. * Supports definition of mesh facing forward or backward
  82610. * @param amountRight defines the distance on the right axis
  82611. * @param amountUp defines the distance on the up axis
  82612. * @param amountForward defines the distance on the forward axis
  82613. * @returns the new displacement vector
  82614. */
  82615. calcMovePOV(amountRight: number, amountUp: number, amountForward: number): Vector3;
  82616. /**
  82617. * Perform relative rotation change from the point of view of behind the front of the mesh.
  82618. * Supports definition of mesh facing forward or backward
  82619. * @param flipBack defines the flip
  82620. * @param twirlClockwise defines the twirl
  82621. * @param tiltRight defines the tilt
  82622. * @returns the current mesh
  82623. */
  82624. rotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): AbstractMesh;
  82625. /**
  82626. * Calculate relative rotation change from the point of view of behind the front of the mesh.
  82627. * Supports definition of mesh facing forward or backward.
  82628. * @param flipBack defines the flip
  82629. * @param twirlClockwise defines the twirl
  82630. * @param tiltRight defines the tilt
  82631. * @returns the new rotation vector
  82632. */
  82633. calcRotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): Vector3;
  82634. /**
  82635. * Return the minimum and maximum world vectors of the entire hierarchy under current mesh
  82636. * @param includeDescendants Include bounding info from descendants as well (true by default)
  82637. * @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
  82638. * @returns the new bounding vectors
  82639. */
  82640. getHierarchyBoundingVectors(includeDescendants?: boolean, predicate?: Nullable<(abstractMesh: AbstractMesh) => boolean>): {
  82641. min: Vector3;
  82642. max: Vector3;
  82643. };
  82644. /**
  82645. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  82646. * This means the mesh underlying bounding box and sphere are recomputed.
  82647. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  82648. * @returns the current mesh
  82649. */
  82650. refreshBoundingInfo(applySkeleton?: boolean): AbstractMesh;
  82651. /** @hidden */
  82652. _refreshBoundingInfo(data: Nullable<FloatArray>, bias: Nullable<Vector2>): void;
  82653. /** @hidden */
  82654. _getPositionData(applySkeleton: boolean): Nullable<FloatArray>;
  82655. /** @hidden */
  82656. _updateBoundingInfo(): AbstractMesh;
  82657. /** @hidden */
  82658. _updateSubMeshesBoundingInfo(matrix: DeepImmutable<Matrix>): AbstractMesh;
  82659. /** @hidden */
  82660. protected _afterComputeWorldMatrix(): void;
  82661. /**
  82662. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  82663. * A mesh is in the frustum if its bounding box intersects the frustum
  82664. * @param frustumPlanes defines the frustum to test
  82665. * @returns true if the mesh is in the frustum planes
  82666. */
  82667. isInFrustum(frustumPlanes: Plane[]): boolean;
  82668. /**
  82669. * Returns `true` if the mesh is completely in the frustum defined be the passed array of planes.
  82670. * A mesh is completely in the frustum if its bounding box it completely inside the frustum.
  82671. * @param frustumPlanes defines the frustum to test
  82672. * @returns true if the mesh is completely in the frustum planes
  82673. */
  82674. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  82675. /**
  82676. * True if the mesh intersects another mesh or a SolidParticle object
  82677. * @param mesh defines a target mesh or SolidParticle to test
  82678. * @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)
  82679. * @param includeDescendants Can be set to true to test if the mesh defined in parameters intersects with the current mesh or any child meshes
  82680. * @returns true if there is an intersection
  82681. */
  82682. intersectsMesh(mesh: AbstractMesh | SolidParticle, precise?: boolean, includeDescendants?: boolean): boolean;
  82683. /**
  82684. * Returns true if the passed point (Vector3) is inside the mesh bounding box
  82685. * @param point defines the point to test
  82686. * @returns true if there is an intersection
  82687. */
  82688. intersectsPoint(point: Vector3): boolean;
  82689. /**
  82690. * Gets or sets a boolean indicating that this mesh can be used in the collision engine
  82691. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  82692. */
  82693. checkCollisions: boolean;
  82694. /**
  82695. * Gets Collider object used to compute collisions (not physics)
  82696. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  82697. */
  82698. readonly collider: Collider;
  82699. /**
  82700. * Move the mesh using collision engine
  82701. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  82702. * @param displacement defines the requested displacement vector
  82703. * @returns the current mesh
  82704. */
  82705. moveWithCollisions(displacement: Vector3): AbstractMesh;
  82706. private _onCollisionPositionChange;
  82707. /** @hidden */
  82708. _collideForSubMesh(subMesh: SubMesh, transformMatrix: Matrix, collider: Collider): AbstractMesh;
  82709. /** @hidden */
  82710. _processCollisionsForSubMeshes(collider: Collider, transformMatrix: Matrix): AbstractMesh;
  82711. /** @hidden */
  82712. _checkCollision(collider: Collider): AbstractMesh;
  82713. /** @hidden */
  82714. _generatePointsArray(): boolean;
  82715. /**
  82716. * Checks if the passed Ray intersects with the mesh
  82717. * @param ray defines the ray to use
  82718. * @param fastCheck defines if fast mode (but less precise) must be used (false by default)
  82719. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  82720. * @returns the picking info
  82721. * @see http://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  82722. */
  82723. intersects(ray: Ray, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): PickingInfo;
  82724. /**
  82725. * Clones the current mesh
  82726. * @param name defines the mesh name
  82727. * @param newParent defines the new mesh parent
  82728. * @param doNotCloneChildren defines a boolean indicating that children must not be cloned (false by default)
  82729. * @returns the new mesh
  82730. */
  82731. clone(name: string, newParent: Node, doNotCloneChildren?: boolean): Nullable<AbstractMesh>;
  82732. /**
  82733. * Disposes all the submeshes of the current meshnp
  82734. * @returns the current mesh
  82735. */
  82736. releaseSubMeshes(): AbstractMesh;
  82737. /**
  82738. * Releases resources associated with this abstract mesh.
  82739. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  82740. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  82741. */
  82742. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  82743. /**
  82744. * Adds the passed mesh as a child to the current mesh
  82745. * @param mesh defines the child mesh
  82746. * @returns the current mesh
  82747. */
  82748. addChild(mesh: AbstractMesh): AbstractMesh;
  82749. /**
  82750. * Removes the passed mesh from the current mesh children list
  82751. * @param mesh defines the child mesh
  82752. * @returns the current mesh
  82753. */
  82754. removeChild(mesh: AbstractMesh): AbstractMesh;
  82755. /** @hidden */
  82756. private _initFacetData;
  82757. /**
  82758. * Updates the mesh facetData arrays and the internal partitioning when the mesh is morphed or updated.
  82759. * This method can be called within the render loop.
  82760. * 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
  82761. * @returns the current mesh
  82762. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  82763. */
  82764. updateFacetData(): AbstractMesh;
  82765. /**
  82766. * Returns the facetLocalNormals array.
  82767. * The normals are expressed in the mesh local spac
  82768. * @returns an array of Vector3
  82769. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  82770. */
  82771. getFacetLocalNormals(): Vector3[];
  82772. /**
  82773. * Returns the facetLocalPositions array.
  82774. * The facet positions are expressed in the mesh local space
  82775. * @returns an array of Vector3
  82776. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  82777. */
  82778. getFacetLocalPositions(): Vector3[];
  82779. /**
  82780. * Returns the facetLocalPartioning array
  82781. * @returns an array of array of numbers
  82782. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  82783. */
  82784. getFacetLocalPartitioning(): number[][];
  82785. /**
  82786. * Returns the i-th facet position in the world system.
  82787. * This method allocates a new Vector3 per call
  82788. * @param i defines the facet index
  82789. * @returns a new Vector3
  82790. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  82791. */
  82792. getFacetPosition(i: number): Vector3;
  82793. /**
  82794. * Sets the reference Vector3 with the i-th facet position in the world system
  82795. * @param i defines the facet index
  82796. * @param ref defines the target vector
  82797. * @returns the current mesh
  82798. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  82799. */
  82800. getFacetPositionToRef(i: number, ref: Vector3): AbstractMesh;
  82801. /**
  82802. * Returns the i-th facet normal in the world system.
  82803. * This method allocates a new Vector3 per call
  82804. * @param i defines the facet index
  82805. * @returns a new Vector3
  82806. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  82807. */
  82808. getFacetNormal(i: number): Vector3;
  82809. /**
  82810. * Sets the reference Vector3 with the i-th facet normal in the world system
  82811. * @param i defines the facet index
  82812. * @param ref defines the target vector
  82813. * @returns the current mesh
  82814. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  82815. */
  82816. getFacetNormalToRef(i: number, ref: Vector3): this;
  82817. /**
  82818. * 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)
  82819. * @param x defines x coordinate
  82820. * @param y defines y coordinate
  82821. * @param z defines z coordinate
  82822. * @returns the array of facet indexes
  82823. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  82824. */
  82825. getFacetsAtLocalCoordinates(x: number, y: number, z: number): Nullable<number[]>;
  82826. /**
  82827. * Returns the closest mesh facet index at (x,y,z) World coordinates, null if not found
  82828. * @param projected sets as the (x,y,z) world projection on the facet
  82829. * @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
  82830. * @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
  82831. * @param x defines x coordinate
  82832. * @param y defines y coordinate
  82833. * @param z defines z coordinate
  82834. * @returns the face index if found (or null instead)
  82835. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  82836. */
  82837. getClosestFacetAtCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  82838. /**
  82839. * Returns the closest mesh facet index at (x,y,z) local coordinates, null if not found
  82840. * @param projected sets as the (x,y,z) local projection on the facet
  82841. * @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
  82842. * @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
  82843. * @param x defines x coordinate
  82844. * @param y defines y coordinate
  82845. * @param z defines z coordinate
  82846. * @returns the face index if found (or null instead)
  82847. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  82848. */
  82849. getClosestFacetAtLocalCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  82850. /**
  82851. * Returns the object "parameter" set with all the expected parameters for facetData computation by ComputeNormals()
  82852. * @returns the parameters
  82853. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  82854. */
  82855. getFacetDataParameters(): any;
  82856. /**
  82857. * Disables the feature FacetData and frees the related memory
  82858. * @returns the current mesh
  82859. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  82860. */
  82861. disableFacetData(): AbstractMesh;
  82862. /**
  82863. * Updates the AbstractMesh indices array
  82864. * @param indices defines the data source
  82865. * @param offset defines the offset in the index buffer where to store the new data (can be null)
  82866. * @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)
  82867. * @returns the current mesh
  82868. */
  82869. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): AbstractMesh;
  82870. /**
  82871. * Creates new normals data for the mesh
  82872. * @param updatable defines if the normal vertex buffer must be flagged as updatable
  82873. * @returns the current mesh
  82874. */
  82875. createNormals(updatable: boolean): AbstractMesh;
  82876. /**
  82877. * Align the mesh with a normal
  82878. * @param normal defines the normal to use
  82879. * @param upDirection can be used to redefined the up vector to use (will use the (0, 1, 0) by default)
  82880. * @returns the current mesh
  82881. */
  82882. alignWithNormal(normal: Vector3, upDirection?: Vector3): AbstractMesh;
  82883. /** @hidden */
  82884. _checkOcclusionQuery(): boolean;
  82885. }
  82886. }
  82887. declare module BABYLON {
  82888. /**
  82889. * Interface used to define ActionEvent
  82890. */
  82891. export interface IActionEvent {
  82892. /** The mesh or sprite that triggered the action */
  82893. source: any;
  82894. /** The X mouse cursor position at the time of the event */
  82895. pointerX: number;
  82896. /** The Y mouse cursor position at the time of the event */
  82897. pointerY: number;
  82898. /** The mesh that is currently pointed at (can be null) */
  82899. meshUnderPointer: Nullable<AbstractMesh>;
  82900. /** the original (browser) event that triggered the ActionEvent */
  82901. sourceEvent?: any;
  82902. /** additional data for the event */
  82903. additionalData?: any;
  82904. }
  82905. /**
  82906. * ActionEvent is the event being sent when an action is triggered.
  82907. */
  82908. export class ActionEvent implements IActionEvent {
  82909. /** The mesh or sprite that triggered the action */
  82910. source: any;
  82911. /** The X mouse cursor position at the time of the event */
  82912. pointerX: number;
  82913. /** The Y mouse cursor position at the time of the event */
  82914. pointerY: number;
  82915. /** The mesh that is currently pointed at (can be null) */
  82916. meshUnderPointer: Nullable<AbstractMesh>;
  82917. /** the original (browser) event that triggered the ActionEvent */
  82918. sourceEvent?: any;
  82919. /** additional data for the event */
  82920. additionalData?: any;
  82921. /**
  82922. * Creates a new ActionEvent
  82923. * @param source The mesh or sprite that triggered the action
  82924. * @param pointerX The X mouse cursor position at the time of the event
  82925. * @param pointerY The Y mouse cursor position at the time of the event
  82926. * @param meshUnderPointer The mesh that is currently pointed at (can be null)
  82927. * @param sourceEvent the original (browser) event that triggered the ActionEvent
  82928. * @param additionalData additional data for the event
  82929. */
  82930. constructor(
  82931. /** The mesh or sprite that triggered the action */
  82932. source: any,
  82933. /** The X mouse cursor position at the time of the event */
  82934. pointerX: number,
  82935. /** The Y mouse cursor position at the time of the event */
  82936. pointerY: number,
  82937. /** The mesh that is currently pointed at (can be null) */
  82938. meshUnderPointer: Nullable<AbstractMesh>,
  82939. /** the original (browser) event that triggered the ActionEvent */
  82940. sourceEvent?: any,
  82941. /** additional data for the event */
  82942. additionalData?: any);
  82943. /**
  82944. * Helper function to auto-create an ActionEvent from a source mesh.
  82945. * @param source The source mesh that triggered the event
  82946. * @param evt The original (browser) event
  82947. * @param additionalData additional data for the event
  82948. * @returns the new ActionEvent
  82949. */
  82950. static CreateNew(source: AbstractMesh, evt?: Event, additionalData?: any): ActionEvent;
  82951. /**
  82952. * Helper function to auto-create an ActionEvent from a source sprite
  82953. * @param source The source sprite that triggered the event
  82954. * @param scene Scene associated with the sprite
  82955. * @param evt The original (browser) event
  82956. * @param additionalData additional data for the event
  82957. * @returns the new ActionEvent
  82958. */
  82959. static CreateNewFromSprite(source: Sprite, scene: Scene, evt?: Event, additionalData?: any): ActionEvent;
  82960. /**
  82961. * Helper function to auto-create an ActionEvent from a scene. If triggered by a mesh use ActionEvent.CreateNew
  82962. * @param scene the scene where the event occurred
  82963. * @param evt The original (browser) event
  82964. * @returns the new ActionEvent
  82965. */
  82966. static CreateNewFromScene(scene: Scene, evt: Event): ActionEvent;
  82967. /**
  82968. * Helper function to auto-create an ActionEvent from a primitive
  82969. * @param prim defines the target primitive
  82970. * @param pointerPos defines the pointer position
  82971. * @param evt The original (browser) event
  82972. * @param additionalData additional data for the event
  82973. * @returns the new ActionEvent
  82974. */
  82975. static CreateNewFromPrimitive(prim: any, pointerPos: Vector2, evt?: Event, additionalData?: any): ActionEvent;
  82976. }
  82977. }
  82978. declare module BABYLON {
  82979. /**
  82980. * Abstract class used to decouple action Manager from scene and meshes.
  82981. * Do not instantiate.
  82982. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  82983. */
  82984. export abstract class AbstractActionManager implements IDisposable {
  82985. /** Gets the list of active triggers */
  82986. static Triggers: {
  82987. [key: string]: number;
  82988. };
  82989. /** Gets the cursor to use when hovering items */
  82990. hoverCursor: string;
  82991. /** Gets the list of actions */
  82992. actions: IAction[];
  82993. /**
  82994. * Gets or sets a boolean indicating that the manager is recursive meaning that it can trigger action from children
  82995. */
  82996. isRecursive: boolean;
  82997. /**
  82998. * Releases all associated resources
  82999. */
  83000. abstract dispose(): void;
  83001. /**
  83002. * Does this action manager has pointer triggers
  83003. */
  83004. abstract readonly hasPointerTriggers: boolean;
  83005. /**
  83006. * Does this action manager has pick triggers
  83007. */
  83008. abstract readonly hasPickTriggers: boolean;
  83009. /**
  83010. * Process a specific trigger
  83011. * @param trigger defines the trigger to process
  83012. * @param evt defines the event details to be processed
  83013. */
  83014. abstract processTrigger(trigger: number, evt?: IActionEvent): void;
  83015. /**
  83016. * Does this action manager handles actions of any of the given triggers
  83017. * @param triggers defines the triggers to be tested
  83018. * @return a boolean indicating whether one (or more) of the triggers is handled
  83019. */
  83020. abstract hasSpecificTriggers(triggers: number[]): boolean;
  83021. /**
  83022. * Does this action manager handles actions of any of the given triggers. This function takes two arguments for
  83023. * speed.
  83024. * @param triggerA defines the trigger to be tested
  83025. * @param triggerB defines the trigger to be tested
  83026. * @return a boolean indicating whether one (or more) of the triggers is handled
  83027. */
  83028. abstract hasSpecificTriggers2(triggerA: number, triggerB: number): boolean;
  83029. /**
  83030. * Does this action manager handles actions of a given trigger
  83031. * @param trigger defines the trigger to be tested
  83032. * @param parameterPredicate defines an optional predicate to filter triggers by parameter
  83033. * @return whether the trigger is handled
  83034. */
  83035. abstract hasSpecificTrigger(trigger: number, parameterPredicate?: (parameter: any) => boolean): boolean;
  83036. /**
  83037. * Serialize this manager to a JSON object
  83038. * @param name defines the property name to store this manager
  83039. * @returns a JSON representation of this manager
  83040. */
  83041. abstract serialize(name: string): any;
  83042. /**
  83043. * Registers an action to this action manager
  83044. * @param action defines the action to be registered
  83045. * @return the action amended (prepared) after registration
  83046. */
  83047. abstract registerAction(action: IAction): Nullable<IAction>;
  83048. /**
  83049. * Unregisters an action to this action manager
  83050. * @param action defines the action to be unregistered
  83051. * @return a boolean indicating whether the action has been unregistered
  83052. */
  83053. abstract unregisterAction(action: IAction): Boolean;
  83054. /**
  83055. * Does exist one action manager with at least one trigger
  83056. **/
  83057. static readonly HasTriggers: boolean;
  83058. /**
  83059. * Does exist one action manager with at least one pick trigger
  83060. **/
  83061. static readonly HasPickTriggers: boolean;
  83062. /**
  83063. * Does exist one action manager that handles actions of a given trigger
  83064. * @param trigger defines the trigger to be tested
  83065. * @return a boolean indicating whether the trigger is handeled by at least one action manager
  83066. **/
  83067. static HasSpecificTrigger(trigger: number): boolean;
  83068. }
  83069. }
  83070. declare module BABYLON {
  83071. /**
  83072. * Defines how a node can be built from a string name.
  83073. */
  83074. export type NodeConstructor = (name: string, scene: Scene, options?: any) => () => Node;
  83075. /**
  83076. * Node is the basic class for all scene objects (Mesh, Light, Camera.)
  83077. */
  83078. export class Node implements IBehaviorAware<Node> {
  83079. /** @hidden */
  83080. static _AnimationRangeFactory: (name: string, from: number, to: number) => AnimationRange;
  83081. private static _NodeConstructors;
  83082. /**
  83083. * Add a new node constructor
  83084. * @param type defines the type name of the node to construct
  83085. * @param constructorFunc defines the constructor function
  83086. */
  83087. static AddNodeConstructor(type: string, constructorFunc: NodeConstructor): void;
  83088. /**
  83089. * Returns a node constructor based on type name
  83090. * @param type defines the type name
  83091. * @param name defines the new node name
  83092. * @param scene defines the hosting scene
  83093. * @param options defines optional options to transmit to constructors
  83094. * @returns the new constructor or null
  83095. */
  83096. static Construct(type: string, name: string, scene: Scene, options?: any): Nullable<() => Node>;
  83097. /**
  83098. * Gets or sets the name of the node
  83099. */
  83100. name: string;
  83101. /**
  83102. * Gets or sets the id of the node
  83103. */
  83104. id: string;
  83105. /**
  83106. * Gets or sets the unique id of the node
  83107. */
  83108. uniqueId: number;
  83109. /**
  83110. * Gets or sets a string used to store user defined state for the node
  83111. */
  83112. state: string;
  83113. /**
  83114. * Gets or sets an object used to store user defined information for the node
  83115. */
  83116. metadata: any;
  83117. /**
  83118. * For internal use only. Please do not use.
  83119. */
  83120. reservedDataStore: any;
  83121. /**
  83122. * List of inspectable custom properties (used by the Inspector)
  83123. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  83124. */
  83125. inspectableCustomProperties: IInspectable[];
  83126. /**
  83127. * Gets or sets a boolean used to define if the node must be serialized
  83128. */
  83129. doNotSerialize: boolean;
  83130. /** @hidden */
  83131. _isDisposed: boolean;
  83132. /**
  83133. * Gets a list of Animations associated with the node
  83134. */
  83135. animations: Animation[];
  83136. protected _ranges: {
  83137. [name: string]: Nullable<AnimationRange>;
  83138. };
  83139. /**
  83140. * Callback raised when the node is ready to be used
  83141. */
  83142. onReady: (node: Node) => void;
  83143. private _isEnabled;
  83144. private _isParentEnabled;
  83145. private _isReady;
  83146. /** @hidden */
  83147. _currentRenderId: number;
  83148. private _parentRenderId;
  83149. protected _childRenderId: number;
  83150. /** @hidden */
  83151. _waitingParentId: Nullable<string>;
  83152. /** @hidden */
  83153. _scene: Scene;
  83154. /** @hidden */
  83155. _cache: any;
  83156. private _parentNode;
  83157. private _children;
  83158. /** @hidden */
  83159. _worldMatrix: Matrix;
  83160. /** @hidden */
  83161. _worldMatrixDeterminant: number;
  83162. /** @hidden */
  83163. private _sceneRootNodesIndex;
  83164. /**
  83165. * Gets a boolean indicating if the node has been disposed
  83166. * @returns true if the node was disposed
  83167. */
  83168. isDisposed(): boolean;
  83169. /**
  83170. * Gets or sets the parent of the node (without keeping the current position in the scene)
  83171. * @see https://doc.babylonjs.com/how_to/parenting
  83172. */
  83173. parent: Nullable<Node>;
  83174. private addToSceneRootNodes;
  83175. private removeFromSceneRootNodes;
  83176. private _animationPropertiesOverride;
  83177. /**
  83178. * Gets or sets the animation properties override
  83179. */
  83180. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  83181. /**
  83182. * Gets a string idenfifying the name of the class
  83183. * @returns "Node" string
  83184. */
  83185. getClassName(): string;
  83186. /** @hidden */
  83187. readonly _isNode: boolean;
  83188. /**
  83189. * An event triggered when the mesh is disposed
  83190. */
  83191. onDisposeObservable: Observable<Node>;
  83192. private _onDisposeObserver;
  83193. /**
  83194. * Sets a callback that will be raised when the node will be disposed
  83195. */
  83196. onDispose: () => void;
  83197. /**
  83198. * Creates a new Node
  83199. * @param name the name and id to be given to this node
  83200. * @param scene the scene this node will be added to
  83201. * @param addToRootNodes the node will be added to scene.rootNodes
  83202. */
  83203. constructor(name: string, scene?: Nullable<Scene>, addToRootNodes?: boolean);
  83204. /**
  83205. * Gets the scene of the node
  83206. * @returns a scene
  83207. */
  83208. getScene(): Scene;
  83209. /**
  83210. * Gets the engine of the node
  83211. * @returns a Engine
  83212. */
  83213. getEngine(): Engine;
  83214. private _behaviors;
  83215. /**
  83216. * Attach a behavior to the node
  83217. * @see http://doc.babylonjs.com/features/behaviour
  83218. * @param behavior defines the behavior to attach
  83219. * @param attachImmediately defines that the behavior must be attached even if the scene is still loading
  83220. * @returns the current Node
  83221. */
  83222. addBehavior(behavior: Behavior<Node>, attachImmediately?: boolean): Node;
  83223. /**
  83224. * Remove an attached behavior
  83225. * @see http://doc.babylonjs.com/features/behaviour
  83226. * @param behavior defines the behavior to attach
  83227. * @returns the current Node
  83228. */
  83229. removeBehavior(behavior: Behavior<Node>): Node;
  83230. /**
  83231. * Gets the list of attached behaviors
  83232. * @see http://doc.babylonjs.com/features/behaviour
  83233. */
  83234. readonly behaviors: Behavior<Node>[];
  83235. /**
  83236. * Gets an attached behavior by name
  83237. * @param name defines the name of the behavior to look for
  83238. * @see http://doc.babylonjs.com/features/behaviour
  83239. * @returns null if behavior was not found else the requested behavior
  83240. */
  83241. getBehaviorByName(name: string): Nullable<Behavior<Node>>;
  83242. /**
  83243. * Returns the latest update of the World matrix
  83244. * @returns a Matrix
  83245. */
  83246. getWorldMatrix(): Matrix;
  83247. /** @hidden */
  83248. _getWorldMatrixDeterminant(): number;
  83249. /**
  83250. * Returns directly the latest state of the mesh World matrix.
  83251. * A Matrix is returned.
  83252. */
  83253. readonly worldMatrixFromCache: Matrix;
  83254. /** @hidden */
  83255. _initCache(): void;
  83256. /** @hidden */
  83257. updateCache(force?: boolean): void;
  83258. /** @hidden */
  83259. _getActionManagerForTrigger(trigger?: number, initialCall?: boolean): Nullable<AbstractActionManager>;
  83260. /** @hidden */
  83261. _updateCache(ignoreParentClass?: boolean): void;
  83262. /** @hidden */
  83263. _isSynchronized(): boolean;
  83264. /** @hidden */
  83265. _markSyncedWithParent(): void;
  83266. /** @hidden */
  83267. isSynchronizedWithParent(): boolean;
  83268. /** @hidden */
  83269. isSynchronized(): boolean;
  83270. /**
  83271. * Is this node ready to be used/rendered
  83272. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  83273. * @return true if the node is ready
  83274. */
  83275. isReady(completeCheck?: boolean): boolean;
  83276. /**
  83277. * Is this node enabled?
  83278. * 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
  83279. * @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
  83280. * @return whether this node (and its parent) is enabled
  83281. */
  83282. isEnabled(checkAncestors?: boolean): boolean;
  83283. /** @hidden */
  83284. protected _syncParentEnabledState(): void;
  83285. /**
  83286. * Set the enabled state of this node
  83287. * @param value defines the new enabled state
  83288. */
  83289. setEnabled(value: boolean): void;
  83290. /**
  83291. * Is this node a descendant of the given node?
  83292. * The function will iterate up the hierarchy until the ancestor was found or no more parents defined
  83293. * @param ancestor defines the parent node to inspect
  83294. * @returns a boolean indicating if this node is a descendant of the given node
  83295. */
  83296. isDescendantOf(ancestor: Node): boolean;
  83297. /** @hidden */
  83298. _getDescendants(results: Node[], directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): void;
  83299. /**
  83300. * Will return all nodes that have this node as ascendant
  83301. * @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
  83302. * @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
  83303. * @return all children nodes of all types
  83304. */
  83305. getDescendants(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): Node[];
  83306. /**
  83307. * Get all child-meshes of this node
  83308. * @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)
  83309. * @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
  83310. * @returns an array of AbstractMesh
  83311. */
  83312. getChildMeshes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): AbstractMesh[];
  83313. /**
  83314. * Get all direct children of this node
  83315. * @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
  83316. * @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)
  83317. * @returns an array of Node
  83318. */
  83319. getChildren(predicate?: (node: Node) => boolean, directDescendantsOnly?: boolean): Node[];
  83320. /** @hidden */
  83321. _setReady(state: boolean): void;
  83322. /**
  83323. * Get an animation by name
  83324. * @param name defines the name of the animation to look for
  83325. * @returns null if not found else the requested animation
  83326. */
  83327. getAnimationByName(name: string): Nullable<Animation>;
  83328. /**
  83329. * Creates an animation range for this node
  83330. * @param name defines the name of the range
  83331. * @param from defines the starting key
  83332. * @param to defines the end key
  83333. */
  83334. createAnimationRange(name: string, from: number, to: number): void;
  83335. /**
  83336. * Delete a specific animation range
  83337. * @param name defines the name of the range to delete
  83338. * @param deleteFrames defines if animation frames from the range must be deleted as well
  83339. */
  83340. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  83341. /**
  83342. * Get an animation range by name
  83343. * @param name defines the name of the animation range to look for
  83344. * @returns null if not found else the requested animation range
  83345. */
  83346. getAnimationRange(name: string): Nullable<AnimationRange>;
  83347. /**
  83348. * Gets the list of all animation ranges defined on this node
  83349. * @returns an array
  83350. */
  83351. getAnimationRanges(): Nullable<AnimationRange>[];
  83352. /**
  83353. * Will start the animation sequence
  83354. * @param name defines the range frames for animation sequence
  83355. * @param loop defines if the animation should loop (false by default)
  83356. * @param speedRatio defines the speed factor in which to run the animation (1 by default)
  83357. * @param onAnimationEnd defines a function to be executed when the animation ended (undefined by default)
  83358. * @returns the object created for this animation. If range does not exist, it will return null
  83359. */
  83360. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  83361. /**
  83362. * Serialize animation ranges into a JSON compatible object
  83363. * @returns serialization object
  83364. */
  83365. serializeAnimationRanges(): any;
  83366. /**
  83367. * Computes the world matrix of the node
  83368. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  83369. * @returns the world matrix
  83370. */
  83371. computeWorldMatrix(force?: boolean): Matrix;
  83372. /**
  83373. * Releases resources associated with this node.
  83374. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  83375. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  83376. */
  83377. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  83378. /**
  83379. * Parse animation range data from a serialization object and store them into a given node
  83380. * @param node defines where to store the animation ranges
  83381. * @param parsedNode defines the serialization object to read data from
  83382. * @param scene defines the hosting scene
  83383. */
  83384. static ParseAnimationRanges(node: Node, parsedNode: any, scene: Scene): void;
  83385. }
  83386. }
  83387. declare module BABYLON {
  83388. /**
  83389. * Class used to store any kind of animation
  83390. */
  83391. export class Animation {
  83392. /**Name of the animation */
  83393. name: string;
  83394. /**Property to animate */
  83395. targetProperty: string;
  83396. /**The frames per second of the animation */
  83397. framePerSecond: number;
  83398. /**The data type of the animation */
  83399. dataType: number;
  83400. /**The loop mode of the animation */
  83401. loopMode?: number | undefined;
  83402. /**Specifies if blending should be enabled */
  83403. enableBlending?: boolean | undefined;
  83404. /**
  83405. * Use matrix interpolation instead of using direct key value when animating matrices
  83406. */
  83407. static AllowMatricesInterpolation: boolean;
  83408. /**
  83409. * When matrix interpolation is enabled, this boolean forces the system to use Matrix.DecomposeLerp instead of Matrix.Lerp. Interpolation is more precise but slower
  83410. */
  83411. static AllowMatrixDecomposeForInterpolation: boolean;
  83412. /**
  83413. * Stores the key frames of the animation
  83414. */
  83415. private _keys;
  83416. /**
  83417. * Stores the easing function of the animation
  83418. */
  83419. private _easingFunction;
  83420. /**
  83421. * @hidden Internal use only
  83422. */
  83423. _runtimeAnimations: RuntimeAnimation[];
  83424. /**
  83425. * The set of event that will be linked to this animation
  83426. */
  83427. private _events;
  83428. /**
  83429. * Stores an array of target property paths
  83430. */
  83431. targetPropertyPath: string[];
  83432. /**
  83433. * Stores the blending speed of the animation
  83434. */
  83435. blendingSpeed: number;
  83436. /**
  83437. * Stores the animation ranges for the animation
  83438. */
  83439. private _ranges;
  83440. /**
  83441. * @hidden Internal use
  83442. */
  83443. static _PrepareAnimation(name: string, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction): Nullable<Animation>;
  83444. /**
  83445. * Sets up an animation
  83446. * @param property The property to animate
  83447. * @param animationType The animation type to apply
  83448. * @param framePerSecond The frames per second of the animation
  83449. * @param easingFunction The easing function used in the animation
  83450. * @returns The created animation
  83451. */
  83452. static CreateAnimation(property: string, animationType: number, framePerSecond: number, easingFunction: EasingFunction): Animation;
  83453. /**
  83454. * Create and start an animation on a node
  83455. * @param name defines the name of the global animation that will be run on all nodes
  83456. * @param node defines the root node where the animation will take place
  83457. * @param targetProperty defines property to animate
  83458. * @param framePerSecond defines the number of frame per second yo use
  83459. * @param totalFrame defines the number of frames in total
  83460. * @param from defines the initial value
  83461. * @param to defines the final value
  83462. * @param loopMode defines which loop mode you want to use (off by default)
  83463. * @param easingFunction defines the easing function to use (linear by default)
  83464. * @param onAnimationEnd defines the callback to call when animation end
  83465. * @returns the animatable created for this animation
  83466. */
  83467. static CreateAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  83468. /**
  83469. * Create and start an animation on a node and its descendants
  83470. * @param name defines the name of the global animation that will be run on all nodes
  83471. * @param node defines the root node where the animation will take place
  83472. * @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
  83473. * @param targetProperty defines property to animate
  83474. * @param framePerSecond defines the number of frame per second to use
  83475. * @param totalFrame defines the number of frames in total
  83476. * @param from defines the initial value
  83477. * @param to defines the final value
  83478. * @param loopMode defines which loop mode you want to use (off by default)
  83479. * @param easingFunction defines the easing function to use (linear by default)
  83480. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  83481. * @returns the list of animatables created for all nodes
  83482. * @example https://www.babylonjs-playground.com/#MH0VLI
  83483. */
  83484. 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[]>;
  83485. /**
  83486. * Creates a new animation, merges it with the existing animations and starts it
  83487. * @param name Name of the animation
  83488. * @param node Node which contains the scene that begins the animations
  83489. * @param targetProperty Specifies which property to animate
  83490. * @param framePerSecond The frames per second of the animation
  83491. * @param totalFrame The total number of frames
  83492. * @param from The frame at the beginning of the animation
  83493. * @param to The frame at the end of the animation
  83494. * @param loopMode Specifies the loop mode of the animation
  83495. * @param easingFunction (Optional) The easing function of the animation, which allow custom mathematical formulas for animations
  83496. * @param onAnimationEnd Callback to run once the animation is complete
  83497. * @returns Nullable animation
  83498. */
  83499. static CreateMergeAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  83500. /**
  83501. * Transition property of an host to the target Value
  83502. * @param property The property to transition
  83503. * @param targetValue The target Value of the property
  83504. * @param host The object where the property to animate belongs
  83505. * @param scene Scene used to run the animation
  83506. * @param frameRate Framerate (in frame/s) to use
  83507. * @param transition The transition type we want to use
  83508. * @param duration The duration of the animation, in milliseconds
  83509. * @param onAnimationEnd Callback trigger at the end of the animation
  83510. * @returns Nullable animation
  83511. */
  83512. static TransitionTo(property: string, targetValue: any, host: any, scene: Scene, frameRate: number, transition: Animation, duration: number, onAnimationEnd?: Nullable<() => void>): Nullable<Animatable>;
  83513. /**
  83514. * Return the array of runtime animations currently using this animation
  83515. */
  83516. readonly runtimeAnimations: RuntimeAnimation[];
  83517. /**
  83518. * Specifies if any of the runtime animations are currently running
  83519. */
  83520. readonly hasRunningRuntimeAnimations: boolean;
  83521. /**
  83522. * Initializes the animation
  83523. * @param name Name of the animation
  83524. * @param targetProperty Property to animate
  83525. * @param framePerSecond The frames per second of the animation
  83526. * @param dataType The data type of the animation
  83527. * @param loopMode The loop mode of the animation
  83528. * @param enableBlending Specifies if blending should be enabled
  83529. */
  83530. constructor(
  83531. /**Name of the animation */
  83532. name: string,
  83533. /**Property to animate */
  83534. targetProperty: string,
  83535. /**The frames per second of the animation */
  83536. framePerSecond: number,
  83537. /**The data type of the animation */
  83538. dataType: number,
  83539. /**The loop mode of the animation */
  83540. loopMode?: number | undefined,
  83541. /**Specifies if blending should be enabled */
  83542. enableBlending?: boolean | undefined);
  83543. /**
  83544. * Converts the animation to a string
  83545. * @param fullDetails support for multiple levels of logging within scene loading
  83546. * @returns String form of the animation
  83547. */
  83548. toString(fullDetails?: boolean): string;
  83549. /**
  83550. * Add an event to this animation
  83551. * @param event Event to add
  83552. */
  83553. addEvent(event: AnimationEvent): void;
  83554. /**
  83555. * Remove all events found at the given frame
  83556. * @param frame The frame to remove events from
  83557. */
  83558. removeEvents(frame: number): void;
  83559. /**
  83560. * Retrieves all the events from the animation
  83561. * @returns Events from the animation
  83562. */
  83563. getEvents(): AnimationEvent[];
  83564. /**
  83565. * Creates an animation range
  83566. * @param name Name of the animation range
  83567. * @param from Starting frame of the animation range
  83568. * @param to Ending frame of the animation
  83569. */
  83570. createRange(name: string, from: number, to: number): void;
  83571. /**
  83572. * Deletes an animation range by name
  83573. * @param name Name of the animation range to delete
  83574. * @param deleteFrames Specifies if the key frames for the range should also be deleted (true) or not (false)
  83575. */
  83576. deleteRange(name: string, deleteFrames?: boolean): void;
  83577. /**
  83578. * Gets the animation range by name, or null if not defined
  83579. * @param name Name of the animation range
  83580. * @returns Nullable animation range
  83581. */
  83582. getRange(name: string): Nullable<AnimationRange>;
  83583. /**
  83584. * Gets the key frames from the animation
  83585. * @returns The key frames of the animation
  83586. */
  83587. getKeys(): Array<IAnimationKey>;
  83588. /**
  83589. * Gets the highest frame rate of the animation
  83590. * @returns Highest frame rate of the animation
  83591. */
  83592. getHighestFrame(): number;
  83593. /**
  83594. * Gets the easing function of the animation
  83595. * @returns Easing function of the animation
  83596. */
  83597. getEasingFunction(): IEasingFunction;
  83598. /**
  83599. * Sets the easing function of the animation
  83600. * @param easingFunction A custom mathematical formula for animation
  83601. */
  83602. setEasingFunction(easingFunction: EasingFunction): void;
  83603. /**
  83604. * Interpolates a scalar linearly
  83605. * @param startValue Start value of the animation curve
  83606. * @param endValue End value of the animation curve
  83607. * @param gradient Scalar amount to interpolate
  83608. * @returns Interpolated scalar value
  83609. */
  83610. floatInterpolateFunction(startValue: number, endValue: number, gradient: number): number;
  83611. /**
  83612. * Interpolates a scalar cubically
  83613. * @param startValue Start value of the animation curve
  83614. * @param outTangent End tangent of the animation
  83615. * @param endValue End value of the animation curve
  83616. * @param inTangent Start tangent of the animation curve
  83617. * @param gradient Scalar amount to interpolate
  83618. * @returns Interpolated scalar value
  83619. */
  83620. floatInterpolateFunctionWithTangents(startValue: number, outTangent: number, endValue: number, inTangent: number, gradient: number): number;
  83621. /**
  83622. * Interpolates a quaternion using a spherical linear interpolation
  83623. * @param startValue Start value of the animation curve
  83624. * @param endValue End value of the animation curve
  83625. * @param gradient Scalar amount to interpolate
  83626. * @returns Interpolated quaternion value
  83627. */
  83628. quaternionInterpolateFunction(startValue: Quaternion, endValue: Quaternion, gradient: number): Quaternion;
  83629. /**
  83630. * Interpolates a quaternion cubically
  83631. * @param startValue Start value of the animation curve
  83632. * @param outTangent End tangent of the animation curve
  83633. * @param endValue End value of the animation curve
  83634. * @param inTangent Start tangent of the animation curve
  83635. * @param gradient Scalar amount to interpolate
  83636. * @returns Interpolated quaternion value
  83637. */
  83638. quaternionInterpolateFunctionWithTangents(startValue: Quaternion, outTangent: Quaternion, endValue: Quaternion, inTangent: Quaternion, gradient: number): Quaternion;
  83639. /**
  83640. * Interpolates a Vector3 linearl
  83641. * @param startValue Start value of the animation curve
  83642. * @param endValue End value of the animation curve
  83643. * @param gradient Scalar amount to interpolate
  83644. * @returns Interpolated scalar value
  83645. */
  83646. vector3InterpolateFunction(startValue: Vector3, endValue: Vector3, gradient: number): Vector3;
  83647. /**
  83648. * Interpolates a Vector3 cubically
  83649. * @param startValue Start value of the animation curve
  83650. * @param outTangent End tangent of the animation
  83651. * @param endValue End value of the animation curve
  83652. * @param inTangent Start tangent of the animation curve
  83653. * @param gradient Scalar amount to interpolate
  83654. * @returns InterpolatedVector3 value
  83655. */
  83656. vector3InterpolateFunctionWithTangents(startValue: Vector3, outTangent: Vector3, endValue: Vector3, inTangent: Vector3, gradient: number): Vector3;
  83657. /**
  83658. * Interpolates a Vector2 linearly
  83659. * @param startValue Start value of the animation curve
  83660. * @param endValue End value of the animation curve
  83661. * @param gradient Scalar amount to interpolate
  83662. * @returns Interpolated Vector2 value
  83663. */
  83664. vector2InterpolateFunction(startValue: Vector2, endValue: Vector2, gradient: number): Vector2;
  83665. /**
  83666. * Interpolates a Vector2 cubically
  83667. * @param startValue Start value of the animation curve
  83668. * @param outTangent End tangent of the animation
  83669. * @param endValue End value of the animation curve
  83670. * @param inTangent Start tangent of the animation curve
  83671. * @param gradient Scalar amount to interpolate
  83672. * @returns Interpolated Vector2 value
  83673. */
  83674. vector2InterpolateFunctionWithTangents(startValue: Vector2, outTangent: Vector2, endValue: Vector2, inTangent: Vector2, gradient: number): Vector2;
  83675. /**
  83676. * Interpolates a size linearly
  83677. * @param startValue Start value of the animation curve
  83678. * @param endValue End value of the animation curve
  83679. * @param gradient Scalar amount to interpolate
  83680. * @returns Interpolated Size value
  83681. */
  83682. sizeInterpolateFunction(startValue: Size, endValue: Size, gradient: number): Size;
  83683. /**
  83684. * Interpolates a Color3 linearly
  83685. * @param startValue Start value of the animation curve
  83686. * @param endValue End value of the animation curve
  83687. * @param gradient Scalar amount to interpolate
  83688. * @returns Interpolated Color3 value
  83689. */
  83690. color3InterpolateFunction(startValue: Color3, endValue: Color3, gradient: number): Color3;
  83691. /**
  83692. * @hidden Internal use only
  83693. */
  83694. _getKeyValue(value: any): any;
  83695. /**
  83696. * @hidden Internal use only
  83697. */
  83698. _interpolate(currentFrame: number, repeatCount: number, workValue?: any, loopMode?: number, offsetValue?: any, highLimitValue?: any): any;
  83699. /**
  83700. * Defines the function to use to interpolate matrices
  83701. * @param startValue defines the start matrix
  83702. * @param endValue defines the end matrix
  83703. * @param gradient defines the gradient between both matrices
  83704. * @param result defines an optional target matrix where to store the interpolation
  83705. * @returns the interpolated matrix
  83706. */
  83707. matrixInterpolateFunction(startValue: Matrix, endValue: Matrix, gradient: number, result?: Matrix): Matrix;
  83708. /**
  83709. * Makes a copy of the animation
  83710. * @returns Cloned animation
  83711. */
  83712. clone(): Animation;
  83713. /**
  83714. * Sets the key frames of the animation
  83715. * @param values The animation key frames to set
  83716. */
  83717. setKeys(values: Array<IAnimationKey>): void;
  83718. /**
  83719. * Serializes the animation to an object
  83720. * @returns Serialized object
  83721. */
  83722. serialize(): any;
  83723. /**
  83724. * Float animation type
  83725. */
  83726. private static _ANIMATIONTYPE_FLOAT;
  83727. /**
  83728. * Vector3 animation type
  83729. */
  83730. private static _ANIMATIONTYPE_VECTOR3;
  83731. /**
  83732. * Quaternion animation type
  83733. */
  83734. private static _ANIMATIONTYPE_QUATERNION;
  83735. /**
  83736. * Matrix animation type
  83737. */
  83738. private static _ANIMATIONTYPE_MATRIX;
  83739. /**
  83740. * Color3 animation type
  83741. */
  83742. private static _ANIMATIONTYPE_COLOR3;
  83743. /**
  83744. * Vector2 animation type
  83745. */
  83746. private static _ANIMATIONTYPE_VECTOR2;
  83747. /**
  83748. * Size animation type
  83749. */
  83750. private static _ANIMATIONTYPE_SIZE;
  83751. /**
  83752. * Relative Loop Mode
  83753. */
  83754. private static _ANIMATIONLOOPMODE_RELATIVE;
  83755. /**
  83756. * Cycle Loop Mode
  83757. */
  83758. private static _ANIMATIONLOOPMODE_CYCLE;
  83759. /**
  83760. * Constant Loop Mode
  83761. */
  83762. private static _ANIMATIONLOOPMODE_CONSTANT;
  83763. /**
  83764. * Get the float animation type
  83765. */
  83766. static readonly ANIMATIONTYPE_FLOAT: number;
  83767. /**
  83768. * Get the Vector3 animation type
  83769. */
  83770. static readonly ANIMATIONTYPE_VECTOR3: number;
  83771. /**
  83772. * Get the Vector2 animation type
  83773. */
  83774. static readonly ANIMATIONTYPE_VECTOR2: number;
  83775. /**
  83776. * Get the Size animation type
  83777. */
  83778. static readonly ANIMATIONTYPE_SIZE: number;
  83779. /**
  83780. * Get the Quaternion animation type
  83781. */
  83782. static readonly ANIMATIONTYPE_QUATERNION: number;
  83783. /**
  83784. * Get the Matrix animation type
  83785. */
  83786. static readonly ANIMATIONTYPE_MATRIX: number;
  83787. /**
  83788. * Get the Color3 animation type
  83789. */
  83790. static readonly ANIMATIONTYPE_COLOR3: number;
  83791. /**
  83792. * Get the Relative Loop Mode
  83793. */
  83794. static readonly ANIMATIONLOOPMODE_RELATIVE: number;
  83795. /**
  83796. * Get the Cycle Loop Mode
  83797. */
  83798. static readonly ANIMATIONLOOPMODE_CYCLE: number;
  83799. /**
  83800. * Get the Constant Loop Mode
  83801. */
  83802. static readonly ANIMATIONLOOPMODE_CONSTANT: number;
  83803. /** @hidden */
  83804. static _UniversalLerp(left: any, right: any, amount: number): any;
  83805. /**
  83806. * Parses an animation object and creates an animation
  83807. * @param parsedAnimation Parsed animation object
  83808. * @returns Animation object
  83809. */
  83810. static Parse(parsedAnimation: any): Animation;
  83811. /**
  83812. * Appends the serialized animations from the source animations
  83813. * @param source Source containing the animations
  83814. * @param destination Target to store the animations
  83815. */
  83816. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  83817. }
  83818. }
  83819. declare module BABYLON {
  83820. /**
  83821. * Base class of all the textures in babylon.
  83822. * It groups all the common properties the materials, post process, lights... might need
  83823. * in order to make a correct use of the texture.
  83824. */
  83825. export class BaseTexture implements IAnimatable {
  83826. /**
  83827. * Default anisotropic filtering level for the application.
  83828. * It is set to 4 as a good tradeoff between perf and quality.
  83829. */
  83830. static DEFAULT_ANISOTROPIC_FILTERING_LEVEL: number;
  83831. /**
  83832. * Gets or sets the unique id of the texture
  83833. */
  83834. uniqueId: number;
  83835. /**
  83836. * Define the name of the texture.
  83837. */
  83838. name: string;
  83839. /**
  83840. * Gets or sets an object used to store user defined information.
  83841. */
  83842. metadata: any;
  83843. /**
  83844. * For internal use only. Please do not use.
  83845. */
  83846. reservedDataStore: any;
  83847. private _hasAlpha;
  83848. /**
  83849. * Define if the texture is having a usable alpha value (can be use for transparency or glossiness for instance).
  83850. */
  83851. hasAlpha: boolean;
  83852. /**
  83853. * Defines if the alpha value should be determined via the rgb values.
  83854. * If true the luminance of the pixel might be used to find the corresponding alpha value.
  83855. */
  83856. getAlphaFromRGB: boolean;
  83857. /**
  83858. * Intensity or strength of the texture.
  83859. * It is commonly used by materials to fine tune the intensity of the texture
  83860. */
  83861. level: number;
  83862. /**
  83863. * Define the UV chanel to use starting from 0 and defaulting to 0.
  83864. * This is part of the texture as textures usually maps to one uv set.
  83865. */
  83866. coordinatesIndex: number;
  83867. private _coordinatesMode;
  83868. /**
  83869. * How a texture is mapped.
  83870. *
  83871. * | Value | Type | Description |
  83872. * | ----- | ----------------------------------- | ----------- |
  83873. * | 0 | EXPLICIT_MODE | |
  83874. * | 1 | SPHERICAL_MODE | |
  83875. * | 2 | PLANAR_MODE | |
  83876. * | 3 | CUBIC_MODE | |
  83877. * | 4 | PROJECTION_MODE | |
  83878. * | 5 | SKYBOX_MODE | |
  83879. * | 6 | INVCUBIC_MODE | |
  83880. * | 7 | EQUIRECTANGULAR_MODE | |
  83881. * | 8 | FIXED_EQUIRECTANGULAR_MODE | |
  83882. * | 9 | FIXED_EQUIRECTANGULAR_MIRRORED_MODE | |
  83883. */
  83884. coordinatesMode: number;
  83885. /**
  83886. * | Value | Type | Description |
  83887. * | ----- | ------------------ | ----------- |
  83888. * | 0 | CLAMP_ADDRESSMODE | |
  83889. * | 1 | WRAP_ADDRESSMODE | |
  83890. * | 2 | MIRROR_ADDRESSMODE | |
  83891. */
  83892. wrapU: number;
  83893. /**
  83894. * | Value | Type | Description |
  83895. * | ----- | ------------------ | ----------- |
  83896. * | 0 | CLAMP_ADDRESSMODE | |
  83897. * | 1 | WRAP_ADDRESSMODE | |
  83898. * | 2 | MIRROR_ADDRESSMODE | |
  83899. */
  83900. wrapV: number;
  83901. /**
  83902. * | Value | Type | Description |
  83903. * | ----- | ------------------ | ----------- |
  83904. * | 0 | CLAMP_ADDRESSMODE | |
  83905. * | 1 | WRAP_ADDRESSMODE | |
  83906. * | 2 | MIRROR_ADDRESSMODE | |
  83907. */
  83908. wrapR: number;
  83909. /**
  83910. * With compliant hardware and browser (supporting anisotropic filtering)
  83911. * this defines the level of anisotropic filtering in the texture.
  83912. * The higher the better but the slower. This defaults to 4 as it seems to be the best tradeoff.
  83913. */
  83914. anisotropicFilteringLevel: number;
  83915. /**
  83916. * Define if the texture is a cube texture or if false a 2d texture.
  83917. */
  83918. isCube: boolean;
  83919. /**
  83920. * Define if the texture is a 3d texture (webgl 2) or if false a 2d texture.
  83921. */
  83922. is3D: boolean;
  83923. /**
  83924. * Define if the texture contains data in gamma space (most of the png/jpg aside bump).
  83925. * HDR texture are usually stored in linear space.
  83926. * This only impacts the PBR and Background materials
  83927. */
  83928. gammaSpace: boolean;
  83929. /**
  83930. * Gets whether or not the texture contains RGBD data.
  83931. */
  83932. readonly isRGBD: boolean;
  83933. /**
  83934. * Is Z inverted in the texture (useful in a cube texture).
  83935. */
  83936. invertZ: boolean;
  83937. /**
  83938. * Are mip maps generated for this texture or not.
  83939. */
  83940. readonly noMipmap: boolean;
  83941. /**
  83942. * @hidden
  83943. */
  83944. lodLevelInAlpha: boolean;
  83945. /**
  83946. * With prefiltered texture, defined the offset used during the prefiltering steps.
  83947. */
  83948. lodGenerationOffset: number;
  83949. /**
  83950. * With prefiltered texture, defined the scale used during the prefiltering steps.
  83951. */
  83952. lodGenerationScale: number;
  83953. /**
  83954. * Define if the texture is a render target.
  83955. */
  83956. isRenderTarget: boolean;
  83957. /**
  83958. * Define the unique id of the texture in the scene.
  83959. */
  83960. readonly uid: string;
  83961. /**
  83962. * Return a string representation of the texture.
  83963. * @returns the texture as a string
  83964. */
  83965. toString(): string;
  83966. /**
  83967. * Get the class name of the texture.
  83968. * @returns "BaseTexture"
  83969. */
  83970. getClassName(): string;
  83971. /**
  83972. * Define the list of animation attached to the texture.
  83973. */
  83974. animations: Animation[];
  83975. /**
  83976. * An event triggered when the texture is disposed.
  83977. */
  83978. onDisposeObservable: Observable<BaseTexture>;
  83979. private _onDisposeObserver;
  83980. /**
  83981. * Callback triggered when the texture has been disposed.
  83982. * Kept for back compatibility, you can use the onDisposeObservable instead.
  83983. */
  83984. onDispose: () => void;
  83985. /**
  83986. * Define the current state of the loading sequence when in delayed load mode.
  83987. */
  83988. delayLoadState: number;
  83989. private _scene;
  83990. /** @hidden */
  83991. _texture: Nullable<InternalTexture>;
  83992. private _uid;
  83993. /**
  83994. * Define if the texture is preventinga material to render or not.
  83995. * If not and the texture is not ready, the engine will use a default black texture instead.
  83996. */
  83997. readonly isBlocking: boolean;
  83998. /**
  83999. * Instantiates a new BaseTexture.
  84000. * Base class of all the textures in babylon.
  84001. * It groups all the common properties the materials, post process, lights... might need
  84002. * in order to make a correct use of the texture.
  84003. * @param scene Define the scene the texture blongs to
  84004. */
  84005. constructor(scene: Nullable<Scene>);
  84006. /**
  84007. * Get the scene the texture belongs to.
  84008. * @returns the scene or null if undefined
  84009. */
  84010. getScene(): Nullable<Scene>;
  84011. /**
  84012. * Get the texture transform matrix used to offset tile the texture for istance.
  84013. * @returns the transformation matrix
  84014. */
  84015. getTextureMatrix(): Matrix;
  84016. /**
  84017. * Get the texture reflection matrix used to rotate/transform the reflection.
  84018. * @returns the reflection matrix
  84019. */
  84020. getReflectionTextureMatrix(): Matrix;
  84021. /**
  84022. * Get the underlying lower level texture from Babylon.
  84023. * @returns the insternal texture
  84024. */
  84025. getInternalTexture(): Nullable<InternalTexture>;
  84026. /**
  84027. * Get if the texture is ready to be consumed (either it is ready or it is not blocking)
  84028. * @returns true if ready or not blocking
  84029. */
  84030. isReadyOrNotBlocking(): boolean;
  84031. /**
  84032. * Get if the texture is ready to be used (downloaded, converted, mip mapped...).
  84033. * @returns true if fully ready
  84034. */
  84035. isReady(): boolean;
  84036. private _cachedSize;
  84037. /**
  84038. * Get the size of the texture.
  84039. * @returns the texture size.
  84040. */
  84041. getSize(): ISize;
  84042. /**
  84043. * Get the base size of the texture.
  84044. * It can be different from the size if the texture has been resized for POT for instance
  84045. * @returns the base size
  84046. */
  84047. getBaseSize(): ISize;
  84048. /**
  84049. * Update the sampling mode of the texture.
  84050. * Default is Trilinear mode.
  84051. *
  84052. * | Value | Type | Description |
  84053. * | ----- | ------------------ | ----------- |
  84054. * | 1 | NEAREST_SAMPLINGMODE or NEAREST_NEAREST_MIPLINEAR | Nearest is: mag = nearest, min = nearest, mip = linear |
  84055. * | 2 | BILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPNEAREST | Bilinear is: mag = linear, min = linear, mip = nearest |
  84056. * | 3 | TRILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPLINEAR | Trilinear is: mag = linear, min = linear, mip = linear |
  84057. * | 4 | NEAREST_NEAREST_MIPNEAREST | |
  84058. * | 5 | NEAREST_LINEAR_MIPNEAREST | |
  84059. * | 6 | NEAREST_LINEAR_MIPLINEAR | |
  84060. * | 7 | NEAREST_LINEAR | |
  84061. * | 8 | NEAREST_NEAREST | |
  84062. * | 9 | LINEAR_NEAREST_MIPNEAREST | |
  84063. * | 10 | LINEAR_NEAREST_MIPLINEAR | |
  84064. * | 11 | LINEAR_LINEAR | |
  84065. * | 12 | LINEAR_NEAREST | |
  84066. *
  84067. * > _mag_: magnification filter (close to the viewer)
  84068. * > _min_: minification filter (far from the viewer)
  84069. * > _mip_: filter used between mip map levels
  84070. *@param samplingMode Define the new sampling mode of the texture
  84071. */
  84072. updateSamplingMode(samplingMode: number): void;
  84073. /**
  84074. * Scales the texture if is `canRescale()`
  84075. * @param ratio the resize factor we want to use to rescale
  84076. */
  84077. scale(ratio: number): void;
  84078. /**
  84079. * Get if the texture can rescale.
  84080. */
  84081. readonly canRescale: boolean;
  84082. /** @hidden */
  84083. _getFromCache(url: Nullable<string>, noMipmap: boolean, sampling?: number, invertY?: boolean): Nullable<InternalTexture>;
  84084. /** @hidden */
  84085. _rebuild(): void;
  84086. /**
  84087. * Triggers the load sequence in delayed load mode.
  84088. */
  84089. delayLoad(): void;
  84090. /**
  84091. * Clones the texture.
  84092. * @returns the cloned texture
  84093. */
  84094. clone(): Nullable<BaseTexture>;
  84095. /**
  84096. * Get the texture underlying type (INT, FLOAT...)
  84097. */
  84098. readonly textureType: number;
  84099. /**
  84100. * Get the texture underlying format (RGB, RGBA...)
  84101. */
  84102. readonly textureFormat: number;
  84103. /**
  84104. * Reads the pixels stored in the webgl texture and returns them as an ArrayBuffer.
  84105. * This will returns an RGBA array buffer containing either in values (0-255) or
  84106. * float values (0-1) depending of the underlying buffer type.
  84107. * @param faceIndex defines the face of the texture to read (in case of cube texture)
  84108. * @param level defines the LOD level of the texture to read (in case of Mip Maps)
  84109. * @param buffer defines a user defined buffer to fill with data (can be null)
  84110. * @returns The Array buffer containing the pixels data.
  84111. */
  84112. readPixels(faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>): Nullable<ArrayBufferView>;
  84113. /**
  84114. * Release and destroy the underlying lower level texture aka internalTexture.
  84115. */
  84116. releaseInternalTexture(): void;
  84117. /**
  84118. * Get the polynomial representation of the texture data.
  84119. * This is mainly use as a fast way to recover IBL Diffuse irradiance data.
  84120. * @see https://learnopengl.com/PBR/IBL/Diffuse-irradiance
  84121. */
  84122. sphericalPolynomial: Nullable<SphericalPolynomial>;
  84123. /** @hidden */
  84124. readonly _lodTextureHigh: Nullable<BaseTexture>;
  84125. /** @hidden */
  84126. readonly _lodTextureMid: Nullable<BaseTexture>;
  84127. /** @hidden */
  84128. readonly _lodTextureLow: Nullable<BaseTexture>;
  84129. /**
  84130. * Dispose the texture and release its associated resources.
  84131. */
  84132. dispose(): void;
  84133. /**
  84134. * Serialize the texture into a JSON representation that can be parsed later on.
  84135. * @returns the JSON representation of the texture
  84136. */
  84137. serialize(): any;
  84138. /**
  84139. * Helper function to be called back once a list of texture contains only ready textures.
  84140. * @param textures Define the list of textures to wait for
  84141. * @param callback Define the callback triggered once the entire list will be ready
  84142. */
  84143. static WhenAllReady(textures: BaseTexture[], callback: () => void): void;
  84144. }
  84145. }
  84146. declare module BABYLON {
  84147. /**
  84148. * Uniform buffer objects.
  84149. *
  84150. * Handles blocks of uniform on the GPU.
  84151. *
  84152. * If WebGL 2 is not available, this class falls back on traditionnal setUniformXXX calls.
  84153. *
  84154. * For more information, please refer to :
  84155. * https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
  84156. */
  84157. export class UniformBuffer {
  84158. private _engine;
  84159. private _buffer;
  84160. private _data;
  84161. private _bufferData;
  84162. private _dynamic?;
  84163. private _uniformLocations;
  84164. private _uniformSizes;
  84165. private _uniformLocationPointer;
  84166. private _needSync;
  84167. private _noUBO;
  84168. private _currentEffect;
  84169. private static _MAX_UNIFORM_SIZE;
  84170. private static _tempBuffer;
  84171. /**
  84172. * Lambda to Update a 3x3 Matrix in a uniform buffer.
  84173. * This is dynamic to allow compat with webgl 1 and 2.
  84174. * You will need to pass the name of the uniform as well as the value.
  84175. */
  84176. updateMatrix3x3: (name: string, matrix: Float32Array) => void;
  84177. /**
  84178. * Lambda to Update a 2x2 Matrix in a uniform buffer.
  84179. * This is dynamic to allow compat with webgl 1 and 2.
  84180. * You will need to pass the name of the uniform as well as the value.
  84181. */
  84182. updateMatrix2x2: (name: string, matrix: Float32Array) => void;
  84183. /**
  84184. * Lambda to Update a single float in a uniform buffer.
  84185. * This is dynamic to allow compat with webgl 1 and 2.
  84186. * You will need to pass the name of the uniform as well as the value.
  84187. */
  84188. updateFloat: (name: string, x: number) => void;
  84189. /**
  84190. * Lambda to Update a vec2 of float in a uniform buffer.
  84191. * This is dynamic to allow compat with webgl 1 and 2.
  84192. * You will need to pass the name of the uniform as well as the value.
  84193. */
  84194. updateFloat2: (name: string, x: number, y: number, suffix?: string) => void;
  84195. /**
  84196. * Lambda to Update a vec3 of float in a uniform buffer.
  84197. * This is dynamic to allow compat with webgl 1 and 2.
  84198. * You will need to pass the name of the uniform as well as the value.
  84199. */
  84200. updateFloat3: (name: string, x: number, y: number, z: number, suffix?: string) => void;
  84201. /**
  84202. * Lambda to Update a vec4 of float in a uniform buffer.
  84203. * This is dynamic to allow compat with webgl 1 and 2.
  84204. * You will need to pass the name of the uniform as well as the value.
  84205. */
  84206. updateFloat4: (name: string, x: number, y: number, z: number, w: number, suffix?: string) => void;
  84207. /**
  84208. * Lambda to Update a 4x4 Matrix in a uniform buffer.
  84209. * This is dynamic to allow compat with webgl 1 and 2.
  84210. * You will need to pass the name of the uniform as well as the value.
  84211. */
  84212. updateMatrix: (name: string, mat: Matrix) => void;
  84213. /**
  84214. * Lambda to Update vec3 of float from a Vector in a uniform buffer.
  84215. * This is dynamic to allow compat with webgl 1 and 2.
  84216. * You will need to pass the name of the uniform as well as the value.
  84217. */
  84218. updateVector3: (name: string, vector: Vector3) => void;
  84219. /**
  84220. * Lambda to Update vec4 of float from a Vector in a uniform buffer.
  84221. * This is dynamic to allow compat with webgl 1 and 2.
  84222. * You will need to pass the name of the uniform as well as the value.
  84223. */
  84224. updateVector4: (name: string, vector: Vector4) => void;
  84225. /**
  84226. * Lambda to Update vec3 of float from a Color in a uniform buffer.
  84227. * This is dynamic to allow compat with webgl 1 and 2.
  84228. * You will need to pass the name of the uniform as well as the value.
  84229. */
  84230. updateColor3: (name: string, color: Color3, suffix?: string) => void;
  84231. /**
  84232. * Lambda to Update vec4 of float from a Color in a uniform buffer.
  84233. * This is dynamic to allow compat with webgl 1 and 2.
  84234. * You will need to pass the name of the uniform as well as the value.
  84235. */
  84236. updateColor4: (name: string, color: Color3, alpha: number, suffix?: string) => void;
  84237. /**
  84238. * Instantiates a new Uniform buffer objects.
  84239. *
  84240. * Handles blocks of uniform on the GPU.
  84241. *
  84242. * If WebGL 2 is not available, this class falls back on traditionnal setUniformXXX calls.
  84243. *
  84244. * For more information, please refer to :
  84245. * @see https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
  84246. * @param engine Define the engine the buffer is associated with
  84247. * @param data Define the data contained in the buffer
  84248. * @param dynamic Define if the buffer is updatable
  84249. */
  84250. constructor(engine: Engine, data?: number[], dynamic?: boolean);
  84251. /**
  84252. * Indicates if the buffer is using the WebGL2 UBO implementation,
  84253. * or just falling back on setUniformXXX calls.
  84254. */
  84255. readonly useUbo: boolean;
  84256. /**
  84257. * Indicates if the WebGL underlying uniform buffer is in sync
  84258. * with the javascript cache data.
  84259. */
  84260. readonly isSync: boolean;
  84261. /**
  84262. * Indicates if the WebGL underlying uniform buffer is dynamic.
  84263. * Also, a dynamic UniformBuffer will disable cache verification and always
  84264. * update the underlying WebGL uniform buffer to the GPU.
  84265. * @returns if Dynamic, otherwise false
  84266. */
  84267. isDynamic(): boolean;
  84268. /**
  84269. * The data cache on JS side.
  84270. * @returns the underlying data as a float array
  84271. */
  84272. getData(): Float32Array;
  84273. /**
  84274. * The underlying WebGL Uniform buffer.
  84275. * @returns the webgl buffer
  84276. */
  84277. getBuffer(): Nullable<WebGLBuffer>;
  84278. /**
  84279. * std140 layout specifies how to align data within an UBO structure.
  84280. * See https://khronos.org/registry/OpenGL/specs/gl/glspec45.core.pdf#page=159
  84281. * for specs.
  84282. */
  84283. private _fillAlignment;
  84284. /**
  84285. * Adds an uniform in the buffer.
  84286. * Warning : the subsequents calls of this function must be in the same order as declared in the shader
  84287. * for the layout to be correct !
  84288. * @param name Name of the uniform, as used in the uniform block in the shader.
  84289. * @param size Data size, or data directly.
  84290. */
  84291. addUniform(name: string, size: number | number[]): void;
  84292. /**
  84293. * Adds a Matrix 4x4 to the uniform buffer.
  84294. * @param name Name of the uniform, as used in the uniform block in the shader.
  84295. * @param mat A 4x4 matrix.
  84296. */
  84297. addMatrix(name: string, mat: Matrix): void;
  84298. /**
  84299. * Adds a vec2 to the uniform buffer.
  84300. * @param name Name of the uniform, as used in the uniform block in the shader.
  84301. * @param x Define the x component value of the vec2
  84302. * @param y Define the y component value of the vec2
  84303. */
  84304. addFloat2(name: string, x: number, y: number): void;
  84305. /**
  84306. * Adds a vec3 to the uniform buffer.
  84307. * @param name Name of the uniform, as used in the uniform block in the shader.
  84308. * @param x Define the x component value of the vec3
  84309. * @param y Define the y component value of the vec3
  84310. * @param z Define the z component value of the vec3
  84311. */
  84312. addFloat3(name: string, x: number, y: number, z: number): void;
  84313. /**
  84314. * Adds a vec3 to the uniform buffer.
  84315. * @param name Name of the uniform, as used in the uniform block in the shader.
  84316. * @param color Define the vec3 from a Color
  84317. */
  84318. addColor3(name: string, color: Color3): void;
  84319. /**
  84320. * Adds a vec4 to the uniform buffer.
  84321. * @param name Name of the uniform, as used in the uniform block in the shader.
  84322. * @param color Define the rgb components from a Color
  84323. * @param alpha Define the a component of the vec4
  84324. */
  84325. addColor4(name: string, color: Color3, alpha: number): void;
  84326. /**
  84327. * Adds a vec3 to the uniform buffer.
  84328. * @param name Name of the uniform, as used in the uniform block in the shader.
  84329. * @param vector Define the vec3 components from a Vector
  84330. */
  84331. addVector3(name: string, vector: Vector3): void;
  84332. /**
  84333. * Adds a Matrix 3x3 to the uniform buffer.
  84334. * @param name Name of the uniform, as used in the uniform block in the shader.
  84335. */
  84336. addMatrix3x3(name: string): void;
  84337. /**
  84338. * Adds a Matrix 2x2 to the uniform buffer.
  84339. * @param name Name of the uniform, as used in the uniform block in the shader.
  84340. */
  84341. addMatrix2x2(name: string): void;
  84342. /**
  84343. * Effectively creates the WebGL Uniform Buffer, once layout is completed with `addUniform`.
  84344. */
  84345. create(): void;
  84346. /** @hidden */
  84347. _rebuild(): void;
  84348. /**
  84349. * Updates the WebGL Uniform Buffer on the GPU.
  84350. * If the `dynamic` flag is set to true, no cache comparison is done.
  84351. * Otherwise, the buffer will be updated only if the cache differs.
  84352. */
  84353. update(): void;
  84354. /**
  84355. * Updates the value of an uniform. The `update` method must be called afterwards to make it effective in the GPU.
  84356. * @param uniformName Define the name of the uniform, as used in the uniform block in the shader.
  84357. * @param data Define the flattened data
  84358. * @param size Define the size of the data.
  84359. */
  84360. updateUniform(uniformName: string, data: FloatArray, size: number): void;
  84361. private _updateMatrix3x3ForUniform;
  84362. private _updateMatrix3x3ForEffect;
  84363. private _updateMatrix2x2ForEffect;
  84364. private _updateMatrix2x2ForUniform;
  84365. private _updateFloatForEffect;
  84366. private _updateFloatForUniform;
  84367. private _updateFloat2ForEffect;
  84368. private _updateFloat2ForUniform;
  84369. private _updateFloat3ForEffect;
  84370. private _updateFloat3ForUniform;
  84371. private _updateFloat4ForEffect;
  84372. private _updateFloat4ForUniform;
  84373. private _updateMatrixForEffect;
  84374. private _updateMatrixForUniform;
  84375. private _updateVector3ForEffect;
  84376. private _updateVector3ForUniform;
  84377. private _updateVector4ForEffect;
  84378. private _updateVector4ForUniform;
  84379. private _updateColor3ForEffect;
  84380. private _updateColor3ForUniform;
  84381. private _updateColor4ForEffect;
  84382. private _updateColor4ForUniform;
  84383. /**
  84384. * Sets a sampler uniform on the effect.
  84385. * @param name Define the name of the sampler.
  84386. * @param texture Define the texture to set in the sampler
  84387. */
  84388. setTexture(name: string, texture: Nullable<BaseTexture>): void;
  84389. /**
  84390. * Directly updates the value of the uniform in the cache AND on the GPU.
  84391. * @param uniformName Define the name of the uniform, as used in the uniform block in the shader.
  84392. * @param data Define the flattened data
  84393. */
  84394. updateUniformDirectly(uniformName: string, data: FloatArray): void;
  84395. /**
  84396. * Binds this uniform buffer to an effect.
  84397. * @param effect Define the effect to bind the buffer to
  84398. * @param name Name of the uniform block in the shader.
  84399. */
  84400. bindToEffect(effect: Effect, name: string): void;
  84401. /**
  84402. * Disposes the uniform buffer.
  84403. */
  84404. dispose(): void;
  84405. }
  84406. }
  84407. declare module BABYLON {
  84408. /**
  84409. * This represents the required contract to create a new type of texture loader.
  84410. */
  84411. export interface IInternalTextureLoader {
  84412. /**
  84413. * Defines wether the loader supports cascade loading the different faces.
  84414. */
  84415. supportCascades: boolean;
  84416. /**
  84417. * This returns if the loader support the current file information.
  84418. * @param extension defines the file extension of the file being loaded
  84419. * @param textureFormatInUse defines the current compressed format in use iun the engine
  84420. * @param fallback defines the fallback internal texture if any
  84421. * @param isBase64 defines whether the texture is encoded as a base64
  84422. * @param isBuffer defines whether the texture data are stored as a buffer
  84423. * @returns true if the loader can load the specified file
  84424. */
  84425. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  84426. /**
  84427. * Transform the url before loading if required.
  84428. * @param rootUrl the url of the texture
  84429. * @param textureFormatInUse defines the current compressed format in use iun the engine
  84430. * @returns the transformed texture
  84431. */
  84432. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  84433. /**
  84434. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  84435. * @param rootUrl the url of the texture
  84436. * @param textureFormatInUse defines the current compressed format in use iun the engine
  84437. * @returns the fallback texture
  84438. */
  84439. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  84440. /**
  84441. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  84442. * @param data contains the texture data
  84443. * @param texture defines the BabylonJS internal texture
  84444. * @param createPolynomials will be true if polynomials have been requested
  84445. * @param onLoad defines the callback to trigger once the texture is ready
  84446. * @param onError defines the callback to trigger in case of error
  84447. */
  84448. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  84449. /**
  84450. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  84451. * @param data contains the texture data
  84452. * @param texture defines the BabylonJS internal texture
  84453. * @param callback defines the method to call once ready to upload
  84454. */
  84455. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void, loadFailed?: boolean) => void): void;
  84456. }
  84457. }
  84458. declare module BABYLON {
  84459. /**
  84460. * Creation options of the multi render target texture.
  84461. */
  84462. export interface IMultiRenderTargetOptions {
  84463. /**
  84464. * Define if the texture needs to create mip maps after render.
  84465. */
  84466. generateMipMaps?: boolean;
  84467. /**
  84468. * Define the types of all the draw buffers we want to create
  84469. */
  84470. types?: number[];
  84471. /**
  84472. * Define the sampling modes of all the draw buffers we want to create
  84473. */
  84474. samplingModes?: number[];
  84475. /**
  84476. * Define if a depth buffer is required
  84477. */
  84478. generateDepthBuffer?: boolean;
  84479. /**
  84480. * Define if a stencil buffer is required
  84481. */
  84482. generateStencilBuffer?: boolean;
  84483. /**
  84484. * Define if a depth texture is required instead of a depth buffer
  84485. */
  84486. generateDepthTexture?: boolean;
  84487. /**
  84488. * Define the number of desired draw buffers
  84489. */
  84490. textureCount?: number;
  84491. /**
  84492. * Define if aspect ratio should be adapted to the texture or stay the scene one
  84493. */
  84494. doNotChangeAspectRatio?: boolean;
  84495. /**
  84496. * Define the default type of the buffers we are creating
  84497. */
  84498. defaultType?: number;
  84499. }
  84500. /**
  84501. * A multi render target, like a render target provides the ability to render to a texture.
  84502. * Unlike the render target, it can render to several draw buffers in one draw.
  84503. * This is specially interesting in deferred rendering or for any effects requiring more than
  84504. * just one color from a single pass.
  84505. */
  84506. export class MultiRenderTarget extends RenderTargetTexture {
  84507. private _internalTextures;
  84508. private _textures;
  84509. private _multiRenderTargetOptions;
  84510. /**
  84511. * Get if draw buffers are currently supported by the used hardware and browser.
  84512. */
  84513. readonly isSupported: boolean;
  84514. /**
  84515. * Get the list of textures generated by the multi render target.
  84516. */
  84517. readonly textures: Texture[];
  84518. /**
  84519. * Get the depth texture generated by the multi render target if options.generateDepthTexture has been set
  84520. */
  84521. readonly depthTexture: Texture;
  84522. /**
  84523. * Set the wrapping mode on U of all the textures we are rendering to.
  84524. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  84525. */
  84526. wrapU: number;
  84527. /**
  84528. * Set the wrapping mode on V of all the textures we are rendering to.
  84529. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  84530. */
  84531. wrapV: number;
  84532. /**
  84533. * Instantiate a new multi render target texture.
  84534. * A multi render target, like a render target provides the ability to render to a texture.
  84535. * Unlike the render target, it can render to several draw buffers in one draw.
  84536. * This is specially interesting in deferred rendering or for any effects requiring more than
  84537. * just one color from a single pass.
  84538. * @param name Define the name of the texture
  84539. * @param size Define the size of the buffers to render to
  84540. * @param count Define the number of target we are rendering into
  84541. * @param scene Define the scene the texture belongs to
  84542. * @param options Define the options used to create the multi render target
  84543. */
  84544. constructor(name: string, size: any, count: number, scene: Scene, options?: IMultiRenderTargetOptions);
  84545. /** @hidden */
  84546. _rebuild(): void;
  84547. private _createInternalTextures;
  84548. private _createTextures;
  84549. /**
  84550. * Define the number of samples used if MSAA is enabled.
  84551. */
  84552. samples: number;
  84553. /**
  84554. * Resize all the textures in the multi render target.
  84555. * Be carrefull as it will recreate all the data in the new texture.
  84556. * @param size Define the new size
  84557. */
  84558. resize(size: any): void;
  84559. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  84560. /**
  84561. * Dispose the render targets and their associated resources
  84562. */
  84563. dispose(): void;
  84564. /**
  84565. * Release all the underlying texture used as draw buffers.
  84566. */
  84567. releaseInternalTextures(): void;
  84568. }
  84569. }
  84570. declare module BABYLON {
  84571. /**
  84572. * Class used to work with sound analyzer using fast fourier transform (FFT)
  84573. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  84574. */
  84575. export class Analyser {
  84576. /**
  84577. * Gets or sets the smoothing
  84578. * @ignorenaming
  84579. */
  84580. SMOOTHING: number;
  84581. /**
  84582. * Gets or sets the FFT table size
  84583. * @ignorenaming
  84584. */
  84585. FFT_SIZE: number;
  84586. /**
  84587. * Gets or sets the bar graph amplitude
  84588. * @ignorenaming
  84589. */
  84590. BARGRAPHAMPLITUDE: number;
  84591. /**
  84592. * Gets or sets the position of the debug canvas
  84593. * @ignorenaming
  84594. */
  84595. DEBUGCANVASPOS: {
  84596. x: number;
  84597. y: number;
  84598. };
  84599. /**
  84600. * Gets or sets the debug canvas size
  84601. * @ignorenaming
  84602. */
  84603. DEBUGCANVASSIZE: {
  84604. width: number;
  84605. height: number;
  84606. };
  84607. private _byteFreqs;
  84608. private _byteTime;
  84609. private _floatFreqs;
  84610. private _webAudioAnalyser;
  84611. private _debugCanvas;
  84612. private _debugCanvasContext;
  84613. private _scene;
  84614. private _registerFunc;
  84615. private _audioEngine;
  84616. /**
  84617. * Creates a new analyser
  84618. * @param scene defines hosting scene
  84619. */
  84620. constructor(scene: Scene);
  84621. /**
  84622. * Get the number of data values you will have to play with for the visualization
  84623. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/frequencyBinCount
  84624. * @returns a number
  84625. */
  84626. getFrequencyBinCount(): number;
  84627. /**
  84628. * Gets the current frequency data as a byte array
  84629. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  84630. * @returns a Uint8Array
  84631. */
  84632. getByteFrequencyData(): Uint8Array;
  84633. /**
  84634. * Gets the current waveform as a byte array
  84635. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteTimeDomainData
  84636. * @returns a Uint8Array
  84637. */
  84638. getByteTimeDomainData(): Uint8Array;
  84639. /**
  84640. * Gets the current frequency data as a float array
  84641. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  84642. * @returns a Float32Array
  84643. */
  84644. getFloatFrequencyData(): Float32Array;
  84645. /**
  84646. * Renders the debug canvas
  84647. */
  84648. drawDebugCanvas(): void;
  84649. /**
  84650. * Stops rendering the debug canvas and removes it
  84651. */
  84652. stopDebugCanvas(): void;
  84653. /**
  84654. * Connects two audio nodes
  84655. * @param inputAudioNode defines first node to connect
  84656. * @param outputAudioNode defines second node to connect
  84657. */
  84658. connectAudioNodes(inputAudioNode: AudioNode, outputAudioNode: AudioNode): void;
  84659. /**
  84660. * Releases all associated resources
  84661. */
  84662. dispose(): void;
  84663. }
  84664. }
  84665. declare module BABYLON {
  84666. /**
  84667. * This represents an audio engine and it is responsible
  84668. * to play, synchronize and analyse sounds throughout the application.
  84669. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  84670. */
  84671. export interface IAudioEngine extends IDisposable {
  84672. /**
  84673. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  84674. */
  84675. readonly canUseWebAudio: boolean;
  84676. /**
  84677. * Gets the current AudioContext if available.
  84678. */
  84679. readonly audioContext: Nullable<AudioContext>;
  84680. /**
  84681. * The master gain node defines the global audio volume of your audio engine.
  84682. */
  84683. readonly masterGain: GainNode;
  84684. /**
  84685. * Gets whether or not mp3 are supported by your browser.
  84686. */
  84687. readonly isMP3supported: boolean;
  84688. /**
  84689. * Gets whether or not ogg are supported by your browser.
  84690. */
  84691. readonly isOGGsupported: boolean;
  84692. /**
  84693. * Defines if Babylon should emit a warning if WebAudio is not supported.
  84694. * @ignoreNaming
  84695. */
  84696. WarnedWebAudioUnsupported: boolean;
  84697. /**
  84698. * Defines if the audio engine relies on a custom unlocked button.
  84699. * In this case, the embedded button will not be displayed.
  84700. */
  84701. useCustomUnlockedButton: boolean;
  84702. /**
  84703. * Gets whether or not the audio engine is unlocked (require first a user gesture on some browser).
  84704. */
  84705. readonly unlocked: boolean;
  84706. /**
  84707. * Event raised when audio has been unlocked on the browser.
  84708. */
  84709. onAudioUnlockedObservable: Observable<AudioEngine>;
  84710. /**
  84711. * Event raised when audio has been locked on the browser.
  84712. */
  84713. onAudioLockedObservable: Observable<AudioEngine>;
  84714. /**
  84715. * Flags the audio engine in Locked state.
  84716. * This happens due to new browser policies preventing audio to autoplay.
  84717. */
  84718. lock(): void;
  84719. /**
  84720. * Unlocks the audio engine once a user action has been done on the dom.
  84721. * This is helpful to resume play once browser policies have been satisfied.
  84722. */
  84723. unlock(): void;
  84724. }
  84725. /**
  84726. * This represents the default audio engine used in babylon.
  84727. * It is responsible to play, synchronize and analyse sounds throughout the application.
  84728. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  84729. */
  84730. export class AudioEngine implements IAudioEngine {
  84731. private _audioContext;
  84732. private _audioContextInitialized;
  84733. private _muteButton;
  84734. private _hostElement;
  84735. /**
  84736. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  84737. */
  84738. canUseWebAudio: boolean;
  84739. /**
  84740. * The master gain node defines the global audio volume of your audio engine.
  84741. */
  84742. masterGain: GainNode;
  84743. /**
  84744. * Defines if Babylon should emit a warning if WebAudio is not supported.
  84745. * @ignoreNaming
  84746. */
  84747. WarnedWebAudioUnsupported: boolean;
  84748. /**
  84749. * Gets whether or not mp3 are supported by your browser.
  84750. */
  84751. isMP3supported: boolean;
  84752. /**
  84753. * Gets whether or not ogg are supported by your browser.
  84754. */
  84755. isOGGsupported: boolean;
  84756. /**
  84757. * Gets whether audio has been unlocked on the device.
  84758. * Some Browsers have strong restrictions about Audio and won t autoplay unless
  84759. * a user interaction has happened.
  84760. */
  84761. unlocked: boolean;
  84762. /**
  84763. * Defines if the audio engine relies on a custom unlocked button.
  84764. * In this case, the embedded button will not be displayed.
  84765. */
  84766. useCustomUnlockedButton: boolean;
  84767. /**
  84768. * Event raised when audio has been unlocked on the browser.
  84769. */
  84770. onAudioUnlockedObservable: Observable<AudioEngine>;
  84771. /**
  84772. * Event raised when audio has been locked on the browser.
  84773. */
  84774. onAudioLockedObservable: Observable<AudioEngine>;
  84775. /**
  84776. * Gets the current AudioContext if available.
  84777. */
  84778. readonly audioContext: Nullable<AudioContext>;
  84779. private _connectedAnalyser;
  84780. /**
  84781. * Instantiates a new audio engine.
  84782. *
  84783. * There should be only one per page as some browsers restrict the number
  84784. * of audio contexts you can create.
  84785. * @param hostElement defines the host element where to display the mute icon if necessary
  84786. */
  84787. constructor(hostElement?: Nullable<HTMLElement>);
  84788. /**
  84789. * Flags the audio engine in Locked state.
  84790. * This happens due to new browser policies preventing audio to autoplay.
  84791. */
  84792. lock(): void;
  84793. /**
  84794. * Unlocks the audio engine once a user action has been done on the dom.
  84795. * This is helpful to resume play once browser policies have been satisfied.
  84796. */
  84797. unlock(): void;
  84798. private _resumeAudioContext;
  84799. private _initializeAudioContext;
  84800. private _tryToRun;
  84801. private _triggerRunningState;
  84802. private _triggerSuspendedState;
  84803. private _displayMuteButton;
  84804. private _moveButtonToTopLeft;
  84805. private _onResize;
  84806. private _hideMuteButton;
  84807. /**
  84808. * Destroy and release the resources associated with the audio ccontext.
  84809. */
  84810. dispose(): void;
  84811. /**
  84812. * Gets the global volume sets on the master gain.
  84813. * @returns the global volume if set or -1 otherwise
  84814. */
  84815. getGlobalVolume(): number;
  84816. /**
  84817. * Sets the global volume of your experience (sets on the master gain).
  84818. * @param newVolume Defines the new global volume of the application
  84819. */
  84820. setGlobalVolume(newVolume: number): void;
  84821. /**
  84822. * Connect the audio engine to an audio analyser allowing some amazing
  84823. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  84824. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  84825. * @param analyser The analyser to connect to the engine
  84826. */
  84827. connectToAnalyser(analyser: Analyser): void;
  84828. }
  84829. }
  84830. declare module BABYLON {
  84831. /**
  84832. * Interface used to present a loading screen while loading a scene
  84833. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  84834. */
  84835. export interface ILoadingScreen {
  84836. /**
  84837. * Function called to display the loading screen
  84838. */
  84839. displayLoadingUI: () => void;
  84840. /**
  84841. * Function called to hide the loading screen
  84842. */
  84843. hideLoadingUI: () => void;
  84844. /**
  84845. * Gets or sets the color to use for the background
  84846. */
  84847. loadingUIBackgroundColor: string;
  84848. /**
  84849. * Gets or sets the text to display while loading
  84850. */
  84851. loadingUIText: string;
  84852. }
  84853. /**
  84854. * Class used for the default loading screen
  84855. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  84856. */
  84857. export class DefaultLoadingScreen implements ILoadingScreen {
  84858. private _renderingCanvas;
  84859. private _loadingText;
  84860. private _loadingDivBackgroundColor;
  84861. private _loadingDiv;
  84862. private _loadingTextDiv;
  84863. /**
  84864. * Creates a new default loading screen
  84865. * @param _renderingCanvas defines the canvas used to render the scene
  84866. * @param _loadingText defines the default text to display
  84867. * @param _loadingDivBackgroundColor defines the default background color
  84868. */
  84869. constructor(_renderingCanvas: HTMLCanvasElement, _loadingText?: string, _loadingDivBackgroundColor?: string);
  84870. /**
  84871. * Function called to display the loading screen
  84872. */
  84873. displayLoadingUI(): void;
  84874. /**
  84875. * Function called to hide the loading screen
  84876. */
  84877. hideLoadingUI(): void;
  84878. /**
  84879. * Gets or sets the text to display while loading
  84880. */
  84881. loadingUIText: string;
  84882. /**
  84883. * Gets or sets the color to use for the background
  84884. */
  84885. loadingUIBackgroundColor: string;
  84886. private _resizeLoadingUI;
  84887. }
  84888. }
  84889. declare module BABYLON {
  84890. /**
  84891. * Settings for finer control over video usage
  84892. */
  84893. export interface VideoTextureSettings {
  84894. /**
  84895. * Applies `autoplay` to video, if specified
  84896. */
  84897. autoPlay?: boolean;
  84898. /**
  84899. * Applies `loop` to video, if specified
  84900. */
  84901. loop?: boolean;
  84902. /**
  84903. * Automatically updates internal texture from video at every frame in the render loop
  84904. */
  84905. autoUpdateTexture: boolean;
  84906. /**
  84907. * Image src displayed during the video loading or until the user interacts with the video.
  84908. */
  84909. poster?: string;
  84910. }
  84911. /**
  84912. * If you want to display a video in your scene, this is the special texture for that.
  84913. * This special texture works similar to other textures, with the exception of a few parameters.
  84914. * @see https://doc.babylonjs.com/how_to/video_texture
  84915. */
  84916. export class VideoTexture extends Texture {
  84917. /**
  84918. * Tells whether textures will be updated automatically or user is required to call `updateTexture` manually
  84919. */
  84920. readonly autoUpdateTexture: boolean;
  84921. /**
  84922. * The video instance used by the texture internally
  84923. */
  84924. readonly video: HTMLVideoElement;
  84925. private _onUserActionRequestedObservable;
  84926. /**
  84927. * Event triggerd when a dom action is required by the user to play the video.
  84928. * This happens due to recent changes in browser policies preventing video to auto start.
  84929. */
  84930. readonly onUserActionRequestedObservable: Observable<Texture>;
  84931. private _generateMipMaps;
  84932. private _engine;
  84933. private _stillImageCaptured;
  84934. private _displayingPosterTexture;
  84935. private _settings;
  84936. private _createInternalTextureOnEvent;
  84937. /**
  84938. * Creates a video texture.
  84939. * If you want to display a video in your scene, this is the special texture for that.
  84940. * This special texture works similar to other textures, with the exception of a few parameters.
  84941. * @see https://doc.babylonjs.com/how_to/video_texture
  84942. * @param name optional name, will detect from video source, if not defined
  84943. * @param src can be used to provide an url, array of urls or an already setup HTML video element.
  84944. * @param scene is obviously the current scene.
  84945. * @param generateMipMaps can be used to turn on mipmaps (Can be expensive for videoTextures because they are often updated).
  84946. * @param invertY is false by default but can be used to invert video on Y axis
  84947. * @param samplingMode controls the sampling method and is set to TRILINEAR_SAMPLINGMODE by default
  84948. * @param settings allows finer control over video usage
  84949. */
  84950. constructor(name: Nullable<string>, src: string | string[] | HTMLVideoElement, scene: Nullable<Scene>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, settings?: VideoTextureSettings);
  84951. private _getName;
  84952. private _getVideo;
  84953. private _createInternalTexture;
  84954. private reset;
  84955. /**
  84956. * @hidden Internal method to initiate `update`.
  84957. */
  84958. _rebuild(): void;
  84959. /**
  84960. * Update Texture in the `auto` mode. Does not do anything if `settings.autoUpdateTexture` is false.
  84961. */
  84962. update(): void;
  84963. /**
  84964. * Update Texture in `manual` mode. Does not do anything if not visible or paused.
  84965. * @param isVisible Visibility state, detected by user using `scene.getActiveMeshes()` or othervise.
  84966. */
  84967. updateTexture(isVisible: boolean): void;
  84968. protected _updateInternalTexture: () => void;
  84969. /**
  84970. * Change video content. Changing video instance or setting multiple urls (as in constructor) is not supported.
  84971. * @param url New url.
  84972. */
  84973. updateURL(url: string): void;
  84974. /**
  84975. * Dispose the texture and release its associated resources.
  84976. */
  84977. dispose(): void;
  84978. /**
  84979. * Creates a video texture straight from a stream.
  84980. * @param scene Define the scene the texture should be created in
  84981. * @param stream Define the stream the texture should be created from
  84982. * @returns The created video texture as a promise
  84983. */
  84984. static CreateFromStreamAsync(scene: Scene, stream: MediaStream): Promise<VideoTexture>;
  84985. /**
  84986. * Creates a video texture straight from your WebCam video feed.
  84987. * @param scene Define the scene the texture should be created in
  84988. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  84989. * @param audioConstaints Define the audio constraints to use to create the web cam feed from WebRTC
  84990. * @returns The created video texture as a promise
  84991. */
  84992. static CreateFromWebCamAsync(scene: Scene, constraints: {
  84993. minWidth: number;
  84994. maxWidth: number;
  84995. minHeight: number;
  84996. maxHeight: number;
  84997. deviceId: string;
  84998. } & MediaTrackConstraints, audioConstaints?: boolean | MediaTrackConstraints): Promise<VideoTexture>;
  84999. /**
  85000. * Creates a video texture straight from your WebCam video feed.
  85001. * @param scene Define the scene the texture should be created in
  85002. * @param onReady Define a callback to triggered once the texture will be ready
  85003. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  85004. * @param audioConstaints Define the audio constraints to use to create the web cam feed from WebRTC
  85005. */
  85006. static CreateFromWebCam(scene: Scene, onReady: (videoTexture: VideoTexture) => void, constraints: {
  85007. minWidth: number;
  85008. maxWidth: number;
  85009. minHeight: number;
  85010. maxHeight: number;
  85011. deviceId: string;
  85012. } & MediaTrackConstraints, audioConstaints?: boolean | MediaTrackConstraints): void;
  85013. }
  85014. }
  85015. declare module BABYLON {
  85016. /**
  85017. * Interface for attribute information associated with buffer instanciation
  85018. */
  85019. export class InstancingAttributeInfo {
  85020. /**
  85021. * Index/offset of the attribute in the vertex shader
  85022. */
  85023. index: number;
  85024. /**
  85025. * size of the attribute, 1, 2, 3 or 4
  85026. */
  85027. attributeSize: number;
  85028. /**
  85029. * type of the attribute, gl.BYTE, gl.UNSIGNED_BYTE, gl.SHORT, gl.UNSIGNED_SHORT, gl.FIXED, gl.FLOAT.
  85030. * default is FLOAT
  85031. */
  85032. attribyteType: number;
  85033. /**
  85034. * normalization of fixed-point data. behavior unclear, use FALSE, default is FALSE
  85035. */
  85036. normalized: boolean;
  85037. /**
  85038. * Offset of the data in the Vertex Buffer acting as the instancing buffer
  85039. */
  85040. offset: number;
  85041. /**
  85042. * Name of the GLSL attribute, for debugging purpose only
  85043. */
  85044. attributeName: string;
  85045. }
  85046. /**
  85047. * Define options used to create a depth texture
  85048. */
  85049. export class DepthTextureCreationOptions {
  85050. /** Specifies whether or not a stencil should be allocated in the texture */
  85051. generateStencil?: boolean;
  85052. /** Specifies whether or not bilinear filtering is enable on the texture */
  85053. bilinearFiltering?: boolean;
  85054. /** Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode */
  85055. comparisonFunction?: number;
  85056. /** Specifies if the created texture is a cube texture */
  85057. isCube?: boolean;
  85058. }
  85059. /**
  85060. * Class used to describe the capabilities of the engine relatively to the current browser
  85061. */
  85062. export class EngineCapabilities {
  85063. /** Maximum textures units per fragment shader */
  85064. maxTexturesImageUnits: number;
  85065. /** Maximum texture units per vertex shader */
  85066. maxVertexTextureImageUnits: number;
  85067. /** Maximum textures units in the entire pipeline */
  85068. maxCombinedTexturesImageUnits: number;
  85069. /** Maximum texture size */
  85070. maxTextureSize: number;
  85071. /** Maximum cube texture size */
  85072. maxCubemapTextureSize: number;
  85073. /** Maximum render texture size */
  85074. maxRenderTextureSize: number;
  85075. /** Maximum number of vertex attributes */
  85076. maxVertexAttribs: number;
  85077. /** Maximum number of varyings */
  85078. maxVaryingVectors: number;
  85079. /** Maximum number of uniforms per vertex shader */
  85080. maxVertexUniformVectors: number;
  85081. /** Maximum number of uniforms per fragment shader */
  85082. maxFragmentUniformVectors: number;
  85083. /** Defines if standard derivates (dx/dy) are supported */
  85084. standardDerivatives: boolean;
  85085. /** Defines if s3tc texture compression is supported */
  85086. s3tc: Nullable<WEBGL_compressed_texture_s3tc>;
  85087. /** Defines if pvrtc texture compression is supported */
  85088. pvrtc: any;
  85089. /** Defines if etc1 texture compression is supported */
  85090. etc1: any;
  85091. /** Defines if etc2 texture compression is supported */
  85092. etc2: any;
  85093. /** Defines if astc texture compression is supported */
  85094. astc: any;
  85095. /** Defines if float textures are supported */
  85096. textureFloat: boolean;
  85097. /** Defines if vertex array objects are supported */
  85098. vertexArrayObject: boolean;
  85099. /** Gets the webgl extension for anisotropic filtering (null if not supported) */
  85100. textureAnisotropicFilterExtension: Nullable<EXT_texture_filter_anisotropic>;
  85101. /** Gets the maximum level of anisotropy supported */
  85102. maxAnisotropy: number;
  85103. /** Defines if instancing is supported */
  85104. instancedArrays: boolean;
  85105. /** Defines if 32 bits indices are supported */
  85106. uintIndices: boolean;
  85107. /** Defines if high precision shaders are supported */
  85108. highPrecisionShaderSupported: boolean;
  85109. /** Defines if depth reading in the fragment shader is supported */
  85110. fragmentDepthSupported: boolean;
  85111. /** Defines if float texture linear filtering is supported*/
  85112. textureFloatLinearFiltering: boolean;
  85113. /** Defines if rendering to float textures is supported */
  85114. textureFloatRender: boolean;
  85115. /** Defines if half float textures are supported*/
  85116. textureHalfFloat: boolean;
  85117. /** Defines if half float texture linear filtering is supported*/
  85118. textureHalfFloatLinearFiltering: boolean;
  85119. /** Defines if rendering to half float textures is supported */
  85120. textureHalfFloatRender: boolean;
  85121. /** Defines if textureLOD shader command is supported */
  85122. textureLOD: boolean;
  85123. /** Defines if draw buffers extension is supported */
  85124. drawBuffersExtension: boolean;
  85125. /** Defines if depth textures are supported */
  85126. depthTextureExtension: boolean;
  85127. /** Defines if float color buffer are supported */
  85128. colorBufferFloat: boolean;
  85129. /** Gets disjoint timer query extension (null if not supported) */
  85130. timerQuery: EXT_disjoint_timer_query;
  85131. /** Defines if timestamp can be used with timer query */
  85132. canUseTimestampForTimerQuery: boolean;
  85133. /** Function used to let the system compiles shaders in background */
  85134. parallelShaderCompile: {
  85135. COMPLETION_STATUS_KHR: number;
  85136. };
  85137. }
  85138. /** Interface defining initialization parameters for Engine class */
  85139. export interface EngineOptions extends WebGLContextAttributes {
  85140. /**
  85141. * Defines if the engine should no exceed a specified device ratio
  85142. * @see https://developer.mozilla.org/en-US/docs/Web/API/Window/devicePixelRatio
  85143. */
  85144. limitDeviceRatio?: number;
  85145. /**
  85146. * Defines if webvr should be enabled automatically
  85147. * @see http://doc.babylonjs.com/how_to/webvr_camera
  85148. */
  85149. autoEnableWebVR?: boolean;
  85150. /**
  85151. * Defines if webgl2 should be turned off even if supported
  85152. * @see http://doc.babylonjs.com/features/webgl2
  85153. */
  85154. disableWebGL2Support?: boolean;
  85155. /**
  85156. * Defines if webaudio should be initialized as well
  85157. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  85158. */
  85159. audioEngine?: boolean;
  85160. /**
  85161. * Defines if animations should run using a deterministic lock step
  85162. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  85163. */
  85164. deterministicLockstep?: boolean;
  85165. /** Defines the maximum steps to use with deterministic lock step mode */
  85166. lockstepMaxSteps?: number;
  85167. /**
  85168. * Defines that engine should ignore context lost events
  85169. * If this event happens when this parameter is true, you will have to reload the page to restore rendering
  85170. */
  85171. doNotHandleContextLost?: boolean;
  85172. /**
  85173. * Defines that engine should ignore modifying touch action attribute and style
  85174. * If not handle, you might need to set it up on your side for expected touch devices behavior.
  85175. */
  85176. doNotHandleTouchAction?: boolean;
  85177. /**
  85178. * Defines that engine should compile shaders with high precision floats (if supported). True by default
  85179. */
  85180. useHighPrecisionFloats?: boolean;
  85181. }
  85182. /**
  85183. * Defines the interface used by display changed events
  85184. */
  85185. export interface IDisplayChangedEventArgs {
  85186. /** Gets the vrDisplay object (if any) */
  85187. vrDisplay: Nullable<any>;
  85188. /** Gets a boolean indicating if webVR is supported */
  85189. vrSupported: boolean;
  85190. }
  85191. /**
  85192. * The engine class is responsible for interfacing with all lower-level APIs such as WebGL and Audio
  85193. */
  85194. export class Engine {
  85195. /** Use this array to turn off some WebGL2 features on known buggy browsers version */
  85196. static ExceptionList: ({
  85197. key: string;
  85198. capture: string;
  85199. captureConstraint: number;
  85200. targets: string[];
  85201. } | {
  85202. key: string;
  85203. capture: null;
  85204. captureConstraint: null;
  85205. targets: string[];
  85206. })[];
  85207. /** Gets the list of created engines */
  85208. static readonly Instances: Engine[];
  85209. /**
  85210. * Gets the latest created engine
  85211. */
  85212. static readonly LastCreatedEngine: Nullable<Engine>;
  85213. /**
  85214. * Gets the latest created scene
  85215. */
  85216. static readonly LastCreatedScene: Nullable<Scene>;
  85217. /**
  85218. * Will flag all materials in all scenes in all engines as dirty to trigger new shader compilation
  85219. * @param flag defines which part of the materials must be marked as dirty
  85220. * @param predicate defines a predicate used to filter which materials should be affected
  85221. */
  85222. static MarkAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  85223. /**
  85224. * Hidden
  85225. */
  85226. static _TextureLoaders: IInternalTextureLoader[];
  85227. /** Defines that alpha blending is disabled */
  85228. static readonly ALPHA_DISABLE: number;
  85229. /** Defines that alpha blending to SRC ALPHA * SRC + DEST */
  85230. static readonly ALPHA_ADD: number;
  85231. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC ALPHA) * DEST */
  85232. static readonly ALPHA_COMBINE: number;
  85233. /** Defines that alpha blending to DEST - SRC * DEST */
  85234. static readonly ALPHA_SUBTRACT: number;
  85235. /** Defines that alpha blending to SRC * DEST */
  85236. static readonly ALPHA_MULTIPLY: number;
  85237. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC) * DEST */
  85238. static readonly ALPHA_MAXIMIZED: number;
  85239. /** Defines that alpha blending to SRC + DEST */
  85240. static readonly ALPHA_ONEONE: number;
  85241. /** Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST */
  85242. static readonly ALPHA_PREMULTIPLIED: number;
  85243. /**
  85244. * Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST
  85245. * Alpha will be set to (1 - SRC ALPHA) * DEST ALPHA
  85246. */
  85247. static readonly ALPHA_PREMULTIPLIED_PORTERDUFF: number;
  85248. /** Defines that alpha blending to CST * SRC + (1 - CST) * DEST */
  85249. static readonly ALPHA_INTERPOLATE: number;
  85250. /**
  85251. * Defines that alpha blending to SRC + (1 - SRC) * DEST
  85252. * Alpha will be set to SRC ALPHA + (1 - SRC ALPHA) * DEST ALPHA
  85253. */
  85254. static readonly ALPHA_SCREENMODE: number;
  85255. /** Defines that the ressource is not delayed*/
  85256. static readonly DELAYLOADSTATE_NONE: number;
  85257. /** Defines that the ressource was successfully delay loaded */
  85258. static readonly DELAYLOADSTATE_LOADED: number;
  85259. /** Defines that the ressource is currently delay loading */
  85260. static readonly DELAYLOADSTATE_LOADING: number;
  85261. /** Defines that the ressource is delayed and has not started loading */
  85262. static readonly DELAYLOADSTATE_NOTLOADED: number;
  85263. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will never pass. i.e. Nothing will be drawn */
  85264. static readonly NEVER: number;
  85265. /** 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 */
  85266. static readonly ALWAYS: number;
  85267. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than the stored value */
  85268. static readonly LESS: number;
  85269. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is equals to the stored value */
  85270. static readonly EQUAL: number;
  85271. /** 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 */
  85272. static readonly LEQUAL: number;
  85273. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than the stored value */
  85274. static readonly GREATER: number;
  85275. /** 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 */
  85276. static readonly GEQUAL: number;
  85277. /** 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 */
  85278. static readonly NOTEQUAL: number;
  85279. /** Passed to stencilOperation to specify that stencil value must be kept */
  85280. static readonly KEEP: number;
  85281. /** Passed to stencilOperation to specify that stencil value must be replaced */
  85282. static readonly REPLACE: number;
  85283. /** Passed to stencilOperation to specify that stencil value must be incremented */
  85284. static readonly INCR: number;
  85285. /** Passed to stencilOperation to specify that stencil value must be decremented */
  85286. static readonly DECR: number;
  85287. /** Passed to stencilOperation to specify that stencil value must be inverted */
  85288. static readonly INVERT: number;
  85289. /** Passed to stencilOperation to specify that stencil value must be incremented with wrapping */
  85290. static readonly INCR_WRAP: number;
  85291. /** Passed to stencilOperation to specify that stencil value must be decremented with wrapping */
  85292. static readonly DECR_WRAP: number;
  85293. /** Texture is not repeating outside of 0..1 UVs */
  85294. static readonly TEXTURE_CLAMP_ADDRESSMODE: number;
  85295. /** Texture is repeating outside of 0..1 UVs */
  85296. static readonly TEXTURE_WRAP_ADDRESSMODE: number;
  85297. /** Texture is repeating and mirrored */
  85298. static readonly TEXTURE_MIRROR_ADDRESSMODE: number;
  85299. /** ALPHA */
  85300. static readonly TEXTUREFORMAT_ALPHA: number;
  85301. /** LUMINANCE */
  85302. static readonly TEXTUREFORMAT_LUMINANCE: number;
  85303. /** LUMINANCE_ALPHA */
  85304. static readonly TEXTUREFORMAT_LUMINANCE_ALPHA: number;
  85305. /** RGB */
  85306. static readonly TEXTUREFORMAT_RGB: number;
  85307. /** RGBA */
  85308. static readonly TEXTUREFORMAT_RGBA: number;
  85309. /** RED */
  85310. static readonly TEXTUREFORMAT_RED: number;
  85311. /** RED (2nd reference) */
  85312. static readonly TEXTUREFORMAT_R: number;
  85313. /** RG */
  85314. static readonly TEXTUREFORMAT_RG: number;
  85315. /** RED_INTEGER */
  85316. static readonly TEXTUREFORMAT_RED_INTEGER: number;
  85317. /** RED_INTEGER (2nd reference) */
  85318. static readonly TEXTUREFORMAT_R_INTEGER: number;
  85319. /** RG_INTEGER */
  85320. static readonly TEXTUREFORMAT_RG_INTEGER: number;
  85321. /** RGB_INTEGER */
  85322. static readonly TEXTUREFORMAT_RGB_INTEGER: number;
  85323. /** RGBA_INTEGER */
  85324. static readonly TEXTUREFORMAT_RGBA_INTEGER: number;
  85325. /** UNSIGNED_BYTE */
  85326. static readonly TEXTURETYPE_UNSIGNED_BYTE: number;
  85327. /** UNSIGNED_BYTE (2nd reference) */
  85328. static readonly TEXTURETYPE_UNSIGNED_INT: number;
  85329. /** FLOAT */
  85330. static readonly TEXTURETYPE_FLOAT: number;
  85331. /** HALF_FLOAT */
  85332. static readonly TEXTURETYPE_HALF_FLOAT: number;
  85333. /** BYTE */
  85334. static readonly TEXTURETYPE_BYTE: number;
  85335. /** SHORT */
  85336. static readonly TEXTURETYPE_SHORT: number;
  85337. /** UNSIGNED_SHORT */
  85338. static readonly TEXTURETYPE_UNSIGNED_SHORT: number;
  85339. /** INT */
  85340. static readonly TEXTURETYPE_INT: number;
  85341. /** UNSIGNED_INT */
  85342. static readonly TEXTURETYPE_UNSIGNED_INTEGER: number;
  85343. /** UNSIGNED_SHORT_4_4_4_4 */
  85344. static readonly TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4: number;
  85345. /** UNSIGNED_SHORT_5_5_5_1 */
  85346. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1: number;
  85347. /** UNSIGNED_SHORT_5_6_5 */
  85348. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_6_5: number;
  85349. /** UNSIGNED_INT_2_10_10_10_REV */
  85350. static readonly TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV: number;
  85351. /** UNSIGNED_INT_24_8 */
  85352. static readonly TEXTURETYPE_UNSIGNED_INT_24_8: number;
  85353. /** UNSIGNED_INT_10F_11F_11F_REV */
  85354. static readonly TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV: number;
  85355. /** UNSIGNED_INT_5_9_9_9_REV */
  85356. static readonly TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV: number;
  85357. /** FLOAT_32_UNSIGNED_INT_24_8_REV */
  85358. static readonly TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  85359. /** nearest is mag = nearest and min = nearest and mip = linear */
  85360. static readonly TEXTURE_NEAREST_SAMPLINGMODE: number;
  85361. /** Bilinear is mag = linear and min = linear and mip = nearest */
  85362. static readonly TEXTURE_BILINEAR_SAMPLINGMODE: number;
  85363. /** Trilinear is mag = linear and min = linear and mip = linear */
  85364. static readonly TEXTURE_TRILINEAR_SAMPLINGMODE: number;
  85365. /** nearest is mag = nearest and min = nearest and mip = linear */
  85366. static readonly TEXTURE_NEAREST_NEAREST_MIPLINEAR: number;
  85367. /** Bilinear is mag = linear and min = linear and mip = nearest */
  85368. static readonly TEXTURE_LINEAR_LINEAR_MIPNEAREST: number;
  85369. /** Trilinear is mag = linear and min = linear and mip = linear */
  85370. static readonly TEXTURE_LINEAR_LINEAR_MIPLINEAR: number;
  85371. /** mag = nearest and min = nearest and mip = nearest */
  85372. static readonly TEXTURE_NEAREST_NEAREST_MIPNEAREST: number;
  85373. /** mag = nearest and min = linear and mip = nearest */
  85374. static readonly TEXTURE_NEAREST_LINEAR_MIPNEAREST: number;
  85375. /** mag = nearest and min = linear and mip = linear */
  85376. static readonly TEXTURE_NEAREST_LINEAR_MIPLINEAR: number;
  85377. /** mag = nearest and min = linear and mip = none */
  85378. static readonly TEXTURE_NEAREST_LINEAR: number;
  85379. /** mag = nearest and min = nearest and mip = none */
  85380. static readonly TEXTURE_NEAREST_NEAREST: number;
  85381. /** mag = linear and min = nearest and mip = nearest */
  85382. static readonly TEXTURE_LINEAR_NEAREST_MIPNEAREST: number;
  85383. /** mag = linear and min = nearest and mip = linear */
  85384. static readonly TEXTURE_LINEAR_NEAREST_MIPLINEAR: number;
  85385. /** mag = linear and min = linear and mip = none */
  85386. static readonly TEXTURE_LINEAR_LINEAR: number;
  85387. /** mag = linear and min = nearest and mip = none */
  85388. static readonly TEXTURE_LINEAR_NEAREST: number;
  85389. /** Explicit coordinates mode */
  85390. static readonly TEXTURE_EXPLICIT_MODE: number;
  85391. /** Spherical coordinates mode */
  85392. static readonly TEXTURE_SPHERICAL_MODE: number;
  85393. /** Planar coordinates mode */
  85394. static readonly TEXTURE_PLANAR_MODE: number;
  85395. /** Cubic coordinates mode */
  85396. static readonly TEXTURE_CUBIC_MODE: number;
  85397. /** Projection coordinates mode */
  85398. static readonly TEXTURE_PROJECTION_MODE: number;
  85399. /** Skybox coordinates mode */
  85400. static readonly TEXTURE_SKYBOX_MODE: number;
  85401. /** Inverse Cubic coordinates mode */
  85402. static readonly TEXTURE_INVCUBIC_MODE: number;
  85403. /** Equirectangular coordinates mode */
  85404. static readonly TEXTURE_EQUIRECTANGULAR_MODE: number;
  85405. /** Equirectangular Fixed coordinates mode */
  85406. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MODE: number;
  85407. /** Equirectangular Fixed Mirrored coordinates mode */
  85408. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  85409. /** Defines that texture rescaling will use a floor to find the closer power of 2 size */
  85410. static readonly SCALEMODE_FLOOR: number;
  85411. /** Defines that texture rescaling will look for the nearest power of 2 size */
  85412. static readonly SCALEMODE_NEAREST: number;
  85413. /** Defines that texture rescaling will use a ceil to find the closer power of 2 size */
  85414. static readonly SCALEMODE_CEILING: number;
  85415. /**
  85416. * Returns the current npm package of the sdk
  85417. */
  85418. static readonly NpmPackage: string;
  85419. /**
  85420. * Returns the current version of the framework
  85421. */
  85422. static readonly Version: string;
  85423. /**
  85424. * Returns a string describing the current engine
  85425. */
  85426. readonly description: string;
  85427. /**
  85428. * Gets or sets the epsilon value used by collision engine
  85429. */
  85430. static CollisionsEpsilon: number;
  85431. /**
  85432. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  85433. */
  85434. static ShadersRepository: string;
  85435. /**
  85436. * Method called to create the default loading screen.
  85437. * This can be overriden in your own app.
  85438. * @param canvas The rendering canvas element
  85439. * @returns The loading screen
  85440. */
  85441. static DefaultLoadingScreenFactory(canvas: HTMLCanvasElement): ILoadingScreen;
  85442. /**
  85443. * Method called to create the default rescale post process on each engine.
  85444. */
  85445. static _RescalePostProcessFactory: Nullable<(engine: Engine) => PostProcess>;
  85446. /**
  85447. * Gets or sets a boolean that indicates if textures must be forced to power of 2 size even if not required
  85448. */
  85449. forcePOTTextures: boolean;
  85450. /**
  85451. * Gets a boolean indicating if the engine is currently rendering in fullscreen mode
  85452. */
  85453. isFullscreen: boolean;
  85454. /**
  85455. * Gets a boolean indicating if the pointer is currently locked
  85456. */
  85457. isPointerLock: boolean;
  85458. /**
  85459. * Gets or sets a boolean indicating if back faces must be culled (true by default)
  85460. */
  85461. cullBackFaces: boolean;
  85462. /**
  85463. * Gets or sets a boolean indicating if the engine must keep rendering even if the window is not in foregroun
  85464. */
  85465. renderEvenInBackground: boolean;
  85466. /**
  85467. * Gets or sets a boolean indicating that cache can be kept between frames
  85468. */
  85469. preventCacheWipeBetweenFrames: boolean;
  85470. /**
  85471. * Gets or sets a boolean to enable/disable IndexedDB support and avoid XHR on .manifest
  85472. **/
  85473. enableOfflineSupport: boolean;
  85474. /**
  85475. * 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)
  85476. **/
  85477. disableManifestCheck: boolean;
  85478. /**
  85479. * Gets the list of created scenes
  85480. */
  85481. scenes: Scene[];
  85482. /**
  85483. * Event raised when a new scene is created
  85484. */
  85485. onNewSceneAddedObservable: Observable<Scene>;
  85486. /**
  85487. * Gets the list of created postprocesses
  85488. */
  85489. postProcesses: PostProcess[];
  85490. /** Gets or sets a boolean indicating if the engine should validate programs after compilation */
  85491. validateShaderPrograms: boolean;
  85492. /**
  85493. * Observable event triggered each time the rendering canvas is resized
  85494. */
  85495. onResizeObservable: Observable<Engine>;
  85496. /**
  85497. * Observable event triggered each time the canvas loses focus
  85498. */
  85499. onCanvasBlurObservable: Observable<Engine>;
  85500. /**
  85501. * Observable event triggered each time the canvas gains focus
  85502. */
  85503. onCanvasFocusObservable: Observable<Engine>;
  85504. /**
  85505. * Observable event triggered each time the canvas receives pointerout event
  85506. */
  85507. onCanvasPointerOutObservable: Observable<PointerEvent>;
  85508. /**
  85509. * Observable event triggered before each texture is initialized
  85510. */
  85511. onBeforeTextureInitObservable: Observable<Texture>;
  85512. private _vrDisplay;
  85513. private _vrSupported;
  85514. private _oldSize;
  85515. private _oldHardwareScaleFactor;
  85516. private _vrExclusivePointerMode;
  85517. private _webVRInitPromise;
  85518. /**
  85519. * Gets a boolean indicating that the engine is currently in VR exclusive mode for the pointers
  85520. * @see https://docs.microsoft.com/en-us/microsoft-edge/webvr/essentials#mouse-input
  85521. */
  85522. readonly isInVRExclusivePointerMode: boolean;
  85523. /**
  85524. * Gets or sets a boolean indicating that uniform buffers must be disabled even if they are supported
  85525. */
  85526. disableUniformBuffers: boolean;
  85527. /** @hidden */
  85528. _uniformBuffers: UniformBuffer[];
  85529. /**
  85530. * Gets a boolean indicating that the engine supports uniform buffers
  85531. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  85532. */
  85533. readonly supportsUniformBuffers: boolean;
  85534. /**
  85535. * Observable raised when the engine begins a new frame
  85536. */
  85537. onBeginFrameObservable: Observable<Engine>;
  85538. /**
  85539. * If set, will be used to request the next animation frame for the render loop
  85540. */
  85541. customAnimationFrameRequester: Nullable<ICustomAnimationFrameRequester>;
  85542. /**
  85543. * Observable raised when the engine ends the current frame
  85544. */
  85545. onEndFrameObservable: Observable<Engine>;
  85546. /**
  85547. * Observable raised when the engine is about to compile a shader
  85548. */
  85549. onBeforeShaderCompilationObservable: Observable<Engine>;
  85550. /**
  85551. * Observable raised when the engine has jsut compiled a shader
  85552. */
  85553. onAfterShaderCompilationObservable: Observable<Engine>;
  85554. /** @hidden */
  85555. _gl: WebGLRenderingContext;
  85556. private _renderingCanvas;
  85557. private _windowIsBackground;
  85558. private _webGLVersion;
  85559. protected _highPrecisionShadersAllowed: boolean;
  85560. /** @hidden */
  85561. readonly _shouldUseHighPrecisionShader: boolean;
  85562. /**
  85563. * Gets a boolean indicating that only power of 2 textures are supported
  85564. * Please note that you can still use non power of 2 textures but in this case the engine will forcefully convert them
  85565. */
  85566. readonly needPOTTextures: boolean;
  85567. /** @hidden */
  85568. _badOS: boolean;
  85569. /** @hidden */
  85570. _badDesktopOS: boolean;
  85571. /**
  85572. * Gets or sets a value indicating if we want to disable texture binding optimization.
  85573. * This could be required on some buggy drivers which wants to have textures bound in a progressive order.
  85574. * By default Babylon.js will try to let textures bound where they are and only update the samplers to point where the texture is
  85575. */
  85576. disableTextureBindingOptimization: boolean;
  85577. /**
  85578. * Gets the audio engine
  85579. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  85580. * @ignorenaming
  85581. */
  85582. static audioEngine: IAudioEngine;
  85583. /**
  85584. * Default AudioEngine factory responsible of creating the Audio Engine.
  85585. * By default, this will create a BabylonJS Audio Engine if the workload has been embedded.
  85586. */
  85587. static AudioEngineFactory: (hostElement: Nullable<HTMLElement>) => IAudioEngine;
  85588. /**
  85589. * Default offline support factory responsible of creating a tool used to store data locally.
  85590. * By default, this will create a Database object if the workload has been embedded.
  85591. */
  85592. static OfflineProviderFactory: (urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck: boolean) => IOfflineProvider;
  85593. private _onFocus;
  85594. private _onBlur;
  85595. private _onCanvasPointerOut;
  85596. private _onCanvasBlur;
  85597. private _onCanvasFocus;
  85598. private _onFullscreenChange;
  85599. private _onPointerLockChange;
  85600. private _onVRDisplayPointerRestricted;
  85601. private _onVRDisplayPointerUnrestricted;
  85602. private _onVrDisplayConnect;
  85603. private _onVrDisplayDisconnect;
  85604. private _onVrDisplayPresentChange;
  85605. /**
  85606. * Observable signaled when VR display mode changes
  85607. */
  85608. onVRDisplayChangedObservable: Observable<IDisplayChangedEventArgs>;
  85609. /**
  85610. * Observable signaled when VR request present is complete
  85611. */
  85612. onVRRequestPresentComplete: Observable<boolean>;
  85613. /**
  85614. * Observable signaled when VR request present starts
  85615. */
  85616. onVRRequestPresentStart: Observable<Engine>;
  85617. private _hardwareScalingLevel;
  85618. /** @hidden */
  85619. protected _caps: EngineCapabilities;
  85620. private _pointerLockRequested;
  85621. private _isStencilEnable;
  85622. private _colorWrite;
  85623. private _loadingScreen;
  85624. /** @hidden */
  85625. _drawCalls: PerfCounter;
  85626. /** @hidden */
  85627. _textureCollisions: PerfCounter;
  85628. private _glVersion;
  85629. private _glRenderer;
  85630. private _glVendor;
  85631. private _videoTextureSupported;
  85632. private _renderingQueueLaunched;
  85633. private _activeRenderLoops;
  85634. private _deterministicLockstep;
  85635. private _lockstepMaxSteps;
  85636. /**
  85637. * Observable signaled when a context lost event is raised
  85638. */
  85639. onContextLostObservable: Observable<Engine>;
  85640. /**
  85641. * Observable signaled when a context restored event is raised
  85642. */
  85643. onContextRestoredObservable: Observable<Engine>;
  85644. private _onContextLost;
  85645. private _onContextRestored;
  85646. private _contextWasLost;
  85647. private _doNotHandleContextLost;
  85648. /**
  85649. * Gets or sets a boolean indicating if resources should be retained to be able to handle context lost events
  85650. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#handling-webgl-context-lost
  85651. */
  85652. doNotHandleContextLost: boolean;
  85653. private _performanceMonitor;
  85654. private _fps;
  85655. private _deltaTime;
  85656. /**
  85657. * Turn this value on if you want to pause FPS computation when in background
  85658. */
  85659. disablePerformanceMonitorInBackground: boolean;
  85660. /**
  85661. * Gets the performance monitor attached to this engine
  85662. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  85663. */
  85664. readonly performanceMonitor: PerformanceMonitor;
  85665. /** @hidden */
  85666. protected _depthCullingState: _DepthCullingState;
  85667. /** @hidden */
  85668. protected _stencilState: _StencilState;
  85669. /** @hidden */
  85670. protected _alphaState: _AlphaState;
  85671. /** @hidden */
  85672. protected _alphaMode: number;
  85673. protected _internalTexturesCache: InternalTexture[];
  85674. /** @hidden */
  85675. protected _activeChannel: number;
  85676. private _currentTextureChannel;
  85677. /** @hidden */
  85678. protected _boundTexturesCache: {
  85679. [key: string]: Nullable<InternalTexture>;
  85680. };
  85681. /** @hidden */
  85682. protected _currentEffect: Nullable<Effect>;
  85683. /** @hidden */
  85684. protected _currentProgram: Nullable<WebGLProgram>;
  85685. private _compiledEffects;
  85686. private _vertexAttribArraysEnabled;
  85687. /** @hidden */
  85688. protected _cachedViewport: Nullable<Viewport>;
  85689. private _cachedVertexArrayObject;
  85690. /** @hidden */
  85691. protected _cachedVertexBuffers: any;
  85692. /** @hidden */
  85693. protected _cachedIndexBuffer: Nullable<WebGLBuffer>;
  85694. /** @hidden */
  85695. protected _cachedEffectForVertexBuffers: Nullable<Effect>;
  85696. /** @hidden */
  85697. protected _currentRenderTarget: Nullable<InternalTexture>;
  85698. private _uintIndicesCurrentlySet;
  85699. private _currentBoundBuffer;
  85700. /** @hidden */
  85701. protected _currentFramebuffer: Nullable<WebGLFramebuffer>;
  85702. private _currentBufferPointers;
  85703. private _currentInstanceLocations;
  85704. private _currentInstanceBuffers;
  85705. private _textureUnits;
  85706. private _firstBoundInternalTextureTracker;
  85707. private _lastBoundInternalTextureTracker;
  85708. private _workingCanvas;
  85709. private _workingContext;
  85710. private _rescalePostProcess;
  85711. private _dummyFramebuffer;
  85712. private _externalData;
  85713. private _bindedRenderFunction;
  85714. private _vaoRecordInProgress;
  85715. private _mustWipeVertexAttributes;
  85716. private _emptyTexture;
  85717. private _emptyCubeTexture;
  85718. private _emptyTexture3D;
  85719. /** @hidden */
  85720. _frameHandler: number;
  85721. private _nextFreeTextureSlots;
  85722. private _maxSimultaneousTextures;
  85723. private _activeRequests;
  85724. private _texturesSupported;
  85725. private _textureFormatInUse;
  85726. /**
  85727. * Gets the list of texture formats supported
  85728. */
  85729. readonly texturesSupported: Array<string>;
  85730. /**
  85731. * Gets the list of texture formats in use
  85732. */
  85733. readonly textureFormatInUse: Nullable<string>;
  85734. /**
  85735. * Gets the current viewport
  85736. */
  85737. readonly currentViewport: Nullable<Viewport>;
  85738. /**
  85739. * Gets the default empty texture
  85740. */
  85741. readonly emptyTexture: InternalTexture;
  85742. /**
  85743. * Gets the default empty 3D texture
  85744. */
  85745. readonly emptyTexture3D: InternalTexture;
  85746. /**
  85747. * Gets the default empty cube texture
  85748. */
  85749. readonly emptyCubeTexture: InternalTexture;
  85750. /**
  85751. * Defines whether the engine has been created with the premultipliedAlpha option on or not.
  85752. */
  85753. readonly premultipliedAlpha: boolean;
  85754. /**
  85755. * Creates a new engine
  85756. * @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
  85757. * @param antialias defines enable antialiasing (default: false)
  85758. * @param options defines further options to be sent to the getContext() function
  85759. * @param adaptToDeviceRatio defines whether to adapt to the device's viewport characteristics (default: false)
  85760. */
  85761. constructor(canvasOrContext: Nullable<HTMLCanvasElement | WebGLRenderingContext>, antialias?: boolean, options?: EngineOptions, adaptToDeviceRatio?: boolean);
  85762. private _disableTouchAction;
  85763. private _rebuildInternalTextures;
  85764. private _rebuildEffects;
  85765. /**
  85766. * Gets a boolean indicating if all created effects are ready
  85767. * @returns true if all effects are ready
  85768. */
  85769. areAllEffectsReady(): boolean;
  85770. private _rebuildBuffers;
  85771. private _initGLContext;
  85772. /**
  85773. * Gets version of the current webGL context
  85774. */
  85775. readonly webGLVersion: number;
  85776. /**
  85777. * Returns true if the stencil buffer has been enabled through the creation option of the context.
  85778. */
  85779. readonly isStencilEnable: boolean;
  85780. private _prepareWorkingCanvas;
  85781. /**
  85782. * Reset the texture cache to empty state
  85783. */
  85784. resetTextureCache(): void;
  85785. /**
  85786. * Gets a boolean indicating that the engine is running in deterministic lock step mode
  85787. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  85788. * @returns true if engine is in deterministic lock step mode
  85789. */
  85790. isDeterministicLockStep(): boolean;
  85791. /**
  85792. * Gets the max steps when engine is running in deterministic lock step
  85793. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  85794. * @returns the max steps
  85795. */
  85796. getLockstepMaxSteps(): number;
  85797. /**
  85798. * Gets an object containing information about the current webGL context
  85799. * @returns an object containing the vender, the renderer and the version of the current webGL context
  85800. */
  85801. getGlInfo(): {
  85802. vendor: string;
  85803. renderer: string;
  85804. version: string;
  85805. };
  85806. /**
  85807. * Gets current aspect ratio
  85808. * @param camera defines the camera to use to get the aspect ratio
  85809. * @param useScreen defines if screen size must be used (or the current render target if any)
  85810. * @returns a number defining the aspect ratio
  85811. */
  85812. getAspectRatio(camera: Camera, useScreen?: boolean): number;
  85813. /**
  85814. * Gets current screen aspect ratio
  85815. * @returns a number defining the aspect ratio
  85816. */
  85817. getScreenAspectRatio(): number;
  85818. /**
  85819. * Gets the current render width
  85820. * @param useScreen defines if screen size must be used (or the current render target if any)
  85821. * @returns a number defining the current render width
  85822. */
  85823. getRenderWidth(useScreen?: boolean): number;
  85824. /**
  85825. * Gets the current render height
  85826. * @param useScreen defines if screen size must be used (or the current render target if any)
  85827. * @returns a number defining the current render height
  85828. */
  85829. getRenderHeight(useScreen?: boolean): number;
  85830. /**
  85831. * Gets the HTML canvas attached with the current webGL context
  85832. * @returns a HTML canvas
  85833. */
  85834. getRenderingCanvas(): Nullable<HTMLCanvasElement>;
  85835. /**
  85836. * Gets the client rect of the HTML canvas attached with the current webGL context
  85837. * @returns a client rectanglee
  85838. */
  85839. getRenderingCanvasClientRect(): Nullable<ClientRect>;
  85840. /**
  85841. * Defines the hardware scaling level.
  85842. * By default the hardware scaling level is computed from the window device ratio.
  85843. * 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.
  85844. * @param level defines the level to use
  85845. */
  85846. setHardwareScalingLevel(level: number): void;
  85847. /**
  85848. * Gets the current hardware scaling level.
  85849. * By default the hardware scaling level is computed from the window device ratio.
  85850. * 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.
  85851. * @returns a number indicating the current hardware scaling level
  85852. */
  85853. getHardwareScalingLevel(): number;
  85854. /**
  85855. * Gets the list of loaded textures
  85856. * @returns an array containing all loaded textures
  85857. */
  85858. getLoadedTexturesCache(): InternalTexture[];
  85859. /**
  85860. * Gets the object containing all engine capabilities
  85861. * @returns the EngineCapabilities object
  85862. */
  85863. getCaps(): EngineCapabilities;
  85864. /**
  85865. * Gets the current depth function
  85866. * @returns a number defining the depth function
  85867. */
  85868. getDepthFunction(): Nullable<number>;
  85869. /**
  85870. * Sets the current depth function
  85871. * @param depthFunc defines the function to use
  85872. */
  85873. setDepthFunction(depthFunc: number): void;
  85874. /**
  85875. * Sets the current depth function to GREATER
  85876. */
  85877. setDepthFunctionToGreater(): void;
  85878. /**
  85879. * Sets the current depth function to GEQUAL
  85880. */
  85881. setDepthFunctionToGreaterOrEqual(): void;
  85882. /**
  85883. * Sets the current depth function to LESS
  85884. */
  85885. setDepthFunctionToLess(): void;
  85886. private _cachedStencilBuffer;
  85887. private _cachedStencilFunction;
  85888. private _cachedStencilMask;
  85889. private _cachedStencilOperationPass;
  85890. private _cachedStencilOperationFail;
  85891. private _cachedStencilOperationDepthFail;
  85892. private _cachedStencilReference;
  85893. /**
  85894. * Caches the the state of the stencil buffer
  85895. */
  85896. cacheStencilState(): void;
  85897. /**
  85898. * Restores the state of the stencil buffer
  85899. */
  85900. restoreStencilState(): void;
  85901. /**
  85902. * Sets the current depth function to LEQUAL
  85903. */
  85904. setDepthFunctionToLessOrEqual(): void;
  85905. /**
  85906. * Gets a boolean indicating if stencil buffer is enabled
  85907. * @returns the current stencil buffer state
  85908. */
  85909. getStencilBuffer(): boolean;
  85910. /**
  85911. * Enable or disable the stencil buffer
  85912. * @param enable defines if the stencil buffer must be enabled or disabled
  85913. */
  85914. setStencilBuffer(enable: boolean): void;
  85915. /**
  85916. * Gets the current stencil mask
  85917. * @returns a number defining the new stencil mask to use
  85918. */
  85919. getStencilMask(): number;
  85920. /**
  85921. * Sets the current stencil mask
  85922. * @param mask defines the new stencil mask to use
  85923. */
  85924. setStencilMask(mask: number): void;
  85925. /**
  85926. * Gets the current stencil function
  85927. * @returns a number defining the stencil function to use
  85928. */
  85929. getStencilFunction(): number;
  85930. /**
  85931. * Gets the current stencil reference value
  85932. * @returns a number defining the stencil reference value to use
  85933. */
  85934. getStencilFunctionReference(): number;
  85935. /**
  85936. * Gets the current stencil mask
  85937. * @returns a number defining the stencil mask to use
  85938. */
  85939. getStencilFunctionMask(): number;
  85940. /**
  85941. * Sets the current stencil function
  85942. * @param stencilFunc defines the new stencil function to use
  85943. */
  85944. setStencilFunction(stencilFunc: number): void;
  85945. /**
  85946. * Sets the current stencil reference
  85947. * @param reference defines the new stencil reference to use
  85948. */
  85949. setStencilFunctionReference(reference: number): void;
  85950. /**
  85951. * Sets the current stencil mask
  85952. * @param mask defines the new stencil mask to use
  85953. */
  85954. setStencilFunctionMask(mask: number): void;
  85955. /**
  85956. * Gets the current stencil operation when stencil fails
  85957. * @returns a number defining stencil operation to use when stencil fails
  85958. */
  85959. getStencilOperationFail(): number;
  85960. /**
  85961. * Gets the current stencil operation when depth fails
  85962. * @returns a number defining stencil operation to use when depth fails
  85963. */
  85964. getStencilOperationDepthFail(): number;
  85965. /**
  85966. * Gets the current stencil operation when stencil passes
  85967. * @returns a number defining stencil operation to use when stencil passes
  85968. */
  85969. getStencilOperationPass(): number;
  85970. /**
  85971. * Sets the stencil operation to use when stencil fails
  85972. * @param operation defines the stencil operation to use when stencil fails
  85973. */
  85974. setStencilOperationFail(operation: number): void;
  85975. /**
  85976. * Sets the stencil operation to use when depth fails
  85977. * @param operation defines the stencil operation to use when depth fails
  85978. */
  85979. setStencilOperationDepthFail(operation: number): void;
  85980. /**
  85981. * Sets the stencil operation to use when stencil passes
  85982. * @param operation defines the stencil operation to use when stencil passes
  85983. */
  85984. setStencilOperationPass(operation: number): void;
  85985. /**
  85986. * Sets a boolean indicating if the dithering state is enabled or disabled
  85987. * @param value defines the dithering state
  85988. */
  85989. setDitheringState(value: boolean): void;
  85990. /**
  85991. * Sets a boolean indicating if the rasterizer state is enabled or disabled
  85992. * @param value defines the rasterizer state
  85993. */
  85994. setRasterizerState(value: boolean): void;
  85995. /**
  85996. * stop executing a render loop function and remove it from the execution array
  85997. * @param renderFunction defines the function to be removed. If not provided all functions will be removed.
  85998. */
  85999. stopRenderLoop(renderFunction?: () => void): void;
  86000. /** @hidden */
  86001. _renderLoop(): void;
  86002. /**
  86003. * Register and execute a render loop. The engine can have more than one render function
  86004. * @param renderFunction defines the function to continuously execute
  86005. */
  86006. runRenderLoop(renderFunction: () => void): void;
  86007. /**
  86008. * Toggle full screen mode
  86009. * @param requestPointerLock defines if a pointer lock should be requested from the user
  86010. */
  86011. switchFullscreen(requestPointerLock: boolean): void;
  86012. /**
  86013. * Enters full screen mode
  86014. * @param requestPointerLock defines if a pointer lock should be requested from the user
  86015. */
  86016. enterFullscreen(requestPointerLock: boolean): void;
  86017. /**
  86018. * Exits full screen mode
  86019. */
  86020. exitFullscreen(): void;
  86021. /**
  86022. * Clear the current render buffer or the current render target (if any is set up)
  86023. * @param color defines the color to use
  86024. * @param backBuffer defines if the back buffer must be cleared
  86025. * @param depth defines if the depth buffer must be cleared
  86026. * @param stencil defines if the stencil buffer must be cleared
  86027. */
  86028. clear(color: Nullable<Color4>, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  86029. /**
  86030. * Executes a scissor clear (ie. a clear on a specific portion of the screen)
  86031. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  86032. * @param y defines the y-coordinate of the corner of the clear rectangle
  86033. * @param width defines the width of the clear rectangle
  86034. * @param height defines the height of the clear rectangle
  86035. * @param clearColor defines the clear color
  86036. */
  86037. scissorClear(x: number, y: number, width: number, height: number, clearColor: Color4): void;
  86038. /**
  86039. * Enable scissor test on a specific rectangle (ie. render will only be executed on a specific portion of the screen)
  86040. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  86041. * @param y defines the y-coordinate of the corner of the clear rectangle
  86042. * @param width defines the width of the clear rectangle
  86043. * @param height defines the height of the clear rectangle
  86044. */
  86045. enableScissor(x: number, y: number, width: number, height: number): void;
  86046. /**
  86047. * Disable previously set scissor test rectangle
  86048. */
  86049. disableScissor(): void;
  86050. private _viewportCached;
  86051. /** @hidden */
  86052. _viewport(x: number, y: number, width: number, height: number): void;
  86053. /**
  86054. * Set the WebGL's viewport
  86055. * @param viewport defines the viewport element to be used
  86056. * @param requiredWidth defines the width required for rendering. If not provided the rendering canvas' width is used
  86057. * @param requiredHeight defines the height required for rendering. If not provided the rendering canvas' height is used
  86058. */
  86059. setViewport(viewport: Viewport, requiredWidth?: number, requiredHeight?: number): void;
  86060. /**
  86061. * Directly set the WebGL Viewport
  86062. * @param x defines the x coordinate of the viewport (in screen space)
  86063. * @param y defines the y coordinate of the viewport (in screen space)
  86064. * @param width defines the width of the viewport (in screen space)
  86065. * @param height defines the height of the viewport (in screen space)
  86066. * @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
  86067. */
  86068. setDirectViewport(x: number, y: number, width: number, height: number): Nullable<Viewport>;
  86069. /**
  86070. * Begin a new frame
  86071. */
  86072. beginFrame(): void;
  86073. /**
  86074. * Enf the current frame
  86075. */
  86076. endFrame(): void;
  86077. /**
  86078. * Resize the view according to the canvas' size
  86079. */
  86080. resize(): void;
  86081. /**
  86082. * Force a specific size of the canvas
  86083. * @param width defines the new canvas' width
  86084. * @param height defines the new canvas' height
  86085. */
  86086. setSize(width: number, height: number): void;
  86087. /**
  86088. * Gets a boolean indicating if a webVR device was detected
  86089. * @returns true if a webVR device was detected
  86090. */
  86091. isVRDevicePresent(): boolean;
  86092. /**
  86093. * Gets the current webVR device
  86094. * @returns the current webVR device (or null)
  86095. */
  86096. getVRDevice(): any;
  86097. /**
  86098. * Initializes a webVR display and starts listening to display change events
  86099. * The onVRDisplayChangedObservable will be notified upon these changes
  86100. * @returns The onVRDisplayChangedObservable
  86101. */
  86102. initWebVR(): Observable<IDisplayChangedEventArgs>;
  86103. /**
  86104. * Initializes a webVR display and starts listening to display change events
  86105. * The onVRDisplayChangedObservable will be notified upon these changes
  86106. * @returns A promise containing a VRDisplay and if vr is supported
  86107. */
  86108. initWebVRAsync(): Promise<IDisplayChangedEventArgs>;
  86109. /**
  86110. * Call this function to switch to webVR mode
  86111. * Will do nothing if webVR is not supported or if there is no webVR device
  86112. * @see http://doc.babylonjs.com/how_to/webvr_camera
  86113. */
  86114. enableVR(): void;
  86115. /**
  86116. * Call this function to leave webVR mode
  86117. * Will do nothing if webVR is not supported or if there is no webVR device
  86118. * @see http://doc.babylonjs.com/how_to/webvr_camera
  86119. */
  86120. disableVR(): void;
  86121. private _onVRFullScreenTriggered;
  86122. private _getVRDisplaysAsync;
  86123. /**
  86124. * Binds the frame buffer to the specified texture.
  86125. * @param texture The texture to render to or null for the default canvas
  86126. * @param faceIndex The face of the texture to render to in case of cube texture
  86127. * @param requiredWidth The width of the target to render to
  86128. * @param requiredHeight The height of the target to render to
  86129. * @param forceFullscreenViewport Forces the viewport to be the entire texture/screen if true
  86130. * @param depthStencilTexture The depth stencil texture to use to render
  86131. * @param lodLevel defines le lod level to bind to the frame buffer
  86132. */
  86133. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean, depthStencilTexture?: InternalTexture, lodLevel?: number): void;
  86134. private bindUnboundFramebuffer;
  86135. /**
  86136. * Unbind the current render target texture from the webGL context
  86137. * @param texture defines the render target texture to unbind
  86138. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  86139. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  86140. */
  86141. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  86142. /**
  86143. * Unbind a list of render target textures from the webGL context
  86144. * This is used only when drawBuffer extension or webGL2 are active
  86145. * @param textures defines the render target textures to unbind
  86146. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  86147. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  86148. */
  86149. unBindMultiColorAttachmentFramebuffer(textures: InternalTexture[], disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  86150. /**
  86151. * Force the mipmap generation for the given render target texture
  86152. * @param texture defines the render target texture to use
  86153. */
  86154. generateMipMapsForCubemap(texture: InternalTexture): void;
  86155. /**
  86156. * Force a webGL flush (ie. a flush of all waiting webGL commands)
  86157. */
  86158. flushFramebuffer(): void;
  86159. /**
  86160. * Unbind the current render target and bind the default framebuffer
  86161. */
  86162. restoreDefaultFramebuffer(): void;
  86163. /**
  86164. * Create an uniform buffer
  86165. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  86166. * @param elements defines the content of the uniform buffer
  86167. * @returns the webGL uniform buffer
  86168. */
  86169. createUniformBuffer(elements: FloatArray): WebGLBuffer;
  86170. /**
  86171. * Create a dynamic uniform buffer
  86172. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  86173. * @param elements defines the content of the uniform buffer
  86174. * @returns the webGL uniform buffer
  86175. */
  86176. createDynamicUniformBuffer(elements: FloatArray): WebGLBuffer;
  86177. /**
  86178. * Update an existing uniform buffer
  86179. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  86180. * @param uniformBuffer defines the target uniform buffer
  86181. * @param elements defines the content to update
  86182. * @param offset defines the offset in the uniform buffer where update should start
  86183. * @param count defines the size of the data to update
  86184. */
  86185. updateUniformBuffer(uniformBuffer: WebGLBuffer, elements: FloatArray, offset?: number, count?: number): void;
  86186. private _resetVertexBufferBinding;
  86187. /**
  86188. * Creates a vertex buffer
  86189. * @param data the data for the vertex buffer
  86190. * @returns the new WebGL static buffer
  86191. */
  86192. createVertexBuffer(data: DataArray): WebGLBuffer;
  86193. /**
  86194. * Creates a dynamic vertex buffer
  86195. * @param data the data for the dynamic vertex buffer
  86196. * @returns the new WebGL dynamic buffer
  86197. */
  86198. createDynamicVertexBuffer(data: DataArray): WebGLBuffer;
  86199. /**
  86200. * Update a dynamic index buffer
  86201. * @param indexBuffer defines the target index buffer
  86202. * @param indices defines the data to update
  86203. * @param offset defines the offset in the target index buffer where update should start
  86204. */
  86205. updateDynamicIndexBuffer(indexBuffer: WebGLBuffer, indices: IndicesArray, offset?: number): void;
  86206. /**
  86207. * Updates a dynamic vertex buffer.
  86208. * @param vertexBuffer the vertex buffer to update
  86209. * @param data the data used to update the vertex buffer
  86210. * @param byteOffset the byte offset of the data
  86211. * @param byteLength the byte length of the data
  86212. */
  86213. updateDynamicVertexBuffer(vertexBuffer: WebGLBuffer, data: DataArray, byteOffset?: number, byteLength?: number): void;
  86214. private _resetIndexBufferBinding;
  86215. /**
  86216. * Creates a new index buffer
  86217. * @param indices defines the content of the index buffer
  86218. * @param updatable defines if the index buffer must be updatable
  86219. * @returns a new webGL buffer
  86220. */
  86221. createIndexBuffer(indices: IndicesArray, updatable?: boolean): WebGLBuffer;
  86222. /**
  86223. * Bind a webGL buffer to the webGL context
  86224. * @param buffer defines the buffer to bind
  86225. */
  86226. bindArrayBuffer(buffer: Nullable<WebGLBuffer>): void;
  86227. /**
  86228. * Bind an uniform buffer to the current webGL context
  86229. * @param buffer defines the buffer to bind
  86230. */
  86231. bindUniformBuffer(buffer: Nullable<WebGLBuffer>): void;
  86232. /**
  86233. * Bind a buffer to the current webGL context at a given location
  86234. * @param buffer defines the buffer to bind
  86235. * @param location defines the index where to bind the buffer
  86236. */
  86237. bindUniformBufferBase(buffer: WebGLBuffer, location: number): void;
  86238. /**
  86239. * Bind a specific block at a given index in a specific shader program
  86240. * @param shaderProgram defines the shader program
  86241. * @param blockName defines the block name
  86242. * @param index defines the index where to bind the block
  86243. */
  86244. bindUniformBlock(shaderProgram: WebGLProgram, blockName: string, index: number): void;
  86245. private bindIndexBuffer;
  86246. private bindBuffer;
  86247. /**
  86248. * update the bound buffer with the given data
  86249. * @param data defines the data to update
  86250. */
  86251. updateArrayBuffer(data: Float32Array): void;
  86252. private _vertexAttribPointer;
  86253. private _bindIndexBufferWithCache;
  86254. private _bindVertexBuffersAttributes;
  86255. /**
  86256. * Records a vertex array object
  86257. * @see http://doc.babylonjs.com/features/webgl2#vertex-array-objects
  86258. * @param vertexBuffers defines the list of vertex buffers to store
  86259. * @param indexBuffer defines the index buffer to store
  86260. * @param effect defines the effect to store
  86261. * @returns the new vertex array object
  86262. */
  86263. recordVertexArrayObject(vertexBuffers: {
  86264. [key: string]: VertexBuffer;
  86265. }, indexBuffer: Nullable<WebGLBuffer>, effect: Effect): WebGLVertexArrayObject;
  86266. /**
  86267. * Bind a specific vertex array object
  86268. * @see http://doc.babylonjs.com/features/webgl2#vertex-array-objects
  86269. * @param vertexArrayObject defines the vertex array object to bind
  86270. * @param indexBuffer defines the index buffer to bind
  86271. */
  86272. bindVertexArrayObject(vertexArrayObject: WebGLVertexArrayObject, indexBuffer: Nullable<WebGLBuffer>): void;
  86273. /**
  86274. * Bind webGl buffers directly to the webGL context
  86275. * @param vertexBuffer defines the vertex buffer to bind
  86276. * @param indexBuffer defines the index buffer to bind
  86277. * @param vertexDeclaration defines the vertex declaration to use with the vertex buffer
  86278. * @param vertexStrideSize defines the vertex stride of the vertex buffer
  86279. * @param effect defines the effect associated with the vertex buffer
  86280. */
  86281. bindBuffersDirectly(vertexBuffer: WebGLBuffer, indexBuffer: WebGLBuffer, vertexDeclaration: number[], vertexStrideSize: number, effect: Effect): void;
  86282. private _unbindVertexArrayObject;
  86283. /**
  86284. * Bind a list of vertex buffers to the webGL context
  86285. * @param vertexBuffers defines the list of vertex buffers to bind
  86286. * @param indexBuffer defines the index buffer to bind
  86287. * @param effect defines the effect associated with the vertex buffers
  86288. */
  86289. bindBuffers(vertexBuffers: {
  86290. [key: string]: Nullable<VertexBuffer>;
  86291. }, indexBuffer: Nullable<WebGLBuffer>, effect: Effect): void;
  86292. /**
  86293. * Unbind all instance attributes
  86294. */
  86295. unbindInstanceAttributes(): void;
  86296. /**
  86297. * Release and free the memory of a vertex array object
  86298. * @param vao defines the vertex array object to delete
  86299. */
  86300. releaseVertexArrayObject(vao: WebGLVertexArrayObject): void;
  86301. /** @hidden */
  86302. _releaseBuffer(buffer: WebGLBuffer): boolean;
  86303. /**
  86304. * Creates a webGL buffer to use with instanciation
  86305. * @param capacity defines the size of the buffer
  86306. * @returns the webGL buffer
  86307. */
  86308. createInstancesBuffer(capacity: number): WebGLBuffer;
  86309. /**
  86310. * Delete a webGL buffer used with instanciation
  86311. * @param buffer defines the webGL buffer to delete
  86312. */
  86313. deleteInstancesBuffer(buffer: WebGLBuffer): void;
  86314. /**
  86315. * Update the content of a webGL buffer used with instanciation and bind it to the webGL context
  86316. * @param instancesBuffer defines the webGL buffer to update and bind
  86317. * @param data defines the data to store in the buffer
  86318. * @param offsetLocations defines the offsets or attributes information used to determine where data must be stored in the buffer
  86319. */
  86320. updateAndBindInstancesBuffer(instancesBuffer: WebGLBuffer, data: Float32Array, offsetLocations: number[] | InstancingAttributeInfo[]): void;
  86321. /**
  86322. * Apply all cached states (depth, culling, stencil and alpha)
  86323. */
  86324. applyStates(): void;
  86325. /**
  86326. * Send a draw order
  86327. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  86328. * @param indexStart defines the starting index
  86329. * @param indexCount defines the number of index to draw
  86330. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  86331. */
  86332. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  86333. /**
  86334. * Draw a list of points
  86335. * @param verticesStart defines the index of first vertex to draw
  86336. * @param verticesCount defines the count of vertices to draw
  86337. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  86338. */
  86339. drawPointClouds(verticesStart: number, verticesCount: number, instancesCount?: number): void;
  86340. /**
  86341. * Draw a list of unindexed primitives
  86342. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  86343. * @param verticesStart defines the index of first vertex to draw
  86344. * @param verticesCount defines the count of vertices to draw
  86345. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  86346. */
  86347. drawUnIndexed(useTriangles: boolean, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  86348. /**
  86349. * Draw a list of indexed primitives
  86350. * @param fillMode defines the primitive to use
  86351. * @param indexStart defines the starting index
  86352. * @param indexCount defines the number of index to draw
  86353. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  86354. */
  86355. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  86356. /**
  86357. * Draw a list of unindexed primitives
  86358. * @param fillMode defines the primitive to use
  86359. * @param verticesStart defines the index of first vertex to draw
  86360. * @param verticesCount defines the count of vertices to draw
  86361. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  86362. */
  86363. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  86364. private _drawMode;
  86365. /** @hidden */
  86366. _releaseEffect(effect: Effect): void;
  86367. /** @hidden */
  86368. _deleteProgram(program: WebGLProgram): void;
  86369. /**
  86370. * Create a new effect (used to store vertex/fragment shaders)
  86371. * @param baseName defines the base name of the effect (The name of file without .fragment.fx or .vertex.fx)
  86372. * @param attributesNamesOrOptions defines either a list of attribute names or an EffectCreationOptions object
  86373. * @param uniformsNamesOrEngine defines either a list of uniform names or the engine to use
  86374. * @param samplers defines an array of string used to represent textures
  86375. * @param defines defines the string containing the defines to use to compile the shaders
  86376. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  86377. * @param onCompiled defines a function to call when the effect creation is successful
  86378. * @param onError defines a function to call when the effect creation has failed
  86379. * @param indexParameters defines an object containing the index values to use to compile shaders (like the maximum number of simultaneous lights)
  86380. * @returns the new Effect
  86381. */
  86382. 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;
  86383. private _compileShader;
  86384. private _compileRawShader;
  86385. /**
  86386. * Directly creates a webGL program
  86387. * @param vertexCode defines the vertex shader code to use
  86388. * @param fragmentCode defines the fragment shader code to use
  86389. * @param context defines the webGL context to use (if not set, the current one will be used)
  86390. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  86391. * @returns the new webGL program
  86392. */
  86393. createRawShaderProgram(vertexCode: string, fragmentCode: string, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  86394. /**
  86395. * Creates a webGL program
  86396. * @param vertexCode defines the vertex shader code to use
  86397. * @param fragmentCode defines the fragment shader code to use
  86398. * @param defines defines the string containing the defines to use to compile the shaders
  86399. * @param context defines the webGL context to use (if not set, the current one will be used)
  86400. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  86401. * @returns the new webGL program
  86402. */
  86403. createShaderProgram(vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  86404. private _createShaderProgram;
  86405. private _finalizeProgram;
  86406. /** @hidden */
  86407. _isProgramCompiled(shaderProgram: WebGLProgram): boolean;
  86408. /** @hidden */
  86409. _executeWhenProgramIsCompiled(shaderProgram: WebGLProgram, action: () => void): void;
  86410. /**
  86411. * Gets the list of webGL uniform locations associated with a specific program based on a list of uniform names
  86412. * @param shaderProgram defines the webGL program to use
  86413. * @param uniformsNames defines the list of uniform names
  86414. * @returns an array of webGL uniform locations
  86415. */
  86416. getUniforms(shaderProgram: WebGLProgram, uniformsNames: string[]): Nullable<WebGLUniformLocation>[];
  86417. /**
  86418. * Gets the lsit of active attributes for a given webGL program
  86419. * @param shaderProgram defines the webGL program to use
  86420. * @param attributesNames defines the list of attribute names to get
  86421. * @returns an array of indices indicating the offset of each attribute
  86422. */
  86423. getAttributes(shaderProgram: WebGLProgram, attributesNames: string[]): number[];
  86424. /**
  86425. * Activates an effect, mkaing it the current one (ie. the one used for rendering)
  86426. * @param effect defines the effect to activate
  86427. */
  86428. enableEffect(effect: Nullable<Effect>): void;
  86429. /**
  86430. * Set the value of an uniform to an array of int32
  86431. * @param uniform defines the webGL uniform location where to store the value
  86432. * @param array defines the array of int32 to store
  86433. */
  86434. setIntArray(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  86435. /**
  86436. * Set the value of an uniform to an array of int32 (stored as vec2)
  86437. * @param uniform defines the webGL uniform location where to store the value
  86438. * @param array defines the array of int32 to store
  86439. */
  86440. setIntArray2(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  86441. /**
  86442. * Set the value of an uniform to an array of int32 (stored as vec3)
  86443. * @param uniform defines the webGL uniform location where to store the value
  86444. * @param array defines the array of int32 to store
  86445. */
  86446. setIntArray3(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  86447. /**
  86448. * Set the value of an uniform to an array of int32 (stored as vec4)
  86449. * @param uniform defines the webGL uniform location where to store the value
  86450. * @param array defines the array of int32 to store
  86451. */
  86452. setIntArray4(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  86453. /**
  86454. * Set the value of an uniform to an array of float32
  86455. * @param uniform defines the webGL uniform location where to store the value
  86456. * @param array defines the array of float32 to store
  86457. */
  86458. setFloatArray(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  86459. /**
  86460. * Set the value of an uniform to an array of float32 (stored as vec2)
  86461. * @param uniform defines the webGL uniform location where to store the value
  86462. * @param array defines the array of float32 to store
  86463. */
  86464. setFloatArray2(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  86465. /**
  86466. * Set the value of an uniform to an array of float32 (stored as vec3)
  86467. * @param uniform defines the webGL uniform location where to store the value
  86468. * @param array defines the array of float32 to store
  86469. */
  86470. setFloatArray3(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  86471. /**
  86472. * Set the value of an uniform to an array of float32 (stored as vec4)
  86473. * @param uniform defines the webGL uniform location where to store the value
  86474. * @param array defines the array of float32 to store
  86475. */
  86476. setFloatArray4(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  86477. /**
  86478. * Set the value of an uniform to an array of number
  86479. * @param uniform defines the webGL uniform location where to store the value
  86480. * @param array defines the array of number to store
  86481. */
  86482. setArray(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  86483. /**
  86484. * Set the value of an uniform to an array of number (stored as vec2)
  86485. * @param uniform defines the webGL uniform location where to store the value
  86486. * @param array defines the array of number to store
  86487. */
  86488. setArray2(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  86489. /**
  86490. * Set the value of an uniform to an array of number (stored as vec3)
  86491. * @param uniform defines the webGL uniform location where to store the value
  86492. * @param array defines the array of number to store
  86493. */
  86494. setArray3(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  86495. /**
  86496. * Set the value of an uniform to an array of number (stored as vec4)
  86497. * @param uniform defines the webGL uniform location where to store the value
  86498. * @param array defines the array of number to store
  86499. */
  86500. setArray4(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  86501. /**
  86502. * Set the value of an uniform to an array of float32 (stored as matrices)
  86503. * @param uniform defines the webGL uniform location where to store the value
  86504. * @param matrices defines the array of float32 to store
  86505. */
  86506. setMatrices(uniform: Nullable<WebGLUniformLocation>, matrices: Float32Array): void;
  86507. /**
  86508. * Set the value of an uniform to a matrix
  86509. * @param uniform defines the webGL uniform location where to store the value
  86510. * @param matrix defines the matrix to store
  86511. */
  86512. setMatrix(uniform: Nullable<WebGLUniformLocation>, matrix: Matrix): void;
  86513. /**
  86514. * Set the value of an uniform to a matrix (3x3)
  86515. * @param uniform defines the webGL uniform location where to store the value
  86516. * @param matrix defines the Float32Array representing the 3x3 matrix to store
  86517. */
  86518. setMatrix3x3(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): void;
  86519. /**
  86520. * Set the value of an uniform to a matrix (2x2)
  86521. * @param uniform defines the webGL uniform location where to store the value
  86522. * @param matrix defines the Float32Array representing the 2x2 matrix to store
  86523. */
  86524. setMatrix2x2(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): void;
  86525. /**
  86526. * Set the value of an uniform to a number (int)
  86527. * @param uniform defines the webGL uniform location where to store the value
  86528. * @param value defines the int number to store
  86529. */
  86530. setInt(uniform: Nullable<WebGLUniformLocation>, value: number): void;
  86531. /**
  86532. * Set the value of an uniform to a number (float)
  86533. * @param uniform defines the webGL uniform location where to store the value
  86534. * @param value defines the float number to store
  86535. */
  86536. setFloat(uniform: Nullable<WebGLUniformLocation>, value: number): void;
  86537. /**
  86538. * Set the value of an uniform to a vec2
  86539. * @param uniform defines the webGL uniform location where to store the value
  86540. * @param x defines the 1st component of the value
  86541. * @param y defines the 2nd component of the value
  86542. */
  86543. setFloat2(uniform: Nullable<WebGLUniformLocation>, x: number, y: number): void;
  86544. /**
  86545. * Set the value of an uniform to a vec3
  86546. * @param uniform defines the webGL uniform location where to store the value
  86547. * @param x defines the 1st component of the value
  86548. * @param y defines the 2nd component of the value
  86549. * @param z defines the 3rd component of the value
  86550. */
  86551. setFloat3(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number): void;
  86552. /**
  86553. * Set the value of an uniform to a boolean
  86554. * @param uniform defines the webGL uniform location where to store the value
  86555. * @param bool defines the boolean to store
  86556. */
  86557. setBool(uniform: Nullable<WebGLUniformLocation>, bool: number): void;
  86558. /**
  86559. * Set the value of an uniform to a vec4
  86560. * @param uniform defines the webGL uniform location where to store the value
  86561. * @param x defines the 1st component of the value
  86562. * @param y defines the 2nd component of the value
  86563. * @param z defines the 3rd component of the value
  86564. * @param w defines the 4th component of the value
  86565. */
  86566. setFloat4(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number, w: number): void;
  86567. /**
  86568. * Set the value of an uniform to a Color3
  86569. * @param uniform defines the webGL uniform location where to store the value
  86570. * @param color3 defines the color to store
  86571. */
  86572. setColor3(uniform: Nullable<WebGLUniformLocation>, color3: Color3): void;
  86573. /**
  86574. * Set the value of an uniform to a Color3 and an alpha value
  86575. * @param uniform defines the webGL uniform location where to store the value
  86576. * @param color3 defines the color to store
  86577. * @param alpha defines the alpha component to store
  86578. */
  86579. setColor4(uniform: Nullable<WebGLUniformLocation>, color3: Color3, alpha: number): void;
  86580. /**
  86581. * Sets a Color4 on a uniform variable
  86582. * @param uniform defines the uniform location
  86583. * @param color4 defines the value to be set
  86584. */
  86585. setDirectColor4(uniform: Nullable<WebGLUniformLocation>, color4: Color4): void;
  86586. /**
  86587. * Set various states to the webGL context
  86588. * @param culling defines backface culling state
  86589. * @param zOffset defines the value to apply to zOffset (0 by default)
  86590. * @param force defines if states must be applied even if cache is up to date
  86591. * @param reverseSide defines if culling must be reversed (CCW instead of CW and CW instead of CCW)
  86592. */
  86593. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  86594. /**
  86595. * Set the z offset to apply to current rendering
  86596. * @param value defines the offset to apply
  86597. */
  86598. setZOffset(value: number): void;
  86599. /**
  86600. * Gets the current value of the zOffset
  86601. * @returns the current zOffset state
  86602. */
  86603. getZOffset(): number;
  86604. /**
  86605. * Enable or disable depth buffering
  86606. * @param enable defines the state to set
  86607. */
  86608. setDepthBuffer(enable: boolean): void;
  86609. /**
  86610. * Gets a boolean indicating if depth writing is enabled
  86611. * @returns the current depth writing state
  86612. */
  86613. getDepthWrite(): boolean;
  86614. /**
  86615. * Enable or disable depth writing
  86616. * @param enable defines the state to set
  86617. */
  86618. setDepthWrite(enable: boolean): void;
  86619. /**
  86620. * Enable or disable color writing
  86621. * @param enable defines the state to set
  86622. */
  86623. setColorWrite(enable: boolean): void;
  86624. /**
  86625. * Gets a boolean indicating if color writing is enabled
  86626. * @returns the current color writing state
  86627. */
  86628. getColorWrite(): boolean;
  86629. /**
  86630. * Sets alpha constants used by some alpha blending modes
  86631. * @param r defines the red component
  86632. * @param g defines the green component
  86633. * @param b defines the blue component
  86634. * @param a defines the alpha component
  86635. */
  86636. setAlphaConstants(r: number, g: number, b: number, a: number): void;
  86637. /**
  86638. * Sets the current alpha mode
  86639. * @param mode defines the mode to use (one of the Engine.ALPHA_XXX)
  86640. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  86641. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  86642. */
  86643. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  86644. /**
  86645. * Gets the current alpha mode
  86646. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  86647. * @returns the current alpha mode
  86648. */
  86649. getAlphaMode(): number;
  86650. /**
  86651. * Clears the list of texture accessible through engine.
  86652. * This can help preventing texture load conflict due to name collision.
  86653. */
  86654. clearInternalTexturesCache(): void;
  86655. /**
  86656. * Force the entire cache to be cleared
  86657. * You should not have to use this function unless your engine needs to share the webGL context with another engine
  86658. * @param bruteForce defines a boolean to force clearing ALL caches (including stencil, detoh and alpha states)
  86659. */
  86660. wipeCaches(bruteForce?: boolean): void;
  86661. /**
  86662. * Set the compressed texture format to use, based on the formats you have, and the formats
  86663. * supported by the hardware / browser.
  86664. *
  86665. * Khronos Texture Container (.ktx) files are used to support this. This format has the
  86666. * advantage of being specifically designed for OpenGL. Header elements directly correspond
  86667. * to API arguments needed to compressed textures. This puts the burden on the container
  86668. * generator to house the arcane code for determining these for current & future formats.
  86669. *
  86670. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  86671. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  86672. *
  86673. * Note: The result of this call is not taken into account when a texture is base64.
  86674. *
  86675. * @param formatsAvailable defines the list of those format families you have created
  86676. * on your server. Syntax: '-' + format family + '.ktx'. (Case and order do not matter.)
  86677. *
  86678. * Current families are astc, dxt, pvrtc, etc2, & etc1.
  86679. * @returns The extension selected.
  86680. */
  86681. setTextureFormatToUse(formatsAvailable: Array<string>): Nullable<string>;
  86682. private _getSamplingParameters;
  86683. private _partialLoadImg;
  86684. private _cascadeLoadImgs;
  86685. /** @hidden */
  86686. _createTexture(): WebGLTexture;
  86687. /**
  86688. * Usually called from Texture.ts.
  86689. * Passed information to create a WebGLTexture
  86690. * @param urlArg defines a value which contains one of the following:
  86691. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  86692. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  86693. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  86694. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  86695. * @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)
  86696. * @param scene needed for loading to the correct scene
  86697. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  86698. * @param onLoad optional callback to be called upon successful completion
  86699. * @param onError optional callback to be called upon failure
  86700. * @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
  86701. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  86702. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  86703. * @param forcedExtension defines the extension to use to pick the right loader
  86704. * @param excludeLoaders array of texture loaders that should be excluded when picking a loader for the texture (default: empty array)
  86705. * @returns a InternalTexture for assignment back into BABYLON.Texture
  86706. */
  86707. 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;
  86708. private _rescaleTexture;
  86709. /**
  86710. * Update a raw texture
  86711. * @param texture defines the texture to update
  86712. * @param data defines the data to store in the texture
  86713. * @param format defines the format of the data
  86714. * @param invertY defines if data must be stored with Y axis inverted
  86715. * @param compression defines the compression used (null by default)
  86716. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  86717. */
  86718. updateRawTexture(texture: Nullable<InternalTexture>, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression?: Nullable<string>, type?: number): void;
  86719. /**
  86720. * Creates a raw texture
  86721. * @param data defines the data to store in the texture
  86722. * @param width defines the width of the texture
  86723. * @param height defines the height of the texture
  86724. * @param format defines the format of the data
  86725. * @param generateMipMaps defines if the engine should generate the mip levels
  86726. * @param invertY defines if data must be stored with Y axis inverted
  86727. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  86728. * @param compression defines the compression used (null by default)
  86729. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  86730. * @returns the raw texture inside an InternalTexture
  86731. */
  86732. createRawTexture(data: Nullable<ArrayBufferView>, width: number, height: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression?: Nullable<string>, type?: number): InternalTexture;
  86733. private _unpackFlipYCached;
  86734. /**
  86735. * In case you are sharing the context with other applications, it might
  86736. * be interested to not cache the unpack flip y state to ensure a consistent
  86737. * value would be set.
  86738. */
  86739. enableUnpackFlipYCached: boolean;
  86740. /** @hidden */
  86741. _unpackFlipY(value: boolean): void;
  86742. /** @hidden */
  86743. _getUnpackAlignement(): number;
  86744. /**
  86745. * Creates a dynamic texture
  86746. * @param width defines the width of the texture
  86747. * @param height defines the height of the texture
  86748. * @param generateMipMaps defines if the engine should generate the mip levels
  86749. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  86750. * @returns the dynamic texture inside an InternalTexture
  86751. */
  86752. createDynamicTexture(width: number, height: number, generateMipMaps: boolean, samplingMode: number): InternalTexture;
  86753. /**
  86754. * Update the sampling mode of a given texture
  86755. * @param samplingMode defines the required sampling mode
  86756. * @param texture defines the texture to update
  86757. */
  86758. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  86759. /**
  86760. * Update the content of a dynamic texture
  86761. * @param texture defines the texture to update
  86762. * @param canvas defines the canvas containing the source
  86763. * @param invertY defines if data must be stored with Y axis inverted
  86764. * @param premulAlpha defines if alpha is stored as premultiplied
  86765. * @param format defines the format of the data
  86766. * @param forceBindTexture if the texture should be forced to be bound eg. after a graphics context loss (Default: false)
  86767. */
  86768. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement, invertY: boolean, premulAlpha?: boolean, format?: number, forceBindTexture?: boolean): void;
  86769. /**
  86770. * Update a video texture
  86771. * @param texture defines the texture to update
  86772. * @param video defines the video element to use
  86773. * @param invertY defines if data must be stored with Y axis inverted
  86774. */
  86775. updateVideoTexture(texture: Nullable<InternalTexture>, video: HTMLVideoElement, invertY: boolean): void;
  86776. /**
  86777. * Updates a depth texture Comparison Mode and Function.
  86778. * If the comparison Function is equal to 0, the mode will be set to none.
  86779. * Otherwise, this only works in webgl 2 and requires a shadow sampler in the shader.
  86780. * @param texture The texture to set the comparison function for
  86781. * @param comparisonFunction The comparison function to set, 0 if no comparison required
  86782. */
  86783. updateTextureComparisonFunction(texture: InternalTexture, comparisonFunction: number): void;
  86784. private _setupDepthStencilTexture;
  86785. /**
  86786. * Creates a depth stencil texture.
  86787. * This is only available in WebGL 2 or with the depth texture extension available.
  86788. * @param size The size of face edge in the texture.
  86789. * @param options The options defining the texture.
  86790. * @returns The texture
  86791. */
  86792. createDepthStencilTexture(size: number | {
  86793. width: number;
  86794. height: number;
  86795. }, options: DepthTextureCreationOptions): InternalTexture;
  86796. /**
  86797. * Creates a depth stencil texture.
  86798. * This is only available in WebGL 2 or with the depth texture extension available.
  86799. * @param size The size of face edge in the texture.
  86800. * @param options The options defining the texture.
  86801. * @returns The texture
  86802. */
  86803. private _createDepthStencilTexture;
  86804. /**
  86805. * Creates a depth stencil cube texture.
  86806. * This is only available in WebGL 2.
  86807. * @param size The size of face edge in the cube texture.
  86808. * @param options The options defining the cube texture.
  86809. * @returns The cube texture
  86810. */
  86811. private _createDepthStencilCubeTexture;
  86812. /**
  86813. * Sets the frame buffer Depth / Stencil attachement of the render target to the defined depth stencil texture.
  86814. * @param renderTarget The render target to set the frame buffer for
  86815. */
  86816. setFrameBufferDepthStencilTexture(renderTarget: RenderTargetTexture): void;
  86817. /**
  86818. * Creates a new render target texture
  86819. * @param size defines the size of the texture
  86820. * @param options defines the options used to create the texture
  86821. * @returns a new render target texture stored in an InternalTexture
  86822. */
  86823. createRenderTargetTexture(size: number | {
  86824. width: number;
  86825. height: number;
  86826. }, options: boolean | RenderTargetCreationOptions): InternalTexture;
  86827. /**
  86828. * Create a multi render target texture
  86829. * @see http://doc.babylonjs.com/features/webgl2#multiple-render-target
  86830. * @param size defines the size of the texture
  86831. * @param options defines the creation options
  86832. * @returns the cube texture as an InternalTexture
  86833. */
  86834. createMultipleRenderTarget(size: any, options: IMultiRenderTargetOptions): InternalTexture[];
  86835. private _setupFramebufferDepthAttachments;
  86836. /**
  86837. * Updates the sample count of a render target texture
  86838. * @see http://doc.babylonjs.com/features/webgl2#multisample-render-targets
  86839. * @param texture defines the texture to update
  86840. * @param samples defines the sample count to set
  86841. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  86842. */
  86843. updateRenderTargetTextureSampleCount(texture: Nullable<InternalTexture>, samples: number): number;
  86844. /**
  86845. * Update the sample count for a given multiple render target texture
  86846. * @see http://doc.babylonjs.com/features/webgl2#multisample-render-targets
  86847. * @param textures defines the textures to update
  86848. * @param samples defines the sample count to set
  86849. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  86850. */
  86851. updateMultipleRenderTargetTextureSampleCount(textures: Nullable<InternalTexture[]>, samples: number): number;
  86852. /** @hidden */
  86853. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  86854. /** @hidden */
  86855. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  86856. /** @hidden */
  86857. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  86858. /** @hidden */
  86859. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  86860. /**
  86861. * Creates a new render target cube texture
  86862. * @param size defines the size of the texture
  86863. * @param options defines the options used to create the texture
  86864. * @returns a new render target cube texture stored in an InternalTexture
  86865. */
  86866. createRenderTargetCubeTexture(size: number, options?: Partial<RenderTargetCreationOptions>): InternalTexture;
  86867. /**
  86868. * Creates a cube texture
  86869. * @param rootUrl defines the url where the files to load is located
  86870. * @param scene defines the current scene
  86871. * @param files defines the list of files to load (1 per face)
  86872. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  86873. * @param onLoad defines an optional callback raised when the texture is loaded
  86874. * @param onError defines an optional callback raised if there is an issue to load the texture
  86875. * @param format defines the format of the data
  86876. * @param forcedExtension defines the extension to use to pick the right loader
  86877. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  86878. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  86879. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  86880. * @param fallback defines texture to use while falling back when (compressed) texture file not found.
  86881. * @param excludeLoaders array of texture loaders that should be excluded when picking a loader for the texture (defualt: empty array)
  86882. * @returns the cube texture as an InternalTexture
  86883. */
  86884. 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;
  86885. /**
  86886. * @hidden
  86887. */
  86888. _setCubeMapTextureParams(loadMipmap: boolean): void;
  86889. /**
  86890. * Update a raw cube texture
  86891. * @param texture defines the texture to udpdate
  86892. * @param data defines the data to store
  86893. * @param format defines the data format
  86894. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  86895. * @param invertY defines if data must be stored with Y axis inverted
  86896. * @param compression defines the compression used (null by default)
  86897. * @param level defines which level of the texture to update
  86898. */
  86899. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression?: Nullable<string>, level?: number): void;
  86900. /**
  86901. * Creates a new raw cube texture
  86902. * @param data defines the array of data to use to create each face
  86903. * @param size defines the size of the textures
  86904. * @param format defines the format of the data
  86905. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  86906. * @param generateMipMaps defines if the engine should generate the mip levels
  86907. * @param invertY defines if data must be stored with Y axis inverted
  86908. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  86909. * @param compression defines the compression used (null by default)
  86910. * @returns the cube texture as an InternalTexture
  86911. */
  86912. createRawCubeTexture(data: Nullable<ArrayBufferView[]>, size: number, format: number, type: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression?: Nullable<string>): InternalTexture;
  86913. /**
  86914. * Creates a new raw cube texture from a specified url
  86915. * @param url defines the url where the data is located
  86916. * @param scene defines the current scene
  86917. * @param size defines the size of the textures
  86918. * @param format defines the format of the data
  86919. * @param type defines the type fo the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  86920. * @param noMipmap defines if the engine should avoid generating the mip levels
  86921. * @param callback defines a callback used to extract texture data from loaded data
  86922. * @param mipmapGenerator defines to provide an optional tool to generate mip levels
  86923. * @param onLoad defines a callback called when texture is loaded
  86924. * @param onError defines a callback called if there is an error
  86925. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  86926. * @param invertY defines if data must be stored with Y axis inverted
  86927. * @returns the cube texture as an InternalTexture
  86928. */
  86929. 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;
  86930. /**
  86931. * Update a raw 3D texture
  86932. * @param texture defines the texture to update
  86933. * @param data defines the data to store
  86934. * @param format defines the data format
  86935. * @param invertY defines if data must be stored with Y axis inverted
  86936. * @param compression defines the used compression (can be null)
  86937. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  86938. */
  86939. updateRawTexture3D(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression?: Nullable<string>, textureType?: number): void;
  86940. /**
  86941. * Creates a new raw 3D texture
  86942. * @param data defines the data used to create the texture
  86943. * @param width defines the width of the texture
  86944. * @param height defines the height of the texture
  86945. * @param depth defines the depth of the texture
  86946. * @param format defines the format of the texture
  86947. * @param generateMipMaps defines if the engine must generate mip levels
  86948. * @param invertY defines if data must be stored with Y axis inverted
  86949. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  86950. * @param compression defines the compressed used (can be null)
  86951. * @param textureType defines the compressed used (can be null)
  86952. * @returns a new raw 3D texture (stored in an InternalTexture)
  86953. */
  86954. createRawTexture3D(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression?: Nullable<string>, textureType?: number): InternalTexture;
  86955. private _prepareWebGLTextureContinuation;
  86956. private _prepareWebGLTexture;
  86957. private _convertRGBtoRGBATextureData;
  86958. /** @hidden */
  86959. _releaseFramebufferObjects(texture: InternalTexture): void;
  86960. /** @hidden */
  86961. _releaseTexture(texture: InternalTexture): void;
  86962. private setProgram;
  86963. private _boundUniforms;
  86964. /**
  86965. * Binds an effect to the webGL context
  86966. * @param effect defines the effect to bind
  86967. */
  86968. bindSamplers(effect: Effect): void;
  86969. private _moveBoundTextureOnTop;
  86970. private _getCorrectTextureChannel;
  86971. private _linkTrackers;
  86972. private _removeDesignatedSlot;
  86973. private _activateCurrentTexture;
  86974. /** @hidden */
  86975. _bindTextureDirectly(target: number, texture: Nullable<InternalTexture>, forTextureDataUpdate?: boolean, force?: boolean): boolean;
  86976. /** @hidden */
  86977. _bindTexture(channel: number, texture: Nullable<InternalTexture>): void;
  86978. /**
  86979. * Sets a texture to the webGL context from a postprocess
  86980. * @param channel defines the channel to use
  86981. * @param postProcess defines the source postprocess
  86982. */
  86983. setTextureFromPostProcess(channel: number, postProcess: Nullable<PostProcess>): void;
  86984. /**
  86985. * Binds the output of the passed in post process to the texture channel specified
  86986. * @param channel The channel the texture should be bound to
  86987. * @param postProcess The post process which's output should be bound
  86988. */
  86989. setTextureFromPostProcessOutput(channel: number, postProcess: Nullable<PostProcess>): void;
  86990. /**
  86991. * Unbind all textures from the webGL context
  86992. */
  86993. unbindAllTextures(): void;
  86994. /**
  86995. * Sets a texture to the according uniform.
  86996. * @param channel The texture channel
  86997. * @param uniform The uniform to set
  86998. * @param texture The texture to apply
  86999. */
  87000. setTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<BaseTexture>): void;
  87001. /**
  87002. * Sets a depth stencil texture from a render target to the according uniform.
  87003. * @param channel The texture channel
  87004. * @param uniform The uniform to set
  87005. * @param texture The render target texture containing the depth stencil texture to apply
  87006. */
  87007. setDepthStencilTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<RenderTargetTexture>): void;
  87008. private _bindSamplerUniformToChannel;
  87009. private _getTextureWrapMode;
  87010. private _setTexture;
  87011. /**
  87012. * Sets an array of texture to the webGL context
  87013. * @param channel defines the channel where the texture array must be set
  87014. * @param uniform defines the associated uniform location
  87015. * @param textures defines the array of textures to bind
  87016. */
  87017. setTextureArray(channel: number, uniform: Nullable<WebGLUniformLocation>, textures: BaseTexture[]): void;
  87018. /** @hidden */
  87019. _setAnisotropicLevel(target: number, texture: BaseTexture): void;
  87020. private _setTextureParameterFloat;
  87021. private _setTextureParameterInteger;
  87022. /**
  87023. * Reads pixels from the current frame buffer. Please note that this function can be slow
  87024. * @param x defines the x coordinate of the rectangle where pixels must be read
  87025. * @param y defines the y coordinate of the rectangle where pixels must be read
  87026. * @param width defines the width of the rectangle where pixels must be read
  87027. * @param height defines the height of the rectangle where pixels must be read
  87028. * @returns a Uint8Array containing RGBA colors
  87029. */
  87030. readPixels(x: number, y: number, width: number, height: number): Uint8Array;
  87031. /**
  87032. * Add an externaly attached data from its key.
  87033. * This method call will fail and return false, if such key already exists.
  87034. * If you don't care and just want to get the data no matter what, use the more convenient getOrAddExternalDataWithFactory() method.
  87035. * @param key the unique key that identifies the data
  87036. * @param data the data object to associate to the key for this Engine instance
  87037. * @return true if no such key were already present and the data was added successfully, false otherwise
  87038. */
  87039. addExternalData<T>(key: string, data: T): boolean;
  87040. /**
  87041. * Get an externaly attached data from its key
  87042. * @param key the unique key that identifies the data
  87043. * @return the associated data, if present (can be null), or undefined if not present
  87044. */
  87045. getExternalData<T>(key: string): T;
  87046. /**
  87047. * Get an externaly attached data from its key, create it using a factory if it's not already present
  87048. * @param key the unique key that identifies the data
  87049. * @param factory the factory that will be called to create the instance if and only if it doesn't exists
  87050. * @return the associated data, can be null if the factory returned null.
  87051. */
  87052. getOrAddExternalDataWithFactory<T>(key: string, factory: (k: string) => T): T;
  87053. /**
  87054. * Remove an externaly attached data from the Engine instance
  87055. * @param key the unique key that identifies the data
  87056. * @return true if the data was successfully removed, false if it doesn't exist
  87057. */
  87058. removeExternalData(key: string): boolean;
  87059. /**
  87060. * Unbind all vertex attributes from the webGL context
  87061. */
  87062. unbindAllAttributes(): void;
  87063. /**
  87064. * 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
  87065. */
  87066. releaseEffects(): void;
  87067. /**
  87068. * Dispose and release all associated resources
  87069. */
  87070. dispose(): void;
  87071. /**
  87072. * Display the loading screen
  87073. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  87074. */
  87075. displayLoadingUI(): void;
  87076. /**
  87077. * Hide the loading screen
  87078. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  87079. */
  87080. hideLoadingUI(): void;
  87081. /**
  87082. * Gets the current loading screen object
  87083. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  87084. */
  87085. /**
  87086. * Sets the current loading screen object
  87087. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  87088. */
  87089. loadingScreen: ILoadingScreen;
  87090. /**
  87091. * Sets the current loading screen text
  87092. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  87093. */
  87094. loadingUIText: string;
  87095. /**
  87096. * Sets the current loading screen background color
  87097. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  87098. */
  87099. loadingUIBackgroundColor: string;
  87100. /**
  87101. * Attach a new callback raised when context lost event is fired
  87102. * @param callback defines the callback to call
  87103. */
  87104. attachContextLostEvent(callback: ((event: WebGLContextEvent) => void)): void;
  87105. /**
  87106. * Attach a new callback raised when context restored event is fired
  87107. * @param callback defines the callback to call
  87108. */
  87109. attachContextRestoredEvent(callback: ((event: WebGLContextEvent) => void)): void;
  87110. /**
  87111. * Gets the source code of the vertex shader associated with a specific webGL program
  87112. * @param program defines the program to use
  87113. * @returns a string containing the source code of the vertex shader associated with the program
  87114. */
  87115. getVertexShaderSource(program: WebGLProgram): Nullable<string>;
  87116. /**
  87117. * Gets the source code of the fragment shader associated with a specific webGL program
  87118. * @param program defines the program to use
  87119. * @returns a string containing the source code of the fragment shader associated with the program
  87120. */
  87121. getFragmentShaderSource(program: WebGLProgram): Nullable<string>;
  87122. /**
  87123. * Get the current error code of the webGL context
  87124. * @returns the error code
  87125. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  87126. */
  87127. getError(): number;
  87128. /**
  87129. * Gets the current framerate
  87130. * @returns a number representing the framerate
  87131. */
  87132. getFps(): number;
  87133. /**
  87134. * Gets the time spent between current and previous frame
  87135. * @returns a number representing the delta time in ms
  87136. */
  87137. getDeltaTime(): number;
  87138. private _measureFps;
  87139. /** @hidden */
  87140. _readTexturePixels(texture: InternalTexture, width: number, height: number, faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>): ArrayBufferView;
  87141. private _canRenderToFloatFramebuffer;
  87142. private _canRenderToHalfFloatFramebuffer;
  87143. private _canRenderToFramebuffer;
  87144. /** @hidden */
  87145. _getWebGLTextureType(type: number): number;
  87146. private _getInternalFormat;
  87147. /** @hidden */
  87148. _getRGBABufferInternalSizedFormat(type: number, format?: number): number;
  87149. /** @hidden */
  87150. _getRGBAMultiSampleBufferFormat(type: number): number;
  87151. /** @hidden */
  87152. _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;
  87153. /** @hidden */
  87154. _loadFileAsync(url: string, offlineProvider?: IOfflineProvider, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  87155. private _partialLoadFile;
  87156. private _cascadeLoadFiles;
  87157. /**
  87158. * Gets a boolean indicating if the engine can be instanciated (ie. if a webGL context can be found)
  87159. * @returns true if the engine can be created
  87160. * @ignorenaming
  87161. */
  87162. static isSupported(): boolean;
  87163. }
  87164. }
  87165. declare module BABYLON {
  87166. /**
  87167. * EffectFallbacks can be used to add fallbacks (properties to disable) to certain properties when desired to improve performance.
  87168. * (Eg. Start at high quality with reflection and fog, if fps is low, remove reflection, if still low remove fog)
  87169. */
  87170. export class EffectFallbacks {
  87171. private _defines;
  87172. private _currentRank;
  87173. private _maxRank;
  87174. private _mesh;
  87175. /**
  87176. * Removes the fallback from the bound mesh.
  87177. */
  87178. unBindMesh(): void;
  87179. /**
  87180. * Adds a fallback on the specified property.
  87181. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  87182. * @param define The name of the define in the shader
  87183. */
  87184. addFallback(rank: number, define: string): void;
  87185. /**
  87186. * Sets the mesh to use CPU skinning when needing to fallback.
  87187. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  87188. * @param mesh The mesh to use the fallbacks.
  87189. */
  87190. addCPUSkinningFallback(rank: number, mesh: AbstractMesh): void;
  87191. /**
  87192. * Checks to see if more fallbacks are still availible.
  87193. */
  87194. readonly isMoreFallbacks: boolean;
  87195. /**
  87196. * Removes the defines that shoould be removed when falling back.
  87197. * @param currentDefines defines the current define statements for the shader.
  87198. * @param effect defines the current effect we try to compile
  87199. * @returns The resulting defines with defines of the current rank removed.
  87200. */
  87201. reduce(currentDefines: string, effect: Effect): string;
  87202. }
  87203. /**
  87204. * Options to be used when creating an effect.
  87205. */
  87206. export class EffectCreationOptions {
  87207. /**
  87208. * Atrributes that will be used in the shader.
  87209. */
  87210. attributes: string[];
  87211. /**
  87212. * Uniform varible names that will be set in the shader.
  87213. */
  87214. uniformsNames: string[];
  87215. /**
  87216. * Uniform buffer varible names that will be set in the shader.
  87217. */
  87218. uniformBuffersNames: string[];
  87219. /**
  87220. * Sampler texture variable names that will be set in the shader.
  87221. */
  87222. samplers: string[];
  87223. /**
  87224. * Define statements that will be set in the shader.
  87225. */
  87226. defines: any;
  87227. /**
  87228. * Possible fallbacks for this effect to improve performance when needed.
  87229. */
  87230. fallbacks: Nullable<EffectFallbacks>;
  87231. /**
  87232. * Callback that will be called when the shader is compiled.
  87233. */
  87234. onCompiled: Nullable<(effect: Effect) => void>;
  87235. /**
  87236. * Callback that will be called if an error occurs during shader compilation.
  87237. */
  87238. onError: Nullable<(effect: Effect, errors: string) => void>;
  87239. /**
  87240. * Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  87241. */
  87242. indexParameters: any;
  87243. /**
  87244. * Max number of lights that can be used in the shader.
  87245. */
  87246. maxSimultaneousLights: number;
  87247. /**
  87248. * See https://developer.mozilla.org/en-US/docs/Web/API/WebGL2RenderingContext/transformFeedbackVaryings
  87249. */
  87250. transformFeedbackVaryings: Nullable<string[]>;
  87251. }
  87252. /**
  87253. * Effect containing vertex and fragment shader that can be executed on an object.
  87254. */
  87255. export class Effect {
  87256. /**
  87257. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  87258. */
  87259. static ShadersRepository: string;
  87260. /**
  87261. * Name of the effect.
  87262. */
  87263. name: any;
  87264. /**
  87265. * String container all the define statements that should be set on the shader.
  87266. */
  87267. defines: string;
  87268. /**
  87269. * Callback that will be called when the shader is compiled.
  87270. */
  87271. onCompiled: Nullable<(effect: Effect) => void>;
  87272. /**
  87273. * Callback that will be called if an error occurs during shader compilation.
  87274. */
  87275. onError: Nullable<(effect: Effect, errors: string) => void>;
  87276. /**
  87277. * Callback that will be called when effect is bound.
  87278. */
  87279. onBind: Nullable<(effect: Effect) => void>;
  87280. /**
  87281. * Unique ID of the effect.
  87282. */
  87283. uniqueId: number;
  87284. /**
  87285. * Observable that will be called when the shader is compiled.
  87286. * It is recommended to use executeWhenCompile() or to make sure that scene.isReady() is called to get this observable raised.
  87287. */
  87288. onCompileObservable: Observable<Effect>;
  87289. /**
  87290. * Observable that will be called if an error occurs during shader compilation.
  87291. */
  87292. onErrorObservable: Observable<Effect>;
  87293. /** @hidden */
  87294. _onBindObservable: Nullable<Observable<Effect>>;
  87295. /**
  87296. * Observable that will be called when effect is bound.
  87297. */
  87298. readonly onBindObservable: Observable<Effect>;
  87299. /** @hidden */
  87300. _bonesComputationForcedToCPU: boolean;
  87301. private static _uniqueIdSeed;
  87302. private _engine;
  87303. private _uniformBuffersNames;
  87304. private _uniformsNames;
  87305. private _samplers;
  87306. private _isReady;
  87307. private _compilationError;
  87308. private _attributesNames;
  87309. private _attributes;
  87310. private _uniforms;
  87311. /**
  87312. * Key for the effect.
  87313. * @hidden
  87314. */
  87315. _key: string;
  87316. private _indexParameters;
  87317. private _fallbacks;
  87318. private _vertexSourceCode;
  87319. private _fragmentSourceCode;
  87320. private _vertexSourceCodeOverride;
  87321. private _fragmentSourceCodeOverride;
  87322. private _transformFeedbackVaryings;
  87323. /**
  87324. * Compiled shader to webGL program.
  87325. * @hidden
  87326. */
  87327. _program: WebGLProgram;
  87328. private _valueCache;
  87329. private static _baseCache;
  87330. /**
  87331. * Instantiates an effect.
  87332. * An effect can be used to create/manage/execute vertex and fragment shaders.
  87333. * @param baseName Name of the effect.
  87334. * @param attributesNamesOrOptions List of attribute names that will be passed to the shader or set of all options to create the effect.
  87335. * @param uniformsNamesOrEngine List of uniform variable names that will be passed to the shader or the engine that will be used to render effect.
  87336. * @param samplers List of sampler variables that will be passed to the shader.
  87337. * @param engine Engine to be used to render the effect
  87338. * @param defines Define statements to be added to the shader.
  87339. * @param fallbacks Possible fallbacks for this effect to improve performance when needed.
  87340. * @param onCompiled Callback that will be called when the shader is compiled.
  87341. * @param onError Callback that will be called if an error occurs during shader compilation.
  87342. * @param indexParameters Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  87343. */
  87344. 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);
  87345. /**
  87346. * Unique key for this effect
  87347. */
  87348. readonly key: string;
  87349. /**
  87350. * If the effect has been compiled and prepared.
  87351. * @returns if the effect is compiled and prepared.
  87352. */
  87353. isReady(): boolean;
  87354. /**
  87355. * The engine the effect was initialized with.
  87356. * @returns the engine.
  87357. */
  87358. getEngine(): Engine;
  87359. /**
  87360. * The compiled webGL program for the effect
  87361. * @returns the webGL program.
  87362. */
  87363. getProgram(): WebGLProgram;
  87364. /**
  87365. * The set of names of attribute variables for the shader.
  87366. * @returns An array of attribute names.
  87367. */
  87368. getAttributesNames(): string[];
  87369. /**
  87370. * Returns the attribute at the given index.
  87371. * @param index The index of the attribute.
  87372. * @returns The location of the attribute.
  87373. */
  87374. getAttributeLocation(index: number): number;
  87375. /**
  87376. * Returns the attribute based on the name of the variable.
  87377. * @param name of the attribute to look up.
  87378. * @returns the attribute location.
  87379. */
  87380. getAttributeLocationByName(name: string): number;
  87381. /**
  87382. * The number of attributes.
  87383. * @returns the numnber of attributes.
  87384. */
  87385. getAttributesCount(): number;
  87386. /**
  87387. * Gets the index of a uniform variable.
  87388. * @param uniformName of the uniform to look up.
  87389. * @returns the index.
  87390. */
  87391. getUniformIndex(uniformName: string): number;
  87392. /**
  87393. * Returns the attribute based on the name of the variable.
  87394. * @param uniformName of the uniform to look up.
  87395. * @returns the location of the uniform.
  87396. */
  87397. getUniform(uniformName: string): Nullable<WebGLUniformLocation>;
  87398. /**
  87399. * Returns an array of sampler variable names
  87400. * @returns The array of sampler variable neames.
  87401. */
  87402. getSamplers(): string[];
  87403. /**
  87404. * The error from the last compilation.
  87405. * @returns the error string.
  87406. */
  87407. getCompilationError(): string;
  87408. /**
  87409. * Adds a callback to the onCompiled observable and call the callback imediatly if already ready.
  87410. * @param func The callback to be used.
  87411. */
  87412. executeWhenCompiled(func: (effect: Effect) => void): void;
  87413. private _checkIsReady;
  87414. /** @hidden */
  87415. _loadVertexShader(vertex: any, callback: (data: any) => void): void;
  87416. /** @hidden */
  87417. _loadFragmentShader(fragment: any, callback: (data: any) => void): void;
  87418. /** @hidden */
  87419. _dumpShadersSource(vertexCode: string, fragmentCode: string, defines: string): void;
  87420. private _processShaderConversion;
  87421. private _processIncludes;
  87422. private _processPrecision;
  87423. /**
  87424. * Recompiles the webGL program
  87425. * @param vertexSourceCode The source code for the vertex shader.
  87426. * @param fragmentSourceCode The source code for the fragment shader.
  87427. * @param onCompiled Callback called when completed.
  87428. * @param onError Callback called on error.
  87429. * @hidden
  87430. */
  87431. _rebuildProgram(vertexSourceCode: string, fragmentSourceCode: string, onCompiled: (program: WebGLProgram) => void, onError: (message: string) => void): void;
  87432. /**
  87433. * Gets the uniform locations of the the specified variable names
  87434. * @param names THe names of the variables to lookup.
  87435. * @returns Array of locations in the same order as variable names.
  87436. */
  87437. getSpecificUniformLocations(names: string[]): Nullable<WebGLUniformLocation>[];
  87438. /**
  87439. * Prepares the effect
  87440. * @hidden
  87441. */
  87442. _prepareEffect(): void;
  87443. /**
  87444. * Checks if the effect is supported. (Must be called after compilation)
  87445. */
  87446. readonly isSupported: boolean;
  87447. /**
  87448. * Binds a texture to the engine to be used as output of the shader.
  87449. * @param channel Name of the output variable.
  87450. * @param texture Texture to bind.
  87451. * @hidden
  87452. */
  87453. _bindTexture(channel: string, texture: InternalTexture): void;
  87454. /**
  87455. * Sets a texture on the engine to be used in the shader.
  87456. * @param channel Name of the sampler variable.
  87457. * @param texture Texture to set.
  87458. */
  87459. setTexture(channel: string, texture: Nullable<BaseTexture>): void;
  87460. /**
  87461. * Sets a depth stencil texture from a render target on the engine to be used in the shader.
  87462. * @param channel Name of the sampler variable.
  87463. * @param texture Texture to set.
  87464. */
  87465. setDepthStencilTexture(channel: string, texture: Nullable<RenderTargetTexture>): void;
  87466. /**
  87467. * Sets an array of textures on the engine to be used in the shader.
  87468. * @param channel Name of the variable.
  87469. * @param textures Textures to set.
  87470. */
  87471. setTextureArray(channel: string, textures: BaseTexture[]): void;
  87472. /**
  87473. * 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)
  87474. * @param channel Name of the sampler variable.
  87475. * @param postProcess Post process to get the input texture from.
  87476. */
  87477. setTextureFromPostProcess(channel: string, postProcess: Nullable<PostProcess>): void;
  87478. /**
  87479. * (Warning! setTextureFromPostProcessOutput may be desired instead)
  87480. * 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)
  87481. * @param channel Name of the sampler variable.
  87482. * @param postProcess Post process to get the output texture from.
  87483. */
  87484. setTextureFromPostProcessOutput(channel: string, postProcess: Nullable<PostProcess>): void;
  87485. /** @hidden */
  87486. _cacheMatrix(uniformName: string, matrix: Matrix): boolean;
  87487. /** @hidden */
  87488. _cacheFloat2(uniformName: string, x: number, y: number): boolean;
  87489. /** @hidden */
  87490. _cacheFloat3(uniformName: string, x: number, y: number, z: number): boolean;
  87491. /** @hidden */
  87492. _cacheFloat4(uniformName: string, x: number, y: number, z: number, w: number): boolean;
  87493. /**
  87494. * Binds a buffer to a uniform.
  87495. * @param buffer Buffer to bind.
  87496. * @param name Name of the uniform variable to bind to.
  87497. */
  87498. bindUniformBuffer(buffer: WebGLBuffer, name: string): void;
  87499. /**
  87500. * Binds block to a uniform.
  87501. * @param blockName Name of the block to bind.
  87502. * @param index Index to bind.
  87503. */
  87504. bindUniformBlock(blockName: string, index: number): void;
  87505. /**
  87506. * Sets an interger value on a uniform variable.
  87507. * @param uniformName Name of the variable.
  87508. * @param value Value to be set.
  87509. * @returns this effect.
  87510. */
  87511. setInt(uniformName: string, value: number): Effect;
  87512. /**
  87513. * Sets an int array on a uniform variable.
  87514. * @param uniformName Name of the variable.
  87515. * @param array array to be set.
  87516. * @returns this effect.
  87517. */
  87518. setIntArray(uniformName: string, array: Int32Array): Effect;
  87519. /**
  87520. * 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)
  87521. * @param uniformName Name of the variable.
  87522. * @param array array to be set.
  87523. * @returns this effect.
  87524. */
  87525. setIntArray2(uniformName: string, array: Int32Array): Effect;
  87526. /**
  87527. * 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)
  87528. * @param uniformName Name of the variable.
  87529. * @param array array to be set.
  87530. * @returns this effect.
  87531. */
  87532. setIntArray3(uniformName: string, array: Int32Array): Effect;
  87533. /**
  87534. * 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)
  87535. * @param uniformName Name of the variable.
  87536. * @param array array to be set.
  87537. * @returns this effect.
  87538. */
  87539. setIntArray4(uniformName: string, array: Int32Array): Effect;
  87540. /**
  87541. * Sets an float array on a uniform variable.
  87542. * @param uniformName Name of the variable.
  87543. * @param array array to be set.
  87544. * @returns this effect.
  87545. */
  87546. setFloatArray(uniformName: string, array: Float32Array): Effect;
  87547. /**
  87548. * 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)
  87549. * @param uniformName Name of the variable.
  87550. * @param array array to be set.
  87551. * @returns this effect.
  87552. */
  87553. setFloatArray2(uniformName: string, array: Float32Array): Effect;
  87554. /**
  87555. * 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)
  87556. * @param uniformName Name of the variable.
  87557. * @param array array to be set.
  87558. * @returns this effect.
  87559. */
  87560. setFloatArray3(uniformName: string, array: Float32Array): Effect;
  87561. /**
  87562. * 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)
  87563. * @param uniformName Name of the variable.
  87564. * @param array array to be set.
  87565. * @returns this effect.
  87566. */
  87567. setFloatArray4(uniformName: string, array: Float32Array): Effect;
  87568. /**
  87569. * Sets an array on a uniform variable.
  87570. * @param uniformName Name of the variable.
  87571. * @param array array to be set.
  87572. * @returns this effect.
  87573. */
  87574. setArray(uniformName: string, array: number[]): Effect;
  87575. /**
  87576. * 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)
  87577. * @param uniformName Name of the variable.
  87578. * @param array array to be set.
  87579. * @returns this effect.
  87580. */
  87581. setArray2(uniformName: string, array: number[]): Effect;
  87582. /**
  87583. * 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)
  87584. * @param uniformName Name of the variable.
  87585. * @param array array to be set.
  87586. * @returns this effect.
  87587. */
  87588. setArray3(uniformName: string, array: number[]): Effect;
  87589. /**
  87590. * 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)
  87591. * @param uniformName Name of the variable.
  87592. * @param array array to be set.
  87593. * @returns this effect.
  87594. */
  87595. setArray4(uniformName: string, array: number[]): Effect;
  87596. /**
  87597. * Sets matrices on a uniform variable.
  87598. * @param uniformName Name of the variable.
  87599. * @param matrices matrices to be set.
  87600. * @returns this effect.
  87601. */
  87602. setMatrices(uniformName: string, matrices: Float32Array): Effect;
  87603. /**
  87604. * Sets matrix on a uniform variable.
  87605. * @param uniformName Name of the variable.
  87606. * @param matrix matrix to be set.
  87607. * @returns this effect.
  87608. */
  87609. setMatrix(uniformName: string, matrix: Matrix): Effect;
  87610. /**
  87611. * 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)
  87612. * @param uniformName Name of the variable.
  87613. * @param matrix matrix to be set.
  87614. * @returns this effect.
  87615. */
  87616. setMatrix3x3(uniformName: string, matrix: Float32Array): Effect;
  87617. /**
  87618. * Sets a 2x2 matrix on a uniform variable. (Speicified as [1,2,3,4] will result in [1,2][3,4] matrix)
  87619. * @param uniformName Name of the variable.
  87620. * @param matrix matrix to be set.
  87621. * @returns this effect.
  87622. */
  87623. setMatrix2x2(uniformName: string, matrix: Float32Array): Effect;
  87624. /**
  87625. * Sets a float on a uniform variable.
  87626. * @param uniformName Name of the variable.
  87627. * @param value value to be set.
  87628. * @returns this effect.
  87629. */
  87630. setFloat(uniformName: string, value: number): Effect;
  87631. /**
  87632. * Sets a boolean on a uniform variable.
  87633. * @param uniformName Name of the variable.
  87634. * @param bool value to be set.
  87635. * @returns this effect.
  87636. */
  87637. setBool(uniformName: string, bool: boolean): Effect;
  87638. /**
  87639. * Sets a Vector2 on a uniform variable.
  87640. * @param uniformName Name of the variable.
  87641. * @param vector2 vector2 to be set.
  87642. * @returns this effect.
  87643. */
  87644. setVector2(uniformName: string, vector2: Vector2): Effect;
  87645. /**
  87646. * Sets a float2 on a uniform variable.
  87647. * @param uniformName Name of the variable.
  87648. * @param x First float in float2.
  87649. * @param y Second float in float2.
  87650. * @returns this effect.
  87651. */
  87652. setFloat2(uniformName: string, x: number, y: number): Effect;
  87653. /**
  87654. * Sets a Vector3 on a uniform variable.
  87655. * @param uniformName Name of the variable.
  87656. * @param vector3 Value to be set.
  87657. * @returns this effect.
  87658. */
  87659. setVector3(uniformName: string, vector3: Vector3): Effect;
  87660. /**
  87661. * Sets a float3 on a uniform variable.
  87662. * @param uniformName Name of the variable.
  87663. * @param x First float in float3.
  87664. * @param y Second float in float3.
  87665. * @param z Third float in float3.
  87666. * @returns this effect.
  87667. */
  87668. setFloat3(uniformName: string, x: number, y: number, z: number): Effect;
  87669. /**
  87670. * Sets a Vector4 on a uniform variable.
  87671. * @param uniformName Name of the variable.
  87672. * @param vector4 Value to be set.
  87673. * @returns this effect.
  87674. */
  87675. setVector4(uniformName: string, vector4: Vector4): Effect;
  87676. /**
  87677. * Sets a float4 on a uniform variable.
  87678. * @param uniformName Name of the variable.
  87679. * @param x First float in float4.
  87680. * @param y Second float in float4.
  87681. * @param z Third float in float4.
  87682. * @param w Fourth float in float4.
  87683. * @returns this effect.
  87684. */
  87685. setFloat4(uniformName: string, x: number, y: number, z: number, w: number): Effect;
  87686. /**
  87687. * Sets a Color3 on a uniform variable.
  87688. * @param uniformName Name of the variable.
  87689. * @param color3 Value to be set.
  87690. * @returns this effect.
  87691. */
  87692. setColor3(uniformName: string, color3: Color3): Effect;
  87693. /**
  87694. * Sets a Color4 on a uniform variable.
  87695. * @param uniformName Name of the variable.
  87696. * @param color3 Value to be set.
  87697. * @param alpha Alpha value to be set.
  87698. * @returns this effect.
  87699. */
  87700. setColor4(uniformName: string, color3: Color3, alpha: number): Effect;
  87701. /**
  87702. * Sets a Color4 on a uniform variable
  87703. * @param uniformName defines the name of the variable
  87704. * @param color4 defines the value to be set
  87705. * @returns this effect.
  87706. */
  87707. setDirectColor4(uniformName: string, color4: Color4): Effect;
  87708. /**
  87709. * This function will add a new shader to the shader store
  87710. * @param name the name of the shader
  87711. * @param pixelShader optional pixel shader content
  87712. * @param vertexShader optional vertex shader content
  87713. */
  87714. static RegisterShader(name: string, pixelShader?: string, vertexShader?: string): void;
  87715. /**
  87716. * Store of each shader (The can be looked up using effect.key)
  87717. */
  87718. static ShadersStore: {
  87719. [key: string]: string;
  87720. };
  87721. /**
  87722. * Store of each included file for a shader (The can be looked up using effect.key)
  87723. */
  87724. static IncludesShadersStore: {
  87725. [key: string]: string;
  87726. };
  87727. /**
  87728. * Resets the cache of effects.
  87729. */
  87730. static ResetCache(): void;
  87731. }
  87732. }
  87733. declare module BABYLON {
  87734. /**
  87735. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  87736. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  87737. * 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;
  87738. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  87739. */
  87740. export class ColorCurves {
  87741. private _dirty;
  87742. private _tempColor;
  87743. private _globalCurve;
  87744. private _highlightsCurve;
  87745. private _midtonesCurve;
  87746. private _shadowsCurve;
  87747. private _positiveCurve;
  87748. private _negativeCurve;
  87749. private _globalHue;
  87750. private _globalDensity;
  87751. private _globalSaturation;
  87752. private _globalExposure;
  87753. /**
  87754. * Gets the global Hue value.
  87755. * 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).
  87756. */
  87757. /**
  87758. * Sets the global Hue value.
  87759. * 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).
  87760. */
  87761. globalHue: number;
  87762. /**
  87763. * Gets the global Density value.
  87764. * 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.
  87765. * Values less than zero provide a filter of opposite hue.
  87766. */
  87767. /**
  87768. * Sets the global Density value.
  87769. * 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.
  87770. * Values less than zero provide a filter of opposite hue.
  87771. */
  87772. globalDensity: number;
  87773. /**
  87774. * Gets the global Saturation value.
  87775. * 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.
  87776. */
  87777. /**
  87778. * Sets the global Saturation value.
  87779. * 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.
  87780. */
  87781. globalSaturation: number;
  87782. /**
  87783. * Gets the global Exposure value.
  87784. * 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.
  87785. */
  87786. /**
  87787. * Sets the global Exposure value.
  87788. * 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.
  87789. */
  87790. globalExposure: number;
  87791. private _highlightsHue;
  87792. private _highlightsDensity;
  87793. private _highlightsSaturation;
  87794. private _highlightsExposure;
  87795. /**
  87796. * Gets the highlights Hue value.
  87797. * 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).
  87798. */
  87799. /**
  87800. * Sets the highlights Hue value.
  87801. * 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).
  87802. */
  87803. highlightsHue: number;
  87804. /**
  87805. * Gets the highlights Density value.
  87806. * 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.
  87807. * Values less than zero provide a filter of opposite hue.
  87808. */
  87809. /**
  87810. * Sets the highlights Density value.
  87811. * 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.
  87812. * Values less than zero provide a filter of opposite hue.
  87813. */
  87814. highlightsDensity: number;
  87815. /**
  87816. * Gets the highlights Saturation value.
  87817. * 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.
  87818. */
  87819. /**
  87820. * Sets the highlights Saturation value.
  87821. * 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.
  87822. */
  87823. highlightsSaturation: number;
  87824. /**
  87825. * Gets the highlights Exposure value.
  87826. * 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.
  87827. */
  87828. /**
  87829. * Sets the highlights Exposure value.
  87830. * 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.
  87831. */
  87832. highlightsExposure: number;
  87833. private _midtonesHue;
  87834. private _midtonesDensity;
  87835. private _midtonesSaturation;
  87836. private _midtonesExposure;
  87837. /**
  87838. * Gets the midtones Hue value.
  87839. * 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).
  87840. */
  87841. /**
  87842. * Sets the midtones Hue value.
  87843. * 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).
  87844. */
  87845. midtonesHue: number;
  87846. /**
  87847. * Gets the midtones Density value.
  87848. * 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.
  87849. * Values less than zero provide a filter of opposite hue.
  87850. */
  87851. /**
  87852. * Sets the midtones Density value.
  87853. * 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.
  87854. * Values less than zero provide a filter of opposite hue.
  87855. */
  87856. midtonesDensity: number;
  87857. /**
  87858. * Gets the midtones Saturation value.
  87859. * 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.
  87860. */
  87861. /**
  87862. * Sets the midtones Saturation value.
  87863. * 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.
  87864. */
  87865. midtonesSaturation: number;
  87866. /**
  87867. * Gets the midtones Exposure value.
  87868. * 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.
  87869. */
  87870. /**
  87871. * Sets the midtones Exposure value.
  87872. * 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.
  87873. */
  87874. midtonesExposure: number;
  87875. private _shadowsHue;
  87876. private _shadowsDensity;
  87877. private _shadowsSaturation;
  87878. private _shadowsExposure;
  87879. /**
  87880. * Gets the shadows Hue value.
  87881. * 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).
  87882. */
  87883. /**
  87884. * Sets the shadows Hue value.
  87885. * 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).
  87886. */
  87887. shadowsHue: number;
  87888. /**
  87889. * Gets the shadows Density value.
  87890. * 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.
  87891. * Values less than zero provide a filter of opposite hue.
  87892. */
  87893. /**
  87894. * Sets the shadows Density value.
  87895. * 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.
  87896. * Values less than zero provide a filter of opposite hue.
  87897. */
  87898. shadowsDensity: number;
  87899. /**
  87900. * Gets the shadows Saturation value.
  87901. * 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.
  87902. */
  87903. /**
  87904. * Sets the shadows Saturation value.
  87905. * 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.
  87906. */
  87907. shadowsSaturation: number;
  87908. /**
  87909. * Gets the shadows Exposure value.
  87910. * 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.
  87911. */
  87912. /**
  87913. * Sets the shadows Exposure value.
  87914. * 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.
  87915. */
  87916. shadowsExposure: number;
  87917. /**
  87918. * Returns the class name
  87919. * @returns The class name
  87920. */
  87921. getClassName(): string;
  87922. /**
  87923. * Binds the color curves to the shader.
  87924. * @param colorCurves The color curve to bind
  87925. * @param effect The effect to bind to
  87926. * @param positiveUniform The positive uniform shader parameter
  87927. * @param neutralUniform The neutral uniform shader parameter
  87928. * @param negativeUniform The negative uniform shader parameter
  87929. */
  87930. static Bind(colorCurves: ColorCurves, effect: Effect, positiveUniform?: string, neutralUniform?: string, negativeUniform?: string): void;
  87931. /**
  87932. * Prepare the list of uniforms associated with the ColorCurves effects.
  87933. * @param uniformsList The list of uniforms used in the effect
  87934. */
  87935. static PrepareUniforms(uniformsList: string[]): void;
  87936. /**
  87937. * Returns color grading data based on a hue, density, saturation and exposure value.
  87938. * @param filterHue The hue of the color filter.
  87939. * @param filterDensity The density of the color filter.
  87940. * @param saturation The saturation.
  87941. * @param exposure The exposure.
  87942. * @param result The result data container.
  87943. */
  87944. private getColorGradingDataToRef;
  87945. /**
  87946. * Takes an input slider value and returns an adjusted value that provides extra control near the centre.
  87947. * @param value The input slider value in range [-100,100].
  87948. * @returns Adjusted value.
  87949. */
  87950. private static applyColorGradingSliderNonlinear;
  87951. /**
  87952. * Returns an RGBA Color4 based on Hue, Saturation and Brightness (also referred to as value, HSV).
  87953. * @param hue The hue (H) input.
  87954. * @param saturation The saturation (S) input.
  87955. * @param brightness The brightness (B) input.
  87956. * @result An RGBA color represented as Vector4.
  87957. */
  87958. private static fromHSBToRef;
  87959. /**
  87960. * Returns a value clamped between min and max
  87961. * @param value The value to clamp
  87962. * @param min The minimum of value
  87963. * @param max The maximum of value
  87964. * @returns The clamped value.
  87965. */
  87966. private static clamp;
  87967. /**
  87968. * Clones the current color curve instance.
  87969. * @return The cloned curves
  87970. */
  87971. clone(): ColorCurves;
  87972. /**
  87973. * Serializes the current color curve instance to a json representation.
  87974. * @return a JSON representation
  87975. */
  87976. serialize(): any;
  87977. /**
  87978. * Parses the color curve from a json representation.
  87979. * @param source the JSON source to parse
  87980. * @return The parsed curves
  87981. */
  87982. static Parse(source: any): ColorCurves;
  87983. }
  87984. }
  87985. declare module BABYLON {
  87986. /**
  87987. * Interface to follow in your material defines to integrate easily the
  87988. * Image proccessing functions.
  87989. * @hidden
  87990. */
  87991. export interface IImageProcessingConfigurationDefines {
  87992. IMAGEPROCESSING: boolean;
  87993. VIGNETTE: boolean;
  87994. VIGNETTEBLENDMODEMULTIPLY: boolean;
  87995. VIGNETTEBLENDMODEOPAQUE: boolean;
  87996. TONEMAPPING: boolean;
  87997. TONEMAPPING_ACES: boolean;
  87998. CONTRAST: boolean;
  87999. EXPOSURE: boolean;
  88000. COLORCURVES: boolean;
  88001. COLORGRADING: boolean;
  88002. COLORGRADING3D: boolean;
  88003. SAMPLER3DGREENDEPTH: boolean;
  88004. SAMPLER3DBGRMAP: boolean;
  88005. IMAGEPROCESSINGPOSTPROCESS: boolean;
  88006. }
  88007. /**
  88008. * @hidden
  88009. */
  88010. export class ImageProcessingConfigurationDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  88011. IMAGEPROCESSING: boolean;
  88012. VIGNETTE: boolean;
  88013. VIGNETTEBLENDMODEMULTIPLY: boolean;
  88014. VIGNETTEBLENDMODEOPAQUE: boolean;
  88015. TONEMAPPING: boolean;
  88016. TONEMAPPING_ACES: boolean;
  88017. CONTRAST: boolean;
  88018. COLORCURVES: boolean;
  88019. COLORGRADING: boolean;
  88020. COLORGRADING3D: boolean;
  88021. SAMPLER3DGREENDEPTH: boolean;
  88022. SAMPLER3DBGRMAP: boolean;
  88023. IMAGEPROCESSINGPOSTPROCESS: boolean;
  88024. EXPOSURE: boolean;
  88025. constructor();
  88026. }
  88027. /**
  88028. * This groups together the common properties used for image processing either in direct forward pass
  88029. * or through post processing effect depending on the use of the image processing pipeline in your scene
  88030. * or not.
  88031. */
  88032. export class ImageProcessingConfiguration {
  88033. /**
  88034. * Default tone mapping applied in BabylonJS.
  88035. */
  88036. static readonly TONEMAPPING_STANDARD: number;
  88037. /**
  88038. * ACES Tone mapping (used by default in unreal and unity). This can help getting closer
  88039. * to other engines rendering to increase portability.
  88040. */
  88041. static readonly TONEMAPPING_ACES: number;
  88042. /**
  88043. * Color curves setup used in the effect if colorCurvesEnabled is set to true
  88044. */
  88045. colorCurves: Nullable<ColorCurves>;
  88046. private _colorCurvesEnabled;
  88047. /**
  88048. * Gets wether the color curves effect is enabled.
  88049. */
  88050. /**
  88051. * Sets wether the color curves effect is enabled.
  88052. */
  88053. colorCurvesEnabled: boolean;
  88054. private _colorGradingTexture;
  88055. /**
  88056. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  88057. */
  88058. /**
  88059. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  88060. */
  88061. colorGradingTexture: Nullable<BaseTexture>;
  88062. private _colorGradingEnabled;
  88063. /**
  88064. * Gets wether the color grading effect is enabled.
  88065. */
  88066. /**
  88067. * Sets wether the color grading effect is enabled.
  88068. */
  88069. colorGradingEnabled: boolean;
  88070. private _colorGradingWithGreenDepth;
  88071. /**
  88072. * Gets wether the color grading effect is using a green depth for the 3d Texture.
  88073. */
  88074. /**
  88075. * Sets wether the color grading effect is using a green depth for the 3d Texture.
  88076. */
  88077. colorGradingWithGreenDepth: boolean;
  88078. private _colorGradingBGR;
  88079. /**
  88080. * Gets wether the color grading texture contains BGR values.
  88081. */
  88082. /**
  88083. * Sets wether the color grading texture contains BGR values.
  88084. */
  88085. colorGradingBGR: boolean;
  88086. /** @hidden */
  88087. _exposure: number;
  88088. /**
  88089. * Gets the Exposure used in the effect.
  88090. */
  88091. /**
  88092. * Sets the Exposure used in the effect.
  88093. */
  88094. exposure: number;
  88095. private _toneMappingEnabled;
  88096. /**
  88097. * Gets wether the tone mapping effect is enabled.
  88098. */
  88099. /**
  88100. * Sets wether the tone mapping effect is enabled.
  88101. */
  88102. toneMappingEnabled: boolean;
  88103. private _toneMappingType;
  88104. /**
  88105. * Gets the type of tone mapping effect.
  88106. */
  88107. /**
  88108. * Sets the type of tone mapping effect used in BabylonJS.
  88109. */
  88110. toneMappingType: number;
  88111. protected _contrast: number;
  88112. /**
  88113. * Gets the contrast used in the effect.
  88114. */
  88115. /**
  88116. * Sets the contrast used in the effect.
  88117. */
  88118. contrast: number;
  88119. /**
  88120. * Vignette stretch size.
  88121. */
  88122. vignetteStretch: number;
  88123. /**
  88124. * Vignette centre X Offset.
  88125. */
  88126. vignetteCentreX: number;
  88127. /**
  88128. * Vignette centre Y Offset.
  88129. */
  88130. vignetteCentreY: number;
  88131. /**
  88132. * Vignette weight or intensity of the vignette effect.
  88133. */
  88134. vignetteWeight: number;
  88135. /**
  88136. * Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  88137. * if vignetteEnabled is set to true.
  88138. */
  88139. vignetteColor: Color4;
  88140. /**
  88141. * Camera field of view used by the Vignette effect.
  88142. */
  88143. vignetteCameraFov: number;
  88144. private _vignetteBlendMode;
  88145. /**
  88146. * Gets the vignette blend mode allowing different kind of effect.
  88147. */
  88148. /**
  88149. * Sets the vignette blend mode allowing different kind of effect.
  88150. */
  88151. vignetteBlendMode: number;
  88152. private _vignetteEnabled;
  88153. /**
  88154. * Gets wether the vignette effect is enabled.
  88155. */
  88156. /**
  88157. * Sets wether the vignette effect is enabled.
  88158. */
  88159. vignetteEnabled: boolean;
  88160. private _applyByPostProcess;
  88161. /**
  88162. * Gets wether the image processing is applied through a post process or not.
  88163. */
  88164. /**
  88165. * Sets wether the image processing is applied through a post process or not.
  88166. */
  88167. applyByPostProcess: boolean;
  88168. private _isEnabled;
  88169. /**
  88170. * Gets wether the image processing is enabled or not.
  88171. */
  88172. /**
  88173. * Sets wether the image processing is enabled or not.
  88174. */
  88175. isEnabled: boolean;
  88176. /**
  88177. * An event triggered when the configuration changes and requires Shader to Update some parameters.
  88178. */
  88179. onUpdateParameters: Observable<ImageProcessingConfiguration>;
  88180. /**
  88181. * Method called each time the image processing information changes requires to recompile the effect.
  88182. */
  88183. protected _updateParameters(): void;
  88184. /**
  88185. * Gets the current class name.
  88186. * @return "ImageProcessingConfiguration"
  88187. */
  88188. getClassName(): string;
  88189. /**
  88190. * Prepare the list of uniforms associated with the Image Processing effects.
  88191. * @param uniforms The list of uniforms used in the effect
  88192. * @param defines the list of defines currently in use
  88193. */
  88194. static PrepareUniforms(uniforms: string[], defines: IImageProcessingConfigurationDefines): void;
  88195. /**
  88196. * Prepare the list of samplers associated with the Image Processing effects.
  88197. * @param samplersList The list of uniforms used in the effect
  88198. * @param defines the list of defines currently in use
  88199. */
  88200. static PrepareSamplers(samplersList: string[], defines: IImageProcessingConfigurationDefines): void;
  88201. /**
  88202. * Prepare the list of defines associated to the shader.
  88203. * @param defines the list of defines to complete
  88204. * @param forPostProcess Define if we are currently in post process mode or not
  88205. */
  88206. prepareDefines(defines: IImageProcessingConfigurationDefines, forPostProcess?: boolean): void;
  88207. /**
  88208. * Returns true if all the image processing information are ready.
  88209. * @returns True if ready, otherwise, false
  88210. */
  88211. isReady(): boolean;
  88212. /**
  88213. * Binds the image processing to the shader.
  88214. * @param effect The effect to bind to
  88215. * @param aspectRatio Define the current aspect ratio of the effect
  88216. */
  88217. bind(effect: Effect, aspectRatio?: number): void;
  88218. /**
  88219. * Clones the current image processing instance.
  88220. * @return The cloned image processing
  88221. */
  88222. clone(): ImageProcessingConfiguration;
  88223. /**
  88224. * Serializes the current image processing instance to a json representation.
  88225. * @return a JSON representation
  88226. */
  88227. serialize(): any;
  88228. /**
  88229. * Parses the image processing from a json representation.
  88230. * @param source the JSON source to parse
  88231. * @return The parsed image processing
  88232. */
  88233. static Parse(source: any): ImageProcessingConfiguration;
  88234. private static _VIGNETTEMODE_MULTIPLY;
  88235. private static _VIGNETTEMODE_OPAQUE;
  88236. /**
  88237. * Used to apply the vignette as a mix with the pixel color.
  88238. */
  88239. static readonly VIGNETTEMODE_MULTIPLY: number;
  88240. /**
  88241. * Used to apply the vignette as a replacement of the pixel color.
  88242. */
  88243. static readonly VIGNETTEMODE_OPAQUE: number;
  88244. }
  88245. }
  88246. declare module BABYLON {
  88247. /**
  88248. * This represents all the required information to add a fresnel effect on a material:
  88249. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  88250. */
  88251. export class FresnelParameters {
  88252. private _isEnabled;
  88253. /**
  88254. * Define if the fresnel effect is enable or not.
  88255. */
  88256. isEnabled: boolean;
  88257. /**
  88258. * Define the color used on edges (grazing angle)
  88259. */
  88260. leftColor: Color3;
  88261. /**
  88262. * Define the color used on center
  88263. */
  88264. rightColor: Color3;
  88265. /**
  88266. * Define bias applied to computed fresnel term
  88267. */
  88268. bias: number;
  88269. /**
  88270. * Defined the power exponent applied to fresnel term
  88271. */
  88272. power: number;
  88273. /**
  88274. * Clones the current fresnel and its valuues
  88275. * @returns a clone fresnel configuration
  88276. */
  88277. clone(): FresnelParameters;
  88278. /**
  88279. * Serializes the current fresnel parameters to a JSON representation.
  88280. * @return the JSON serialization
  88281. */
  88282. serialize(): any;
  88283. /**
  88284. * Parse a JSON object and deserialize it to a new Fresnel parameter object.
  88285. * @param parsedFresnelParameters Define the JSON representation
  88286. * @returns the parsed parameters
  88287. */
  88288. static Parse(parsedFresnelParameters: any): FresnelParameters;
  88289. }
  88290. }
  88291. declare module BABYLON {
  88292. export function expandToProperty(callback: string, targetKey?: Nullable<string>): (target: any, propertyKey: string) => void;
  88293. export function serialize(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  88294. export function serializeAsTexture(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  88295. export function serializeAsColor3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  88296. export function serializeAsFresnelParameters(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  88297. export function serializeAsVector2(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  88298. export function serializeAsVector3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  88299. export function serializeAsMeshReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  88300. export function serializeAsColorCurves(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  88301. export function serializeAsColor4(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  88302. export function serializeAsImageProcessingConfiguration(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  88303. export function serializeAsQuaternion(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  88304. export function serializeAsMatrix(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  88305. /**
  88306. * Decorator used to define property that can be serialized as reference to a camera
  88307. * @param sourceName defines the name of the property to decorate
  88308. */
  88309. export function serializeAsCameraReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  88310. /**
  88311. * Class used to help serialization objects
  88312. */
  88313. export class SerializationHelper {
  88314. /** hidden */
  88315. static _ImageProcessingConfigurationParser: (sourceProperty: any) => ImageProcessingConfiguration;
  88316. /** hidden */
  88317. static _FresnelParametersParser: (sourceProperty: any) => FresnelParameters;
  88318. /** hidden */
  88319. static _ColorCurvesParser: (sourceProperty: any) => ColorCurves;
  88320. /** hidden */
  88321. static _TextureParser: (sourceProperty: any, scene: Scene, rootUrl: string) => Nullable<BaseTexture>;
  88322. /**
  88323. * Appends the serialized animations from the source animations
  88324. * @param source Source containing the animations
  88325. * @param destination Target to store the animations
  88326. */
  88327. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  88328. /**
  88329. * Static function used to serialized a specific entity
  88330. * @param entity defines the entity to serialize
  88331. * @param serializationObject defines the optional target obecjt where serialization data will be stored
  88332. * @returns a JSON compatible object representing the serialization of the entity
  88333. */
  88334. static Serialize<T>(entity: T, serializationObject?: any): any;
  88335. /**
  88336. * Creates a new entity from a serialization data object
  88337. * @param creationFunction defines a function used to instanciated the new entity
  88338. * @param source defines the source serialization data
  88339. * @param scene defines the hosting scene
  88340. * @param rootUrl defines the root url for resources
  88341. * @returns a new entity
  88342. */
  88343. static Parse<T>(creationFunction: () => T, source: any, scene: Nullable<Scene>, rootUrl?: Nullable<string>): T;
  88344. /**
  88345. * Clones an object
  88346. * @param creationFunction defines the function used to instanciate the new object
  88347. * @param source defines the source object
  88348. * @returns the cloned object
  88349. */
  88350. static Clone<T>(creationFunction: () => T, source: T): T;
  88351. /**
  88352. * Instanciates a new object based on a source one (some data will be shared between both object)
  88353. * @param creationFunction defines the function used to instanciate the new object
  88354. * @param source defines the source object
  88355. * @returns the new object
  88356. */
  88357. static Instanciate<T>(creationFunction: () => T, source: T): T;
  88358. }
  88359. }
  88360. declare module BABYLON {
  88361. /**
  88362. * This is the base class of all the camera used in the application.
  88363. * @see http://doc.babylonjs.com/features/cameras
  88364. */
  88365. export class Camera extends Node {
  88366. /** @hidden */
  88367. static _createDefaultParsedCamera: (name: string, scene: Scene) => Camera;
  88368. /**
  88369. * This is the default projection mode used by the cameras.
  88370. * It helps recreating a feeling of perspective and better appreciate depth.
  88371. * This is the best way to simulate real life cameras.
  88372. */
  88373. static readonly PERSPECTIVE_CAMERA: number;
  88374. /**
  88375. * This helps creating camera with an orthographic mode.
  88376. * 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.
  88377. */
  88378. static readonly ORTHOGRAPHIC_CAMERA: number;
  88379. /**
  88380. * This is the default FOV mode for perspective cameras.
  88381. * This setting aligns the upper and lower bounds of the viewport to the upper and lower bounds of the camera frustum.
  88382. */
  88383. static readonly FOVMODE_VERTICAL_FIXED: number;
  88384. /**
  88385. * This setting aligns the left and right bounds of the viewport to the left and right bounds of the camera frustum.
  88386. */
  88387. static readonly FOVMODE_HORIZONTAL_FIXED: number;
  88388. /**
  88389. * This specifies ther is no need for a camera rig.
  88390. * Basically only one eye is rendered corresponding to the camera.
  88391. */
  88392. static readonly RIG_MODE_NONE: number;
  88393. /**
  88394. * Simulates a camera Rig with one blue eye and one red eye.
  88395. * This can be use with 3d blue and red glasses.
  88396. */
  88397. static readonly RIG_MODE_STEREOSCOPIC_ANAGLYPH: number;
  88398. /**
  88399. * Defines that both eyes of the camera will be rendered side by side with a parallel target.
  88400. */
  88401. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_PARALLEL: number;
  88402. /**
  88403. * Defines that both eyes of the camera will be rendered side by side with a none parallel target.
  88404. */
  88405. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_CROSSEYED: number;
  88406. /**
  88407. * Defines that both eyes of the camera will be rendered over under each other.
  88408. */
  88409. static readonly RIG_MODE_STEREOSCOPIC_OVERUNDER: number;
  88410. /**
  88411. * Defines that both eyes of the camera should be renderered in a VR mode (carbox).
  88412. */
  88413. static readonly RIG_MODE_VR: number;
  88414. /**
  88415. * Defines that both eyes of the camera should be renderered in a VR mode (webVR).
  88416. */
  88417. static readonly RIG_MODE_WEBVR: number;
  88418. /**
  88419. * Custom rig mode allowing rig cameras to be populated manually with any number of cameras
  88420. */
  88421. static readonly RIG_MODE_CUSTOM: number;
  88422. /**
  88423. * Defines if by default attaching controls should prevent the default javascript event to continue.
  88424. */
  88425. static ForceAttachControlToAlwaysPreventDefault: boolean;
  88426. /**
  88427. * @hidden
  88428. * Might be removed once multiview will be a thing
  88429. */
  88430. static UseAlternateWebVRRendering: boolean;
  88431. /**
  88432. * Define the input manager associated with the camera.
  88433. */
  88434. inputs: CameraInputsManager<Camera>;
  88435. /** @hidden */
  88436. _position: Vector3;
  88437. /**
  88438. * Define the current local position of the camera in the scene
  88439. */
  88440. position: Vector3;
  88441. /**
  88442. * The vector the camera should consider as up.
  88443. * (default is Vector3(0, 1, 0) aka Vector3.Up())
  88444. */
  88445. upVector: Vector3;
  88446. /**
  88447. * Define the current limit on the left side for an orthographic camera
  88448. * In scene unit
  88449. */
  88450. orthoLeft: Nullable<number>;
  88451. /**
  88452. * Define the current limit on the right side for an orthographic camera
  88453. * In scene unit
  88454. */
  88455. orthoRight: Nullable<number>;
  88456. /**
  88457. * Define the current limit on the bottom side for an orthographic camera
  88458. * In scene unit
  88459. */
  88460. orthoBottom: Nullable<number>;
  88461. /**
  88462. * Define the current limit on the top side for an orthographic camera
  88463. * In scene unit
  88464. */
  88465. orthoTop: Nullable<number>;
  88466. /**
  88467. * Field Of View is set in Radians. (default is 0.8)
  88468. */
  88469. fov: number;
  88470. /**
  88471. * Define the minimum distance the camera can see from.
  88472. * This is important to note that the depth buffer are not infinite and the closer it starts
  88473. * the more your scene might encounter depth fighting issue.
  88474. */
  88475. minZ: number;
  88476. /**
  88477. * Define the maximum distance the camera can see to.
  88478. * This is important to note that the depth buffer are not infinite and the further it end
  88479. * the more your scene might encounter depth fighting issue.
  88480. */
  88481. maxZ: number;
  88482. /**
  88483. * Define the default inertia of the camera.
  88484. * This helps giving a smooth feeling to the camera movement.
  88485. */
  88486. inertia: number;
  88487. /**
  88488. * Define the mode of the camera (Camera.PERSPECTIVE_CAMERA or Camera.PERSPECTIVE_ORTHOGRAPHIC)
  88489. */
  88490. mode: number;
  88491. /**
  88492. * Define wether the camera is intermediate.
  88493. * This is useful to not present the output directly to the screen in case of rig without post process for instance
  88494. */
  88495. isIntermediate: boolean;
  88496. /**
  88497. * Define the viewport of the camera.
  88498. * This correspond to the portion of the screen the camera will render to in normalized 0 to 1 unit.
  88499. */
  88500. viewport: Viewport;
  88501. /**
  88502. * Restricts the camera to viewing objects with the same layerMask.
  88503. * A camera with a layerMask of 1 will render mesh.layerMask & camera.layerMask!== 0
  88504. */
  88505. layerMask: number;
  88506. /**
  88507. * fovMode sets the camera frustum bounds to the viewport bounds. (default is FOVMODE_VERTICAL_FIXED)
  88508. */
  88509. fovMode: number;
  88510. /**
  88511. * Rig mode of the camera.
  88512. * This is useful to create the camera with two "eyes" instead of one to create VR or stereoscopic scenes.
  88513. * This is normally controlled byt the camera themselves as internal use.
  88514. */
  88515. cameraRigMode: number;
  88516. /**
  88517. * Defines the distance between both "eyes" in case of a RIG
  88518. */
  88519. interaxialDistance: number;
  88520. /**
  88521. * Defines if stereoscopic rendering is done side by side or over under.
  88522. */
  88523. isStereoscopicSideBySide: boolean;
  88524. /**
  88525. * 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
  88526. * This is pretty helpfull if you wish to make a camera render to a texture you could reuse somewhere
  88527. * else in the scene.
  88528. */
  88529. customRenderTargets: RenderTargetTexture[];
  88530. /**
  88531. * When set, the camera will render to this render target instead of the default canvas
  88532. */
  88533. outputRenderTarget: Nullable<RenderTargetTexture>;
  88534. /**
  88535. * Observable triggered when the camera view matrix has changed.
  88536. */
  88537. onViewMatrixChangedObservable: Observable<Camera>;
  88538. /**
  88539. * Observable triggered when the camera Projection matrix has changed.
  88540. */
  88541. onProjectionMatrixChangedObservable: Observable<Camera>;
  88542. /**
  88543. * Observable triggered when the inputs have been processed.
  88544. */
  88545. onAfterCheckInputsObservable: Observable<Camera>;
  88546. /**
  88547. * Observable triggered when reset has been called and applied to the camera.
  88548. */
  88549. onRestoreStateObservable: Observable<Camera>;
  88550. /** @hidden */
  88551. _cameraRigParams: any;
  88552. /** @hidden */
  88553. _rigCameras: Camera[];
  88554. /** @hidden */
  88555. _rigPostProcess: Nullable<PostProcess>;
  88556. protected _webvrViewMatrix: Matrix;
  88557. /** @hidden */
  88558. _skipRendering: boolean;
  88559. /** @hidden */
  88560. _alternateCamera: Camera;
  88561. /** @hidden */
  88562. _projectionMatrix: Matrix;
  88563. /** @hidden */
  88564. _postProcesses: Nullable<PostProcess>[];
  88565. /** @hidden */
  88566. _activeMeshes: SmartArray<AbstractMesh>;
  88567. protected _globalPosition: Vector3;
  88568. /** hidden */
  88569. _computedViewMatrix: Matrix;
  88570. private _doNotComputeProjectionMatrix;
  88571. private _transformMatrix;
  88572. private _frustumPlanes;
  88573. private _refreshFrustumPlanes;
  88574. private _storedFov;
  88575. private _stateStored;
  88576. /**
  88577. * Instantiates a new camera object.
  88578. * This should not be used directly but through the inherited cameras: ArcRotate, Free...
  88579. * @see http://doc.babylonjs.com/features/cameras
  88580. * @param name Defines the name of the camera in the scene
  88581. * @param position Defines the position of the camera
  88582. * @param scene Defines the scene the camera belongs too
  88583. * @param setActiveOnSceneIfNoneActive Defines if the camera should be set as active after creation if no other camera have been defined in the scene
  88584. */
  88585. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  88586. /**
  88587. * Store current camera state (fov, position, etc..)
  88588. * @returns the camera
  88589. */
  88590. storeState(): Camera;
  88591. /**
  88592. * Restores the camera state values if it has been stored. You must call storeState() first
  88593. */
  88594. protected _restoreStateValues(): boolean;
  88595. /**
  88596. * Restored camera state. You must call storeState() first.
  88597. * @returns true if restored and false otherwise
  88598. */
  88599. restoreState(): boolean;
  88600. /**
  88601. * Gets the class name of the camera.
  88602. * @returns the class name
  88603. */
  88604. getClassName(): string;
  88605. /** @hidden */
  88606. readonly _isCamera: boolean;
  88607. /**
  88608. * Gets a string representation of the camera useful for debug purpose.
  88609. * @param fullDetails Defines that a more verboe level of logging is required
  88610. * @returns the string representation
  88611. */
  88612. toString(fullDetails?: boolean): string;
  88613. /**
  88614. * Gets the current world space position of the camera.
  88615. */
  88616. readonly globalPosition: Vector3;
  88617. /**
  88618. * Gets the list of active meshes this frame (meshes no culled or excluded by lod s in the frame)
  88619. * @returns the active meshe list
  88620. */
  88621. getActiveMeshes(): SmartArray<AbstractMesh>;
  88622. /**
  88623. * Check wether a mesh is part of the current active mesh list of the camera
  88624. * @param mesh Defines the mesh to check
  88625. * @returns true if active, false otherwise
  88626. */
  88627. isActiveMesh(mesh: Mesh): boolean;
  88628. /**
  88629. * Is this camera ready to be used/rendered
  88630. * @param completeCheck defines if a complete check (including post processes) has to be done (false by default)
  88631. * @return true if the camera is ready
  88632. */
  88633. isReady(completeCheck?: boolean): boolean;
  88634. /** @hidden */
  88635. _initCache(): void;
  88636. /** @hidden */
  88637. _updateCache(ignoreParentClass?: boolean): void;
  88638. /** @hidden */
  88639. _isSynchronized(): boolean;
  88640. /** @hidden */
  88641. _isSynchronizedViewMatrix(): boolean;
  88642. /** @hidden */
  88643. _isSynchronizedProjectionMatrix(): boolean;
  88644. /**
  88645. * Attach the input controls to a specific dom element to get the input from.
  88646. * @param element Defines the element the controls should be listened from
  88647. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  88648. */
  88649. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  88650. /**
  88651. * Detach the current controls from the specified dom element.
  88652. * @param element Defines the element to stop listening the inputs from
  88653. */
  88654. detachControl(element: HTMLElement): void;
  88655. /**
  88656. * Update the camera state according to the different inputs gathered during the frame.
  88657. */
  88658. update(): void;
  88659. /** @hidden */
  88660. _checkInputs(): void;
  88661. /** @hidden */
  88662. readonly rigCameras: Camera[];
  88663. /**
  88664. * Gets the post process used by the rig cameras
  88665. */
  88666. readonly rigPostProcess: Nullable<PostProcess>;
  88667. /**
  88668. * Internal, gets the first post proces.
  88669. * @returns the first post process to be run on this camera.
  88670. */
  88671. _getFirstPostProcess(): Nullable<PostProcess>;
  88672. private _cascadePostProcessesToRigCams;
  88673. /**
  88674. * Attach a post process to the camera.
  88675. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  88676. * @param postProcess The post process to attach to the camera
  88677. * @param insertAt The position of the post process in case several of them are in use in the scene
  88678. * @returns the position the post process has been inserted at
  88679. */
  88680. attachPostProcess(postProcess: PostProcess, insertAt?: Nullable<number>): number;
  88681. /**
  88682. * Detach a post process to the camera.
  88683. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  88684. * @param postProcess The post process to detach from the camera
  88685. */
  88686. detachPostProcess(postProcess: PostProcess): void;
  88687. /**
  88688. * Gets the current world matrix of the camera
  88689. */
  88690. getWorldMatrix(): Matrix;
  88691. /** @hidden */
  88692. _getViewMatrix(): Matrix;
  88693. /**
  88694. * Gets the current view matrix of the camera.
  88695. * @param force forces the camera to recompute the matrix without looking at the cached state
  88696. * @returns the view matrix
  88697. */
  88698. getViewMatrix(force?: boolean): Matrix;
  88699. /**
  88700. * Freeze the projection matrix.
  88701. * It will prevent the cache check of the camera projection compute and can speed up perf
  88702. * if no parameter of the camera are meant to change
  88703. * @param projection Defines manually a projection if necessary
  88704. */
  88705. freezeProjectionMatrix(projection?: Matrix): void;
  88706. /**
  88707. * Unfreeze the projection matrix if it has previously been freezed by freezeProjectionMatrix.
  88708. */
  88709. unfreezeProjectionMatrix(): void;
  88710. /**
  88711. * Gets the current projection matrix of the camera.
  88712. * @param force forces the camera to recompute the matrix without looking at the cached state
  88713. * @returns the projection matrix
  88714. */
  88715. getProjectionMatrix(force?: boolean): Matrix;
  88716. /**
  88717. * Gets the transformation matrix (ie. the multiplication of view by projection matrices)
  88718. * @returns a Matrix
  88719. */
  88720. getTransformationMatrix(): Matrix;
  88721. private _updateFrustumPlanes;
  88722. /**
  88723. * Checks if a cullable object (mesh...) is in the camera frustum
  88724. * This checks the bounding box center. See isCompletelyInFrustum for a full bounding check
  88725. * @param target The object to check
  88726. * @returns true if the object is in frustum otherwise false
  88727. */
  88728. isInFrustum(target: ICullable): boolean;
  88729. /**
  88730. * Checks if a cullable object (mesh...) is in the camera frustum
  88731. * Unlike isInFrustum this cheks the full bounding box
  88732. * @param target The object to check
  88733. * @returns true if the object is in frustum otherwise false
  88734. */
  88735. isCompletelyInFrustum(target: ICullable): boolean;
  88736. /**
  88737. * Gets a ray in the forward direction from the camera.
  88738. * @param length Defines the length of the ray to create
  88739. * @param transform Defines the transform to apply to the ray, by default the world matrx is used to create a workd space ray
  88740. * @param origin Defines the start point of the ray which defaults to the camera position
  88741. * @returns the forward ray
  88742. */
  88743. getForwardRay(length?: number, transform?: Matrix, origin?: Vector3): Ray;
  88744. /**
  88745. * Releases resources associated with this node.
  88746. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  88747. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  88748. */
  88749. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  88750. /** @hidden */
  88751. _isLeftCamera: boolean;
  88752. /**
  88753. * Gets the left camera of a rig setup in case of Rigged Camera
  88754. */
  88755. readonly isLeftCamera: boolean;
  88756. /** @hidden */
  88757. _isRightCamera: boolean;
  88758. /**
  88759. * Gets the right camera of a rig setup in case of Rigged Camera
  88760. */
  88761. readonly isRightCamera: boolean;
  88762. /**
  88763. * Gets the left camera of a rig setup in case of Rigged Camera
  88764. */
  88765. readonly leftCamera: Nullable<FreeCamera>;
  88766. /**
  88767. * Gets the right camera of a rig setup in case of Rigged Camera
  88768. */
  88769. readonly rightCamera: Nullable<FreeCamera>;
  88770. /**
  88771. * Gets the left camera target of a rig setup in case of Rigged Camera
  88772. * @returns the target position
  88773. */
  88774. getLeftTarget(): Nullable<Vector3>;
  88775. /**
  88776. * Gets the right camera target of a rig setup in case of Rigged Camera
  88777. * @returns the target position
  88778. */
  88779. getRightTarget(): Nullable<Vector3>;
  88780. /**
  88781. * @hidden
  88782. */
  88783. setCameraRigMode(mode: number, rigParams: any): void;
  88784. /** @hidden */
  88785. static _setStereoscopicRigMode(camera: Camera): void;
  88786. /** @hidden */
  88787. static _setStereoscopicAnaglyphRigMode(camera: Camera): void;
  88788. /** @hidden */
  88789. static _setVRRigMode(camera: Camera, rigParams: any): void;
  88790. /** @hidden */
  88791. static _setWebVRRigMode(camera: Camera, rigParams: any): void;
  88792. /** @hidden */
  88793. _getVRProjectionMatrix(): Matrix;
  88794. protected _updateCameraRotationMatrix(): void;
  88795. protected _updateWebVRCameraRotationMatrix(): void;
  88796. /**
  88797. * This function MUST be overwritten by the different WebVR cameras available.
  88798. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  88799. * @hidden
  88800. */
  88801. _getWebVRProjectionMatrix(): Matrix;
  88802. /**
  88803. * This function MUST be overwritten by the different WebVR cameras available.
  88804. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  88805. * @hidden
  88806. */
  88807. _getWebVRViewMatrix(): Matrix;
  88808. /** @hidden */
  88809. setCameraRigParameter(name: string, value: any): void;
  88810. /**
  88811. * needs to be overridden by children so sub has required properties to be copied
  88812. * @hidden
  88813. */
  88814. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  88815. /**
  88816. * May need to be overridden by children
  88817. * @hidden
  88818. */
  88819. _updateRigCameras(): void;
  88820. /** @hidden */
  88821. _setupInputs(): void;
  88822. /**
  88823. * Serialiaze the camera setup to a json represention
  88824. * @returns the JSON representation
  88825. */
  88826. serialize(): any;
  88827. /**
  88828. * Clones the current camera.
  88829. * @param name The cloned camera name
  88830. * @returns the cloned camera
  88831. */
  88832. clone(name: string): Camera;
  88833. /**
  88834. * Gets the direction of the camera relative to a given local axis.
  88835. * @param localAxis Defines the reference axis to provide a relative direction.
  88836. * @return the direction
  88837. */
  88838. getDirection(localAxis: Vector3): Vector3;
  88839. /**
  88840. * Gets the direction of the camera relative to a given local axis into a passed vector.
  88841. * @param localAxis Defines the reference axis to provide a relative direction.
  88842. * @param result Defines the vector to store the result in
  88843. */
  88844. getDirectionToRef(localAxis: Vector3, result: Vector3): void;
  88845. /**
  88846. * Gets a camera constructor for a given camera type
  88847. * @param type The type of the camera to construct (should be equal to one of the camera class name)
  88848. * @param name The name of the camera the result will be able to instantiate
  88849. * @param scene The scene the result will construct the camera in
  88850. * @param interaxial_distance In case of stereoscopic setup, the distance between both eyes
  88851. * @param isStereoscopicSideBySide In case of stereoscopic setup, should the sereo be side b side
  88852. * @returns a factory method to construc the camera
  88853. */
  88854. static GetConstructorFromName(type: string, name: string, scene: Scene, interaxial_distance?: number, isStereoscopicSideBySide?: boolean): () => Camera;
  88855. /**
  88856. * Compute the world matrix of the camera.
  88857. * @returns the camera workd matrix
  88858. */
  88859. computeWorldMatrix(): Matrix;
  88860. /**
  88861. * Parse a JSON and creates the camera from the parsed information
  88862. * @param parsedCamera The JSON to parse
  88863. * @param scene The scene to instantiate the camera in
  88864. * @returns the newly constructed camera
  88865. */
  88866. static Parse(parsedCamera: any, scene: Scene): Camera;
  88867. }
  88868. }
  88869. declare module BABYLON {
  88870. /**
  88871. * Interface for any object that can request an animation frame
  88872. */
  88873. export interface ICustomAnimationFrameRequester {
  88874. /**
  88875. * This function will be called when the render loop is ready. If this is not populated, the engine's renderloop function will be called
  88876. */
  88877. renderFunction?: Function;
  88878. /**
  88879. * Called to request the next frame to render to
  88880. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame
  88881. */
  88882. requestAnimationFrame: Function;
  88883. /**
  88884. * You can pass this value to cancelAnimationFrame() to cancel the refresh callback request
  88885. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame#Return_value
  88886. */
  88887. requestID?: number;
  88888. }
  88889. /**
  88890. * Interface containing an array of animations
  88891. */
  88892. export interface IAnimatable {
  88893. /**
  88894. * Array of animations
  88895. */
  88896. animations: Array<Animation>;
  88897. }
  88898. /** Interface used by value gradients (color, factor, ...) */
  88899. export interface IValueGradient {
  88900. /**
  88901. * Gets or sets the gradient value (between 0 and 1)
  88902. */
  88903. gradient: number;
  88904. }
  88905. /** Class used to store color4 gradient */
  88906. export class ColorGradient implements IValueGradient {
  88907. /**
  88908. * Gets or sets the gradient value (between 0 and 1)
  88909. */
  88910. gradient: number;
  88911. /**
  88912. * Gets or sets first associated color
  88913. */
  88914. color1: Color4;
  88915. /**
  88916. * Gets or sets second associated color
  88917. */
  88918. color2?: Color4;
  88919. /**
  88920. * Will get a color picked randomly between color1 and color2.
  88921. * If color2 is undefined then color1 will be used
  88922. * @param result defines the target Color4 to store the result in
  88923. */
  88924. getColorToRef(result: Color4): void;
  88925. }
  88926. /** Class used to store color 3 gradient */
  88927. export class Color3Gradient implements IValueGradient {
  88928. /**
  88929. * Gets or sets the gradient value (between 0 and 1)
  88930. */
  88931. gradient: number;
  88932. /**
  88933. * Gets or sets the associated color
  88934. */
  88935. color: Color3;
  88936. }
  88937. /** Class used to store factor gradient */
  88938. export class FactorGradient implements IValueGradient {
  88939. /**
  88940. * Gets or sets the gradient value (between 0 and 1)
  88941. */
  88942. gradient: number;
  88943. /**
  88944. * Gets or sets first associated factor
  88945. */
  88946. factor1: number;
  88947. /**
  88948. * Gets or sets second associated factor
  88949. */
  88950. factor2?: number;
  88951. /**
  88952. * Will get a number picked randomly between factor1 and factor2.
  88953. * If factor2 is undefined then factor1 will be used
  88954. * @returns the picked number
  88955. */
  88956. getFactor(): number;
  88957. }
  88958. /**
  88959. * @ignore
  88960. * Application error to support additional information when loading a file
  88961. */
  88962. export class LoadFileError extends Error {
  88963. /** defines the optional web request */
  88964. request?: WebRequest | undefined;
  88965. private static _setPrototypeOf;
  88966. /**
  88967. * Creates a new LoadFileError
  88968. * @param message defines the message of the error
  88969. * @param request defines the optional web request
  88970. */
  88971. constructor(message: string,
  88972. /** defines the optional web request */
  88973. request?: WebRequest | undefined);
  88974. }
  88975. /**
  88976. * Class used to define a retry strategy when error happens while loading assets
  88977. */
  88978. export class RetryStrategy {
  88979. /**
  88980. * Function used to defines an exponential back off strategy
  88981. * @param maxRetries defines the maximum number of retries (3 by default)
  88982. * @param baseInterval defines the interval between retries
  88983. * @returns the strategy function to use
  88984. */
  88985. static ExponentialBackoff(maxRetries?: number, baseInterval?: number): (url: string, request: WebRequest, retryIndex: number) => number;
  88986. }
  88987. /**
  88988. * File request interface
  88989. */
  88990. export interface IFileRequest {
  88991. /**
  88992. * Raised when the request is complete (success or error).
  88993. */
  88994. onCompleteObservable: Observable<IFileRequest>;
  88995. /**
  88996. * Aborts the request for a file.
  88997. */
  88998. abort: () => void;
  88999. }
  89000. /**
  89001. * Class containing a set of static utilities functions
  89002. */
  89003. export class Tools {
  89004. /**
  89005. * Gets or sets the base URL to use to load assets
  89006. */
  89007. static BaseUrl: string;
  89008. /**
  89009. * Enable/Disable Custom HTTP Request Headers globally.
  89010. * default = false
  89011. * @see CustomRequestHeaders
  89012. */
  89013. static UseCustomRequestHeaders: boolean;
  89014. /**
  89015. * Custom HTTP Request Headers to be sent with XMLHttpRequests
  89016. * i.e. when loading files, where the server/service expects an Authorization header
  89017. */
  89018. static CustomRequestHeaders: {
  89019. [key: string]: string;
  89020. };
  89021. /**
  89022. * Gets or sets the retry strategy to apply when an error happens while loading an asset
  89023. */
  89024. static DefaultRetryStrategy: (url: string, request: WebRequest, retryIndex: number) => number;
  89025. /**
  89026. * Default behaviour for cors in the application.
  89027. * It can be a string if the expected behavior is identical in the entire app.
  89028. * Or a callback to be able to set it per url or on a group of them (in case of Video source for instance)
  89029. */
  89030. static CorsBehavior: string | ((url: string | string[]) => string);
  89031. /**
  89032. * Gets or sets a global variable indicating if fallback texture must be used when a texture cannot be loaded
  89033. * @ignorenaming
  89034. */
  89035. static UseFallbackTexture: boolean;
  89036. /**
  89037. * Use this object to register external classes like custom textures or material
  89038. * to allow the laoders to instantiate them
  89039. */
  89040. static RegisteredExternalClasses: {
  89041. [key: string]: Object;
  89042. };
  89043. /**
  89044. * Texture content used if a texture cannot loaded
  89045. * @ignorenaming
  89046. */
  89047. static fallbackTexture: string;
  89048. /**
  89049. * Read the content of a byte array at a specified coordinates (taking in account wrapping)
  89050. * @param u defines the coordinate on X axis
  89051. * @param v defines the coordinate on Y axis
  89052. * @param width defines the width of the source data
  89053. * @param height defines the height of the source data
  89054. * @param pixels defines the source byte array
  89055. * @param color defines the output color
  89056. */
  89057. static FetchToRef(u: number, v: number, width: number, height: number, pixels: Uint8Array, color: Color4): void;
  89058. /**
  89059. * Interpolates between a and b via alpha
  89060. * @param a The lower value (returned when alpha = 0)
  89061. * @param b The upper value (returned when alpha = 1)
  89062. * @param alpha The interpolation-factor
  89063. * @return The mixed value
  89064. */
  89065. static Mix(a: number, b: number, alpha: number): number;
  89066. /**
  89067. * Tries to instantiate a new object from a given class name
  89068. * @param className defines the class name to instantiate
  89069. * @returns the new object or null if the system was not able to do the instantiation
  89070. */
  89071. static Instantiate(className: string): any;
  89072. /**
  89073. * Provides a slice function that will work even on IE
  89074. * @param data defines the array to slice
  89075. * @param start defines the start of the data (optional)
  89076. * @param end defines the end of the data (optional)
  89077. * @returns the new sliced array
  89078. */
  89079. static Slice<T>(data: T, start?: number, end?: number): T;
  89080. /**
  89081. * Polyfill for setImmediate
  89082. * @param action defines the action to execute after the current execution block
  89083. */
  89084. static SetImmediate(action: () => void): void;
  89085. /**
  89086. * Function indicating if a number is an exponent of 2
  89087. * @param value defines the value to test
  89088. * @returns true if the value is an exponent of 2
  89089. */
  89090. static IsExponentOfTwo(value: number): boolean;
  89091. private static _tmpFloatArray;
  89092. /**
  89093. * Returns the nearest 32-bit single precision float representation of a Number
  89094. * @param value A Number. If the parameter is of a different type, it will get converted
  89095. * to a number or to NaN if it cannot be converted
  89096. * @returns number
  89097. */
  89098. static FloatRound(value: number): number;
  89099. /**
  89100. * Find the next highest power of two.
  89101. * @param x Number to start search from.
  89102. * @return Next highest power of two.
  89103. */
  89104. static CeilingPOT(x: number): number;
  89105. /**
  89106. * Find the next lowest power of two.
  89107. * @param x Number to start search from.
  89108. * @return Next lowest power of two.
  89109. */
  89110. static FloorPOT(x: number): number;
  89111. /**
  89112. * Find the nearest power of two.
  89113. * @param x Number to start search from.
  89114. * @return Next nearest power of two.
  89115. */
  89116. static NearestPOT(x: number): number;
  89117. /**
  89118. * Get the closest exponent of two
  89119. * @param value defines the value to approximate
  89120. * @param max defines the maximum value to return
  89121. * @param mode defines how to define the closest value
  89122. * @returns closest exponent of two of the given value
  89123. */
  89124. static GetExponentOfTwo(value: number, max: number, mode?: number): number;
  89125. /**
  89126. * Extracts the filename from a path
  89127. * @param path defines the path to use
  89128. * @returns the filename
  89129. */
  89130. static GetFilename(path: string): string;
  89131. /**
  89132. * Extracts the "folder" part of a path (everything before the filename).
  89133. * @param uri The URI to extract the info from
  89134. * @param returnUnchangedIfNoSlash Do not touch the URI if no slashes are present
  89135. * @returns The "folder" part of the path
  89136. */
  89137. static GetFolderPath(uri: string, returnUnchangedIfNoSlash?: boolean): string;
  89138. /**
  89139. * Extracts text content from a DOM element hierarchy
  89140. * Back Compat only, please use DomManagement.GetDOMTextContent instead.
  89141. */
  89142. static GetDOMTextContent: typeof DomManagement.GetDOMTextContent;
  89143. /**
  89144. * Convert an angle in radians to degrees
  89145. * @param angle defines the angle to convert
  89146. * @returns the angle in degrees
  89147. */
  89148. static ToDegrees(angle: number): number;
  89149. /**
  89150. * Convert an angle in degrees to radians
  89151. * @param angle defines the angle to convert
  89152. * @returns the angle in radians
  89153. */
  89154. static ToRadians(angle: number): number;
  89155. /**
  89156. * Encode a buffer to a base64 string
  89157. * @param buffer defines the buffer to encode
  89158. * @returns the encoded string
  89159. */
  89160. static EncodeArrayBufferTobase64(buffer: ArrayBuffer): string;
  89161. /**
  89162. * Extracts minimum and maximum values from a list of indexed positions
  89163. * @param positions defines the positions to use
  89164. * @param indices defines the indices to the positions
  89165. * @param indexStart defines the start index
  89166. * @param indexCount defines the end index
  89167. * @param bias defines bias value to add to the result
  89168. * @return minimum and maximum values
  89169. */
  89170. static ExtractMinAndMaxIndexed(positions: FloatArray, indices: IndicesArray, indexStart: number, indexCount: number, bias?: Nullable<Vector2>): {
  89171. minimum: Vector3;
  89172. maximum: Vector3;
  89173. };
  89174. /**
  89175. * Extracts minimum and maximum values from a list of positions
  89176. * @param positions defines the positions to use
  89177. * @param start defines the start index in the positions array
  89178. * @param count defines the number of positions to handle
  89179. * @param bias defines bias value to add to the result
  89180. * @param stride defines the stride size to use (distance between two positions in the positions array)
  89181. * @return minimum and maximum values
  89182. */
  89183. static ExtractMinAndMax(positions: FloatArray, start: number, count: number, bias?: Nullable<Vector2>, stride?: number): {
  89184. minimum: Vector3;
  89185. maximum: Vector3;
  89186. };
  89187. /**
  89188. * Returns an array if obj is not an array
  89189. * @param obj defines the object to evaluate as an array
  89190. * @param allowsNullUndefined defines a boolean indicating if obj is allowed to be null or undefined
  89191. * @returns either obj directly if obj is an array or a new array containing obj
  89192. */
  89193. static MakeArray(obj: any, allowsNullUndefined?: boolean): Nullable<Array<any>>;
  89194. /**
  89195. * Gets the pointer prefix to use
  89196. * @returns "pointer" if touch is enabled. Else returns "mouse"
  89197. */
  89198. static GetPointerPrefix(): string;
  89199. /**
  89200. * Queue a new function into the requested animation frame pool (ie. this function will be executed byt the browser for the next frame)
  89201. * @param func - the function to be called
  89202. * @param requester - the object that will request the next frame. Falls back to window.
  89203. * @returns frame number
  89204. */
  89205. static QueueNewFrame(func: () => void, requester?: any): number;
  89206. /**
  89207. * Ask the browser to promote the current element to fullscreen rendering mode
  89208. * @param element defines the DOM element to promote
  89209. */
  89210. static RequestFullscreen(element: HTMLElement): void;
  89211. /**
  89212. * Asks the browser to exit fullscreen mode
  89213. */
  89214. static ExitFullscreen(): void;
  89215. /**
  89216. * Sets the cors behavior on a dom element. This will add the required Tools.CorsBehavior to the element.
  89217. * @param url define the url we are trying
  89218. * @param element define the dom element where to configure the cors policy
  89219. */
  89220. static SetCorsBehavior(url: string | string[], element: {
  89221. crossOrigin: string | null;
  89222. }): void;
  89223. /**
  89224. * Removes unwanted characters from an url
  89225. * @param url defines the url to clean
  89226. * @returns the cleaned url
  89227. */
  89228. static CleanUrl(url: string): string;
  89229. /**
  89230. * Gets or sets a function used to pre-process url before using them to load assets
  89231. */
  89232. static PreprocessUrl: (url: string) => string;
  89233. /**
  89234. * Loads an image as an HTMLImageElement.
  89235. * @param input url string, ArrayBuffer, or Blob to load
  89236. * @param onLoad callback called when the image successfully loads
  89237. * @param onError callback called when the image fails to load
  89238. * @param offlineProvider offline provider for caching
  89239. * @returns the HTMLImageElement of the loaded image
  89240. */
  89241. static LoadImage(input: string | ArrayBuffer | Blob, onLoad: (img: HTMLImageElement) => void, onError: (message?: string, exception?: any) => void, offlineProvider: Nullable<IOfflineProvider>): HTMLImageElement;
  89242. /**
  89243. * Loads a file
  89244. * @param url url string, ArrayBuffer, or Blob to load
  89245. * @param onSuccess callback called when the file successfully loads
  89246. * @param onProgress callback called while file is loading (if the server supports this mode)
  89247. * @param offlineProvider defines the offline provider for caching
  89248. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  89249. * @param onError callback called when the file fails to load
  89250. * @returns a file request object
  89251. */
  89252. 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;
  89253. /**
  89254. * Load a script (identified by an url). When the url returns, the
  89255. * content of this file is added into a new script element, attached to the DOM (body element)
  89256. * @param scriptUrl defines the url of the script to laod
  89257. * @param onSuccess defines the callback called when the script is loaded
  89258. * @param onError defines the callback to call if an error occurs
  89259. */
  89260. static LoadScript(scriptUrl: string, onSuccess: () => void, onError?: (message?: string, exception?: any) => void): void;
  89261. /**
  89262. * Loads a file from a blob
  89263. * @param fileToLoad defines the blob to use
  89264. * @param callback defines the callback to call when data is loaded
  89265. * @param progressCallback defines the callback to call during loading process
  89266. * @returns a file request object
  89267. */
  89268. static ReadFileAsDataURL(fileToLoad: Blob, callback: (data: any) => void, progressCallback: (ev: ProgressEvent) => any): IFileRequest;
  89269. /**
  89270. * Loads a file
  89271. * @param fileToLoad defines the file to load
  89272. * @param callback defines the callback to call when data is loaded
  89273. * @param progressCallBack defines the callback to call during loading process
  89274. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  89275. * @returns a file request object
  89276. */
  89277. static ReadFile(fileToLoad: File, callback: (data: any) => void, progressCallBack?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean): IFileRequest;
  89278. /**
  89279. * Creates a data url from a given string content
  89280. * @param content defines the content to convert
  89281. * @returns the new data url link
  89282. */
  89283. static FileAsURL(content: string): string;
  89284. /**
  89285. * Format the given number to a specific decimal format
  89286. * @param value defines the number to format
  89287. * @param decimals defines the number of decimals to use
  89288. * @returns the formatted string
  89289. */
  89290. static Format(value: number, decimals?: number): string;
  89291. /**
  89292. * Checks if a given vector is inside a specific range
  89293. * @param v defines the vector to test
  89294. * @param min defines the minimum range
  89295. * @param max defines the maximum range
  89296. */
  89297. static CheckExtends(v: Vector3, min: Vector3, max: Vector3): void;
  89298. /**
  89299. * Tries to copy an object by duplicating every property
  89300. * @param source defines the source object
  89301. * @param destination defines the target object
  89302. * @param doNotCopyList defines a list of properties to avoid
  89303. * @param mustCopyList defines a list of properties to copy (even if they start with _)
  89304. */
  89305. static DeepCopy(source: any, destination: any, doNotCopyList?: string[], mustCopyList?: string[]): void;
  89306. /**
  89307. * Gets a boolean indicating if the given object has no own property
  89308. * @param obj defines the object to test
  89309. * @returns true if object has no own property
  89310. */
  89311. static IsEmpty(obj: any): boolean;
  89312. /**
  89313. * Function used to register events at window level
  89314. * @param events defines the events to register
  89315. */
  89316. static RegisterTopRootEvents(events: {
  89317. name: string;
  89318. handler: Nullable<(e: FocusEvent) => any>;
  89319. }[]): void;
  89320. /**
  89321. * Function used to unregister events from window level
  89322. * @param events defines the events to unregister
  89323. */
  89324. static UnregisterTopRootEvents(events: {
  89325. name: string;
  89326. handler: Nullable<(e: FocusEvent) => any>;
  89327. }[]): void;
  89328. /**
  89329. * @ignore
  89330. */
  89331. static _ScreenshotCanvas: HTMLCanvasElement;
  89332. /**
  89333. * Dumps the current bound framebuffer
  89334. * @param width defines the rendering width
  89335. * @param height defines the rendering height
  89336. * @param engine defines the hosting engine
  89337. * @param successCallback defines the callback triggered once the data are available
  89338. * @param mimeType defines the mime type of the result
  89339. * @param fileName defines the filename to download. If present, the result will automatically be downloaded
  89340. */
  89341. static DumpFramebuffer(width: number, height: number, engine: Engine, successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  89342. /**
  89343. * Converts the canvas data to blob.
  89344. * This acts as a polyfill for browsers not supporting the to blob function.
  89345. * @param canvas Defines the canvas to extract the data from
  89346. * @param successCallback Defines the callback triggered once the data are available
  89347. * @param mimeType Defines the mime type of the result
  89348. */
  89349. static ToBlob(canvas: HTMLCanvasElement, successCallback: (blob: Nullable<Blob>) => void, mimeType?: string): void;
  89350. /**
  89351. * Encodes the canvas data to base 64 or automatically download the result if filename is defined
  89352. * @param successCallback defines the callback triggered once the data are available
  89353. * @param mimeType defines the mime type of the result
  89354. * @param fileName defines he filename to download. If present, the result will automatically be downloaded
  89355. */
  89356. static EncodeScreenshotCanvasData(successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  89357. /**
  89358. * Downloads a blob in the browser
  89359. * @param blob defines the blob to download
  89360. * @param fileName defines the name of the downloaded file
  89361. */
  89362. static Download(blob: Blob, fileName: string): void;
  89363. /**
  89364. * Captures a screenshot of the current rendering
  89365. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  89366. * @param engine defines the rendering engine
  89367. * @param camera defines the source camera
  89368. * @param size This parameter can be set to a single number or to an object with the
  89369. * following (optional) properties: precision, width, height. If a single number is passed,
  89370. * it will be used for both width and height. If an object is passed, the screenshot size
  89371. * will be derived from the parameters. The precision property is a multiplier allowing
  89372. * rendering at a higher or lower resolution
  89373. * @param successCallback defines the callback receives a single parameter which contains the
  89374. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  89375. * src parameter of an <img> to display it
  89376. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  89377. * Check your browser for supported MIME types
  89378. */
  89379. static CreateScreenshot(engine: Engine, camera: Camera, size: any, successCallback?: (data: string) => void, mimeType?: string): void;
  89380. /**
  89381. * Generates an image screenshot from the specified camera.
  89382. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  89383. * @param engine The engine to use for rendering
  89384. * @param camera The camera to use for rendering
  89385. * @param size This parameter can be set to a single number or to an object with the
  89386. * following (optional) properties: precision, width, height. If a single number is passed,
  89387. * it will be used for both width and height. If an object is passed, the screenshot size
  89388. * will be derived from the parameters. The precision property is a multiplier allowing
  89389. * rendering at a higher or lower resolution
  89390. * @param successCallback The callback receives a single parameter which contains the
  89391. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  89392. * src parameter of an <img> to display it
  89393. * @param mimeType The MIME type of the screenshot image (default: image/png).
  89394. * Check your browser for supported MIME types
  89395. * @param samples Texture samples (default: 1)
  89396. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  89397. * @param fileName A name for for the downloaded file.
  89398. */
  89399. static CreateScreenshotUsingRenderTarget(engine: Engine, camera: Camera, size: any, successCallback?: (data: string) => void, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): void;
  89400. /**
  89401. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  89402. * Be aware Math.random() could cause collisions, but:
  89403. * "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"
  89404. * @returns a pseudo random id
  89405. */
  89406. static RandomId(): string;
  89407. /**
  89408. * Test if the given uri is a base64 string
  89409. * @param uri The uri to test
  89410. * @return True if the uri is a base64 string or false otherwise
  89411. */
  89412. static IsBase64(uri: string): boolean;
  89413. /**
  89414. * Decode the given base64 uri.
  89415. * @param uri The uri to decode
  89416. * @return The decoded base64 data.
  89417. */
  89418. static DecodeBase64(uri: string): ArrayBuffer;
  89419. /**
  89420. * No log
  89421. */
  89422. static readonly NoneLogLevel: number;
  89423. /**
  89424. * Only message logs
  89425. */
  89426. static readonly MessageLogLevel: number;
  89427. /**
  89428. * Only warning logs
  89429. */
  89430. static readonly WarningLogLevel: number;
  89431. /**
  89432. * Only error logs
  89433. */
  89434. static readonly ErrorLogLevel: number;
  89435. /**
  89436. * All logs
  89437. */
  89438. static readonly AllLogLevel: number;
  89439. /**
  89440. * Gets a value indicating the number of loading errors
  89441. * @ignorenaming
  89442. */
  89443. static readonly errorsCount: number;
  89444. /**
  89445. * Callback called when a new log is added
  89446. */
  89447. static OnNewCacheEntry: (entry: string) => void;
  89448. /**
  89449. * Log a message to the console
  89450. * @param message defines the message to log
  89451. */
  89452. static Log(message: string): void;
  89453. /**
  89454. * Write a warning message to the console
  89455. * @param message defines the message to log
  89456. */
  89457. static Warn(message: string): void;
  89458. /**
  89459. * Write an error message to the console
  89460. * @param message defines the message to log
  89461. */
  89462. static Error(message: string): void;
  89463. /**
  89464. * Gets current log cache (list of logs)
  89465. */
  89466. static readonly LogCache: string;
  89467. /**
  89468. * Clears the log cache
  89469. */
  89470. static ClearLogCache(): void;
  89471. /**
  89472. * Sets the current log level (MessageLogLevel / WarningLogLevel / ErrorLogLevel)
  89473. */
  89474. static LogLevels: number;
  89475. /**
  89476. * Checks if the loaded document was accessed via `file:`-Protocol.
  89477. * @returns boolean
  89478. */
  89479. static IsFileURL(): boolean;
  89480. /**
  89481. * Checks if the window object exists
  89482. * Back Compat only, please use DomManagement.IsWindowObjectExist instead.
  89483. */
  89484. static IsWindowObjectExist: typeof DomManagement.IsWindowObjectExist;
  89485. /**
  89486. * No performance log
  89487. */
  89488. static readonly PerformanceNoneLogLevel: number;
  89489. /**
  89490. * Use user marks to log performance
  89491. */
  89492. static readonly PerformanceUserMarkLogLevel: number;
  89493. /**
  89494. * Log performance to the console
  89495. */
  89496. static readonly PerformanceConsoleLogLevel: number;
  89497. private static _performance;
  89498. /**
  89499. * Sets the current performance log level
  89500. */
  89501. static PerformanceLogLevel: number;
  89502. private static _StartPerformanceCounterDisabled;
  89503. private static _EndPerformanceCounterDisabled;
  89504. private static _StartUserMark;
  89505. private static _EndUserMark;
  89506. private static _StartPerformanceConsole;
  89507. private static _EndPerformanceConsole;
  89508. /**
  89509. * Starts a performance counter
  89510. */
  89511. static StartPerformanceCounter: (counterName: string, condition?: boolean) => void;
  89512. /**
  89513. * Ends a specific performance coutner
  89514. */
  89515. static EndPerformanceCounter: (counterName: string, condition?: boolean) => void;
  89516. /**
  89517. * Gets either window.performance.now() if supported or Date.now() else
  89518. */
  89519. static readonly Now: number;
  89520. /**
  89521. * This method will return the name of the class used to create the instance of the given object.
  89522. * It will works only on Javascript basic data types (number, string, ...) and instance of class declared with the @className decorator.
  89523. * @param object the object to get the class name from
  89524. * @param isType defines if the object is actually a type
  89525. * @returns the name of the class, will be "object" for a custom data type not using the @className decorator
  89526. */
  89527. static GetClassName(object: any, isType?: boolean): string;
  89528. /**
  89529. * Gets the first element of an array satisfying a given predicate
  89530. * @param array defines the array to browse
  89531. * @param predicate defines the predicate to use
  89532. * @returns null if not found or the element
  89533. */
  89534. static First<T>(array: Array<T>, predicate: (item: T) => boolean): Nullable<T>;
  89535. /**
  89536. * This method will return the name of the full name of the class, including its owning module (if any).
  89537. * 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).
  89538. * @param object the object to get the class name from
  89539. * @param isType defines if the object is actually a type
  89540. * @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.
  89541. * @ignorenaming
  89542. */
  89543. static getFullClassName(object: any, isType?: boolean): Nullable<string>;
  89544. /**
  89545. * Returns a promise that resolves after the given amount of time.
  89546. * @param delay Number of milliseconds to delay
  89547. * @returns Promise that resolves after the given amount of time
  89548. */
  89549. static DelayAsync(delay: number): Promise<void>;
  89550. /**
  89551. * Gets the current gradient from an array of IValueGradient
  89552. * @param ratio defines the current ratio to get
  89553. * @param gradients defines the array of IValueGradient
  89554. * @param updateFunc defines the callback function used to get the final value from the selected gradients
  89555. */
  89556. static GetCurrentGradient(ratio: number, gradients: IValueGradient[], updateFunc: (current: IValueGradient, next: IValueGradient, scale: number) => void): void;
  89557. }
  89558. /**
  89559. * This class is used to track a performance counter which is number based.
  89560. * The user has access to many properties which give statistics of different nature.
  89561. *
  89562. * The implementer can track two kinds of Performance Counter: time and count.
  89563. * 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.
  89564. * 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.
  89565. */
  89566. export class PerfCounter {
  89567. /**
  89568. * Gets or sets a global boolean to turn on and off all the counters
  89569. */
  89570. static Enabled: boolean;
  89571. /**
  89572. * Returns the smallest value ever
  89573. */
  89574. readonly min: number;
  89575. /**
  89576. * Returns the biggest value ever
  89577. */
  89578. readonly max: number;
  89579. /**
  89580. * Returns the average value since the performance counter is running
  89581. */
  89582. readonly average: number;
  89583. /**
  89584. * Returns the average value of the last second the counter was monitored
  89585. */
  89586. readonly lastSecAverage: number;
  89587. /**
  89588. * Returns the current value
  89589. */
  89590. readonly current: number;
  89591. /**
  89592. * Gets the accumulated total
  89593. */
  89594. readonly total: number;
  89595. /**
  89596. * Gets the total value count
  89597. */
  89598. readonly count: number;
  89599. /**
  89600. * Creates a new counter
  89601. */
  89602. constructor();
  89603. /**
  89604. * Call this method to start monitoring a new frame.
  89605. * 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.
  89606. */
  89607. fetchNewFrame(): void;
  89608. /**
  89609. * Call this method to monitor a count of something (e.g. mesh drawn in viewport count)
  89610. * @param newCount the count value to add to the monitored count
  89611. * @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.
  89612. */
  89613. addCount(newCount: number, fetchResult: boolean): void;
  89614. /**
  89615. * Start monitoring this performance counter
  89616. */
  89617. beginMonitoring(): void;
  89618. /**
  89619. * Compute the time lapsed since the previous beginMonitoring() call.
  89620. * @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
  89621. */
  89622. endMonitoring(newFrame?: boolean): void;
  89623. private _fetchResult;
  89624. private _startMonitoringTime;
  89625. private _min;
  89626. private _max;
  89627. private _average;
  89628. private _current;
  89629. private _totalValueCount;
  89630. private _totalAccumulated;
  89631. private _lastSecAverage;
  89632. private _lastSecAccumulated;
  89633. private _lastSecTime;
  89634. private _lastSecValueCount;
  89635. }
  89636. /**
  89637. * Use this className as a decorator on a given class definition to add it a name and optionally its module.
  89638. * You can then use the Tools.getClassName(obj) on an instance to retrieve its class name.
  89639. * This method is the only way to get it done in all cases, even if the .js file declaring the class is minified
  89640. * @param name The name of the class, case should be preserved
  89641. * @param module The name of the Module hosting the class, optional, but strongly recommended to specify if possible. Case should be preserved.
  89642. */
  89643. export function className(name: string, module?: string): (target: Object) => void;
  89644. /**
  89645. * An implementation of a loop for asynchronous functions.
  89646. */
  89647. export class AsyncLoop {
  89648. /**
  89649. * Defines the number of iterations for the loop
  89650. */
  89651. iterations: number;
  89652. /**
  89653. * Defines the current index of the loop.
  89654. */
  89655. index: number;
  89656. private _done;
  89657. private _fn;
  89658. private _successCallback;
  89659. /**
  89660. * Constructor.
  89661. * @param iterations the number of iterations.
  89662. * @param func the function to run each iteration
  89663. * @param successCallback the callback that will be called upon succesful execution
  89664. * @param offset starting offset.
  89665. */
  89666. constructor(
  89667. /**
  89668. * Defines the number of iterations for the loop
  89669. */
  89670. iterations: number, func: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number);
  89671. /**
  89672. * Execute the next iteration. Must be called after the last iteration was finished.
  89673. */
  89674. executeNext(): void;
  89675. /**
  89676. * Break the loop and run the success callback.
  89677. */
  89678. breakLoop(): void;
  89679. /**
  89680. * Create and run an async loop.
  89681. * @param iterations the number of iterations.
  89682. * @param fn the function to run each iteration
  89683. * @param successCallback the callback that will be called upon succesful execution
  89684. * @param offset starting offset.
  89685. * @returns the created async loop object
  89686. */
  89687. static Run(iterations: number, fn: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number): AsyncLoop;
  89688. /**
  89689. * A for-loop that will run a given number of iterations synchronous and the rest async.
  89690. * @param iterations total number of iterations
  89691. * @param syncedIterations number of synchronous iterations in each async iteration.
  89692. * @param fn the function to call each iteration.
  89693. * @param callback a success call back that will be called when iterating stops.
  89694. * @param breakFunction a break condition (optional)
  89695. * @param timeout timeout settings for the setTimeout function. default - 0.
  89696. * @returns the created async loop object
  89697. */
  89698. static SyncAsyncForLoop(iterations: number, syncedIterations: number, fn: (iteration: number) => void, callback: () => void, breakFunction?: () => boolean, timeout?: number): AsyncLoop;
  89699. }
  89700. }
  89701. declare module BABYLON {
  89702. /** @hidden */
  89703. export interface ICollisionCoordinator {
  89704. createCollider(): Collider;
  89705. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: Nullable<AbstractMesh>, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  89706. init(scene: Scene): void;
  89707. }
  89708. /** @hidden */
  89709. export class DefaultCollisionCoordinator implements ICollisionCoordinator {
  89710. private _scene;
  89711. private _scaledPosition;
  89712. private _scaledVelocity;
  89713. private _finalPosition;
  89714. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: AbstractMesh, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  89715. createCollider(): Collider;
  89716. init(scene: Scene): void;
  89717. private _collideWithWorld;
  89718. }
  89719. }
  89720. declare module BABYLON {
  89721. /**
  89722. * This class defines the direct association between an animation and a target
  89723. */
  89724. export class TargetedAnimation {
  89725. /**
  89726. * Animation to perform
  89727. */
  89728. animation: Animation;
  89729. /**
  89730. * Target to animate
  89731. */
  89732. target: any;
  89733. }
  89734. /**
  89735. * Use this class to create coordinated animations on multiple targets
  89736. */
  89737. export class AnimationGroup implements IDisposable {
  89738. /** The name of the animation group */
  89739. name: string;
  89740. private _scene;
  89741. private _targetedAnimations;
  89742. private _animatables;
  89743. private _from;
  89744. private _to;
  89745. private _isStarted;
  89746. private _isPaused;
  89747. private _speedRatio;
  89748. /**
  89749. * Gets or sets the unique id of the node
  89750. */
  89751. uniqueId: number;
  89752. /**
  89753. * This observable will notify when one animation have ended
  89754. */
  89755. onAnimationEndObservable: Observable<TargetedAnimation>;
  89756. /**
  89757. * Observer raised when one animation loops
  89758. */
  89759. onAnimationLoopObservable: Observable<TargetedAnimation>;
  89760. /**
  89761. * This observable will notify when all animations have ended.
  89762. */
  89763. onAnimationGroupEndObservable: Observable<AnimationGroup>;
  89764. /**
  89765. * This observable will notify when all animations have paused.
  89766. */
  89767. onAnimationGroupPauseObservable: Observable<AnimationGroup>;
  89768. /**
  89769. * This observable will notify when all animations are playing.
  89770. */
  89771. onAnimationGroupPlayObservable: Observable<AnimationGroup>;
  89772. /**
  89773. * Gets the first frame
  89774. */
  89775. readonly from: number;
  89776. /**
  89777. * Gets the last frame
  89778. */
  89779. readonly to: number;
  89780. /**
  89781. * Define if the animations are started
  89782. */
  89783. readonly isStarted: boolean;
  89784. /**
  89785. * Gets a value indicating that the current group is playing
  89786. */
  89787. readonly isPlaying: boolean;
  89788. /**
  89789. * Gets or sets the speed ratio to use for all animations
  89790. */
  89791. /**
  89792. * Gets or sets the speed ratio to use for all animations
  89793. */
  89794. speedRatio: number;
  89795. /**
  89796. * Gets the targeted animations for this animation group
  89797. */
  89798. readonly targetedAnimations: Array<TargetedAnimation>;
  89799. /**
  89800. * returning the list of animatables controlled by this animation group.
  89801. */
  89802. readonly animatables: Array<Animatable>;
  89803. /**
  89804. * Instantiates a new Animation Group.
  89805. * This helps managing several animations at once.
  89806. * @see http://doc.babylonjs.com/how_to/group
  89807. * @param name Defines the name of the group
  89808. * @param scene Defines the scene the group belongs to
  89809. */
  89810. constructor(
  89811. /** The name of the animation group */
  89812. name: string, scene?: Nullable<Scene>);
  89813. /**
  89814. * Add an animation (with its target) in the group
  89815. * @param animation defines the animation we want to add
  89816. * @param target defines the target of the animation
  89817. * @returns the TargetedAnimation object
  89818. */
  89819. addTargetedAnimation(animation: Animation, target: any): TargetedAnimation;
  89820. /**
  89821. * This function will normalize every animation in the group to make sure they all go from beginFrame to endFrame
  89822. * It can add constant keys at begin or end
  89823. * @param beginFrame defines the new begin frame for all animations or the smallest begin frame of all animations if null (defaults to null)
  89824. * @param endFrame defines the new end frame for all animations or the largest end frame of all animations if null (defaults to null)
  89825. * @returns the animation group
  89826. */
  89827. normalize(beginFrame?: Nullable<number>, endFrame?: Nullable<number>): AnimationGroup;
  89828. /**
  89829. * Start all animations on given targets
  89830. * @param loop defines if animations must loop
  89831. * @param speedRatio defines the ratio to apply to animation speed (1 by default)
  89832. * @param from defines the from key (optional)
  89833. * @param to defines the to key (optional)
  89834. * @returns the current animation group
  89835. */
  89836. start(loop?: boolean, speedRatio?: number, from?: number, to?: number): AnimationGroup;
  89837. /**
  89838. * Pause all animations
  89839. * @returns the animation group
  89840. */
  89841. pause(): AnimationGroup;
  89842. /**
  89843. * Play all animations to initial state
  89844. * This function will start() the animations if they were not started or will restart() them if they were paused
  89845. * @param loop defines if animations must loop
  89846. * @returns the animation group
  89847. */
  89848. play(loop?: boolean): AnimationGroup;
  89849. /**
  89850. * Reset all animations to initial state
  89851. * @returns the animation group
  89852. */
  89853. reset(): AnimationGroup;
  89854. /**
  89855. * Restart animations from key 0
  89856. * @returns the animation group
  89857. */
  89858. restart(): AnimationGroup;
  89859. /**
  89860. * Stop all animations
  89861. * @returns the animation group
  89862. */
  89863. stop(): AnimationGroup;
  89864. /**
  89865. * Set animation weight for all animatables
  89866. * @param weight defines the weight to use
  89867. * @return the animationGroup
  89868. * @see http://doc.babylonjs.com/babylon101/animations#animation-weights
  89869. */
  89870. setWeightForAllAnimatables(weight: number): AnimationGroup;
  89871. /**
  89872. * Synchronize and normalize all animatables with a source animatable
  89873. * @param root defines the root animatable to synchronize with
  89874. * @return the animationGroup
  89875. * @see http://doc.babylonjs.com/babylon101/animations#animation-weights
  89876. */
  89877. syncAllAnimationsWith(root: Animatable): AnimationGroup;
  89878. /**
  89879. * Goes to a specific frame in this animation group
  89880. * @param frame the frame number to go to
  89881. * @return the animationGroup
  89882. */
  89883. goToFrame(frame: number): AnimationGroup;
  89884. /**
  89885. * Dispose all associated resources
  89886. */
  89887. dispose(): void;
  89888. private _checkAnimationGroupEnded;
  89889. /**
  89890. * Clone the current animation group and returns a copy
  89891. * @param newName defines the name of the new group
  89892. * @param targetConverter defines an optional function used to convert current animation targets to new ones
  89893. * @returns the new aniamtion group
  89894. */
  89895. clone(newName: string, targetConverter?: (oldTarget: any) => any): AnimationGroup;
  89896. /**
  89897. * Returns a new AnimationGroup object parsed from the source provided.
  89898. * @param parsedAnimationGroup defines the source
  89899. * @param scene defines the scene that will receive the animationGroup
  89900. * @returns a new AnimationGroup
  89901. */
  89902. static Parse(parsedAnimationGroup: any, scene: Scene): AnimationGroup;
  89903. /**
  89904. * Returns the string "AnimationGroup"
  89905. * @returns "AnimationGroup"
  89906. */
  89907. getClassName(): string;
  89908. /**
  89909. * Creates a detailled string about the object
  89910. * @param fullDetails defines if the output string will support multiple levels of logging within scene loading
  89911. * @returns a string representing the object
  89912. */
  89913. toString(fullDetails?: boolean): string;
  89914. }
  89915. }
  89916. declare module BABYLON {
  89917. /**
  89918. * Define an interface for all classes that will hold resources
  89919. */
  89920. export interface IDisposable {
  89921. /**
  89922. * Releases all held resources
  89923. */
  89924. dispose(): void;
  89925. }
  89926. /** Interface defining initialization parameters for Scene class */
  89927. export interface SceneOptions {
  89928. /**
  89929. * Defines that scene should keep up-to-date a map of geometry to enable fast look-up by uniqueId
  89930. * It will improve performance when the number of geometries becomes important.
  89931. */
  89932. useGeometryUniqueIdsMap?: boolean;
  89933. /**
  89934. * Defines that each material of the scene should keep up-to-date a map of referencing meshes for fast diposing
  89935. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  89936. */
  89937. useMaterialMeshMap?: boolean;
  89938. /**
  89939. * Defines that each mesh of the scene should keep up-to-date a map of referencing cloned meshes for fast diposing
  89940. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  89941. */
  89942. useClonedMeshhMap?: boolean;
  89943. }
  89944. /**
  89945. * Represents a scene to be rendered by the engine.
  89946. * @see http://doc.babylonjs.com/features/scene
  89947. */
  89948. export class Scene extends AbstractScene implements IAnimatable {
  89949. private static _uniqueIdCounter;
  89950. /** The fog is deactivated */
  89951. static readonly FOGMODE_NONE: number;
  89952. /** The fog density is following an exponential function */
  89953. static readonly FOGMODE_EXP: number;
  89954. /** The fog density is following an exponential function faster than FOGMODE_EXP */
  89955. static readonly FOGMODE_EXP2: number;
  89956. /** The fog density is following a linear function. */
  89957. static readonly FOGMODE_LINEAR: number;
  89958. /**
  89959. * Gets or sets the minimum deltatime when deterministic lock step is enabled
  89960. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  89961. */
  89962. static MinDeltaTime: number;
  89963. /**
  89964. * Gets or sets the maximum deltatime when deterministic lock step is enabled
  89965. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  89966. */
  89967. static MaxDeltaTime: number;
  89968. /**
  89969. * Factory used to create the default material.
  89970. * @param name The name of the material to create
  89971. * @param scene The scene to create the material for
  89972. * @returns The default material
  89973. */
  89974. static DefaultMaterialFactory(scene: Scene): Material;
  89975. /**
  89976. * Factory used to create the a collision coordinator.
  89977. * @returns The collision coordinator
  89978. */
  89979. static CollisionCoordinatorFactory(): ICollisionCoordinator;
  89980. /** @hidden */
  89981. readonly _isScene: boolean;
  89982. /**
  89983. * Gets or sets a boolean that indicates if the scene must clear the render buffer before rendering a frame
  89984. */
  89985. autoClear: boolean;
  89986. /**
  89987. * Gets or sets a boolean that indicates if the scene must clear the depth and stencil buffers before rendering a frame
  89988. */
  89989. autoClearDepthAndStencil: boolean;
  89990. /**
  89991. * Defines the color used to clear the render buffer (Default is (0.2, 0.2, 0.3, 1.0))
  89992. */
  89993. clearColor: Color4;
  89994. /**
  89995. * Defines the color used to simulate the ambient color (Default is (0, 0, 0))
  89996. */
  89997. ambientColor: Color3;
  89998. /** @hidden */
  89999. _environmentBRDFTexture: BaseTexture;
  90000. /** @hidden */
  90001. protected _environmentTexture: Nullable<BaseTexture>;
  90002. /**
  90003. * Texture used in all pbr material as the reflection texture.
  90004. * As in the majority of the scene they are the same (exception for multi room and so on),
  90005. * this is easier to reference from here than from all the materials.
  90006. */
  90007. /**
  90008. * Texture used in all pbr material as the reflection texture.
  90009. * As in the majority of the scene they are the same (exception for multi room and so on),
  90010. * this is easier to set here than in all the materials.
  90011. */
  90012. environmentTexture: Nullable<BaseTexture>;
  90013. /** @hidden */
  90014. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  90015. /**
  90016. * Default image processing configuration used either in the rendering
  90017. * Forward main pass or through the imageProcessingPostProcess if present.
  90018. * As in the majority of the scene they are the same (exception for multi camera),
  90019. * this is easier to reference from here than from all the materials and post process.
  90020. *
  90021. * No setter as we it is a shared configuration, you can set the values instead.
  90022. */
  90023. readonly imageProcessingConfiguration: ImageProcessingConfiguration;
  90024. private _forceWireframe;
  90025. /**
  90026. * Gets or sets a boolean indicating if all rendering must be done in wireframe
  90027. */
  90028. forceWireframe: boolean;
  90029. private _forcePointsCloud;
  90030. /**
  90031. * Gets or sets a boolean indicating if all rendering must be done in point cloud
  90032. */
  90033. forcePointsCloud: boolean;
  90034. /**
  90035. * Gets or sets the active clipplane 1
  90036. */
  90037. clipPlane: Nullable<Plane>;
  90038. /**
  90039. * Gets or sets the active clipplane 2
  90040. */
  90041. clipPlane2: Nullable<Plane>;
  90042. /**
  90043. * Gets or sets the active clipplane 3
  90044. */
  90045. clipPlane3: Nullable<Plane>;
  90046. /**
  90047. * Gets or sets the active clipplane 4
  90048. */
  90049. clipPlane4: Nullable<Plane>;
  90050. /**
  90051. * Gets or sets a boolean indicating if animations are enabled
  90052. */
  90053. animationsEnabled: boolean;
  90054. private _animationPropertiesOverride;
  90055. /**
  90056. * Gets or sets the animation properties override
  90057. */
  90058. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  90059. /**
  90060. * Gets or sets a boolean indicating if a constant deltatime has to be used
  90061. * This is mostly useful for testing purposes when you do not want the animations to scale with the framerate
  90062. */
  90063. useConstantAnimationDeltaTime: boolean;
  90064. /**
  90065. * Gets or sets a boolean indicating if the scene must keep the meshUnderPointer property updated
  90066. * Please note that it requires to run a ray cast through the scene on every frame
  90067. */
  90068. constantlyUpdateMeshUnderPointer: boolean;
  90069. /**
  90070. * Defines the HTML cursor to use when hovering over interactive elements
  90071. */
  90072. hoverCursor: string;
  90073. /**
  90074. * Defines the HTML default cursor to use (empty by default)
  90075. */
  90076. defaultCursor: string;
  90077. /**
  90078. * This is used to call preventDefault() on pointer down
  90079. * in order to block unwanted artifacts like system double clicks
  90080. */
  90081. preventDefaultOnPointerDown: boolean;
  90082. /**
  90083. * This is used to call preventDefault() on pointer up
  90084. * in order to block unwanted artifacts like system double clicks
  90085. */
  90086. preventDefaultOnPointerUp: boolean;
  90087. /**
  90088. * Gets or sets user defined metadata
  90089. */
  90090. metadata: any;
  90091. /**
  90092. * For internal use only. Please do not use.
  90093. */
  90094. reservedDataStore: any;
  90095. /**
  90096. * Gets the name of the plugin used to load this scene (null by default)
  90097. */
  90098. loadingPluginName: string;
  90099. /**
  90100. * Use this array to add regular expressions used to disable offline support for specific urls
  90101. */
  90102. disableOfflineSupportExceptionRules: RegExp[];
  90103. /**
  90104. * An event triggered when the scene is disposed.
  90105. */
  90106. onDisposeObservable: Observable<Scene>;
  90107. private _onDisposeObserver;
  90108. /** Sets a function to be executed when this scene is disposed. */
  90109. onDispose: () => void;
  90110. /**
  90111. * An event triggered before rendering the scene (right after animations and physics)
  90112. */
  90113. onBeforeRenderObservable: Observable<Scene>;
  90114. private _onBeforeRenderObserver;
  90115. /** Sets a function to be executed before rendering this scene */
  90116. beforeRender: Nullable<() => void>;
  90117. /**
  90118. * An event triggered after rendering the scene
  90119. */
  90120. onAfterRenderObservable: Observable<Scene>;
  90121. private _onAfterRenderObserver;
  90122. /** Sets a function to be executed after rendering this scene */
  90123. afterRender: Nullable<() => void>;
  90124. /**
  90125. * An event triggered before animating the scene
  90126. */
  90127. onBeforeAnimationsObservable: Observable<Scene>;
  90128. /**
  90129. * An event triggered after animations processing
  90130. */
  90131. onAfterAnimationsObservable: Observable<Scene>;
  90132. /**
  90133. * An event triggered before draw calls are ready to be sent
  90134. */
  90135. onBeforeDrawPhaseObservable: Observable<Scene>;
  90136. /**
  90137. * An event triggered after draw calls have been sent
  90138. */
  90139. onAfterDrawPhaseObservable: Observable<Scene>;
  90140. /**
  90141. * An event triggered when the scene is ready
  90142. */
  90143. onReadyObservable: Observable<Scene>;
  90144. /**
  90145. * An event triggered before rendering a camera
  90146. */
  90147. onBeforeCameraRenderObservable: Observable<Camera>;
  90148. private _onBeforeCameraRenderObserver;
  90149. /** Sets a function to be executed before rendering a camera*/
  90150. beforeCameraRender: () => void;
  90151. /**
  90152. * An event triggered after rendering a camera
  90153. */
  90154. onAfterCameraRenderObservable: Observable<Camera>;
  90155. private _onAfterCameraRenderObserver;
  90156. /** Sets a function to be executed after rendering a camera*/
  90157. afterCameraRender: () => void;
  90158. /**
  90159. * An event triggered when active meshes evaluation is about to start
  90160. */
  90161. onBeforeActiveMeshesEvaluationObservable: Observable<Scene>;
  90162. /**
  90163. * An event triggered when active meshes evaluation is done
  90164. */
  90165. onAfterActiveMeshesEvaluationObservable: Observable<Scene>;
  90166. /**
  90167. * An event triggered when particles rendering is about to start
  90168. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  90169. */
  90170. onBeforeParticlesRenderingObservable: Observable<Scene>;
  90171. /**
  90172. * An event triggered when particles rendering is done
  90173. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  90174. */
  90175. onAfterParticlesRenderingObservable: Observable<Scene>;
  90176. /**
  90177. * An event triggered when SceneLoader.Append or SceneLoader.Load or SceneLoader.ImportMesh were successfully executed
  90178. */
  90179. onDataLoadedObservable: Observable<Scene>;
  90180. /**
  90181. * An event triggered when a camera is created
  90182. */
  90183. onNewCameraAddedObservable: Observable<Camera>;
  90184. /**
  90185. * An event triggered when a camera is removed
  90186. */
  90187. onCameraRemovedObservable: Observable<Camera>;
  90188. /**
  90189. * An event triggered when a light is created
  90190. */
  90191. onNewLightAddedObservable: Observable<Light>;
  90192. /**
  90193. * An event triggered when a light is removed
  90194. */
  90195. onLightRemovedObservable: Observable<Light>;
  90196. /**
  90197. * An event triggered when a geometry is created
  90198. */
  90199. onNewGeometryAddedObservable: Observable<Geometry>;
  90200. /**
  90201. * An event triggered when a geometry is removed
  90202. */
  90203. onGeometryRemovedObservable: Observable<Geometry>;
  90204. /**
  90205. * An event triggered when a transform node is created
  90206. */
  90207. onNewTransformNodeAddedObservable: Observable<TransformNode>;
  90208. /**
  90209. * An event triggered when a transform node is removed
  90210. */
  90211. onTransformNodeRemovedObservable: Observable<TransformNode>;
  90212. /**
  90213. * An event triggered when a mesh is created
  90214. */
  90215. onNewMeshAddedObservable: Observable<AbstractMesh>;
  90216. /**
  90217. * An event triggered when a mesh is removed
  90218. */
  90219. onMeshRemovedObservable: Observable<AbstractMesh>;
  90220. /**
  90221. * An event triggered when a skeleton is created
  90222. */
  90223. onNewSkeletonAddedObservable: Observable<Skeleton>;
  90224. /**
  90225. * An event triggered when a skeleton is removed
  90226. */
  90227. onSkeletonRemovedObservable: Observable<Skeleton>;
  90228. /**
  90229. * An event triggered when a material is created
  90230. */
  90231. onNewMaterialAddedObservable: Observable<Material>;
  90232. /**
  90233. * An event triggered when a material is removed
  90234. */
  90235. onMaterialRemovedObservable: Observable<Material>;
  90236. /**
  90237. * An event triggered when a texture is created
  90238. */
  90239. onNewTextureAddedObservable: Observable<BaseTexture>;
  90240. /**
  90241. * An event triggered when a texture is removed
  90242. */
  90243. onTextureRemovedObservable: Observable<BaseTexture>;
  90244. /**
  90245. * An event triggered when render targets are about to be rendered
  90246. * Can happen multiple times per frame.
  90247. */
  90248. onBeforeRenderTargetsRenderObservable: Observable<Scene>;
  90249. /**
  90250. * An event triggered when render targets were rendered.
  90251. * Can happen multiple times per frame.
  90252. */
  90253. onAfterRenderTargetsRenderObservable: Observable<Scene>;
  90254. /**
  90255. * An event triggered before calculating deterministic simulation step
  90256. */
  90257. onBeforeStepObservable: Observable<Scene>;
  90258. /**
  90259. * An event triggered after calculating deterministic simulation step
  90260. */
  90261. onAfterStepObservable: Observable<Scene>;
  90262. /**
  90263. * An event triggered when the activeCamera property is updated
  90264. */
  90265. onActiveCameraChanged: Observable<Scene>;
  90266. /**
  90267. * This Observable will be triggered before rendering each renderingGroup of each rendered camera.
  90268. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  90269. * 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)
  90270. */
  90271. onBeforeRenderingGroupObservable: Observable<RenderingGroupInfo>;
  90272. /**
  90273. * This Observable will be triggered after rendering each renderingGroup of each rendered camera.
  90274. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  90275. * 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)
  90276. */
  90277. onAfterRenderingGroupObservable: Observable<RenderingGroupInfo>;
  90278. /**
  90279. * This Observable will when a mesh has been imported into the scene.
  90280. */
  90281. onMeshImportedObservable: Observable<AbstractMesh>;
  90282. /**
  90283. * Gets or sets a user defined funtion to select LOD from a mesh and a camera.
  90284. * By default this function is undefined and Babylon.js will select LOD based on distance to camera
  90285. */
  90286. customLODSelector: (mesh: AbstractMesh, camera: Camera) => Nullable<AbstractMesh>;
  90287. /** @hidden */
  90288. _registeredForLateAnimationBindings: SmartArrayNoDuplicate<any>;
  90289. /**
  90290. * Gets or sets a predicate used to select candidate meshes for a pointer down event
  90291. */
  90292. pointerDownPredicate: (Mesh: AbstractMesh) => boolean;
  90293. /**
  90294. * Gets or sets a predicate used to select candidate meshes for a pointer up event
  90295. */
  90296. pointerUpPredicate: (Mesh: AbstractMesh) => boolean;
  90297. /**
  90298. * Gets or sets a predicate used to select candidate meshes for a pointer move event
  90299. */
  90300. pointerMovePredicate: (Mesh: AbstractMesh) => boolean;
  90301. private _onPointerMove;
  90302. private _onPointerDown;
  90303. private _onPointerUp;
  90304. /** Callback called when a pointer move is detected */
  90305. onPointerMove: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  90306. /** Callback called when a pointer down is detected */
  90307. onPointerDown: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  90308. /** Callback called when a pointer up is detected */
  90309. onPointerUp: (evt: PointerEvent, pickInfo: Nullable<PickingInfo>, type: PointerEventTypes) => void;
  90310. /** Callback called when a pointer pick is detected */
  90311. onPointerPick: (evt: PointerEvent, pickInfo: PickingInfo) => void;
  90312. /**
  90313. * 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).
  90314. * You have the possibility to skip the process and the call to onPointerObservable by setting PointerInfoPre.skipOnPointerObservable to true
  90315. */
  90316. onPrePointerObservable: Observable<PointerInfoPre>;
  90317. /**
  90318. * Observable event triggered each time an input event is received from the rendering canvas
  90319. */
  90320. onPointerObservable: Observable<PointerInfo>;
  90321. /**
  90322. * Gets the pointer coordinates without any translation (ie. straight out of the pointer event)
  90323. */
  90324. readonly unTranslatedPointer: Vector2;
  90325. /** The distance in pixel that you have to move to prevent some events */
  90326. static DragMovementThreshold: number;
  90327. /** Time in milliseconds to wait to raise long press events if button is still pressed */
  90328. static LongPressDelay: number;
  90329. /** Time in milliseconds with two consecutive clicks will be considered as a double click */
  90330. static DoubleClickDelay: number;
  90331. /** If you need to check double click without raising a single click at first click, enable this flag */
  90332. static ExclusiveDoubleClickMode: boolean;
  90333. private _initClickEvent;
  90334. private _initActionManager;
  90335. private _delayedSimpleClick;
  90336. private _delayedSimpleClickTimeout;
  90337. private _previousDelayedSimpleClickTimeout;
  90338. private _meshPickProceed;
  90339. private _previousButtonPressed;
  90340. private _currentPickResult;
  90341. private _previousPickResult;
  90342. private _totalPointersPressed;
  90343. private _doubleClickOccured;
  90344. /** Define this parameter if you are using multiple cameras and you want to specify which one should be used for pointer position */
  90345. cameraToUseForPointers: Nullable<Camera>;
  90346. private _pointerX;
  90347. private _pointerY;
  90348. private _unTranslatedPointerX;
  90349. private _unTranslatedPointerY;
  90350. private _startingPointerPosition;
  90351. private _previousStartingPointerPosition;
  90352. private _startingPointerTime;
  90353. private _previousStartingPointerTime;
  90354. private _pointerCaptures;
  90355. private _timeAccumulator;
  90356. private _currentStepId;
  90357. private _currentInternalStep;
  90358. /** @hidden */
  90359. _mirroredCameraPosition: Nullable<Vector3>;
  90360. /**
  90361. * This observable event is triggered when any keyboard event si raised and registered during Scene.attachControl()
  90362. * You have the possibility to skip the process and the call to onKeyboardObservable by setting KeyboardInfoPre.skipOnPointerObservable to true
  90363. */
  90364. onPreKeyboardObservable: Observable<KeyboardInfoPre>;
  90365. /**
  90366. * Observable event triggered each time an keyboard event is received from the hosting window
  90367. */
  90368. onKeyboardObservable: Observable<KeyboardInfo>;
  90369. private _onKeyDown;
  90370. private _onKeyUp;
  90371. private _onCanvasFocusObserver;
  90372. private _onCanvasBlurObserver;
  90373. private _useRightHandedSystem;
  90374. /**
  90375. * Gets or sets a boolean indicating if the scene must use right-handed coordinates system
  90376. */
  90377. useRightHandedSystem: boolean;
  90378. /**
  90379. * Sets the step Id used by deterministic lock step
  90380. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  90381. * @param newStepId defines the step Id
  90382. */
  90383. setStepId(newStepId: number): void;
  90384. /**
  90385. * Gets the step Id used by deterministic lock step
  90386. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  90387. * @returns the step Id
  90388. */
  90389. getStepId(): number;
  90390. /**
  90391. * Gets the internal step used by deterministic lock step
  90392. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  90393. * @returns the internal step
  90394. */
  90395. getInternalStep(): number;
  90396. private _fogEnabled;
  90397. /**
  90398. * Gets or sets a boolean indicating if fog is enabled on this scene
  90399. * @see http://doc.babylonjs.com/babylon101/environment#fog
  90400. * (Default is true)
  90401. */
  90402. fogEnabled: boolean;
  90403. private _fogMode;
  90404. /**
  90405. * Gets or sets the fog mode to use
  90406. * @see http://doc.babylonjs.com/babylon101/environment#fog
  90407. * | mode | value |
  90408. * | --- | --- |
  90409. * | FOGMODE_NONE | 0 |
  90410. * | FOGMODE_EXP | 1 |
  90411. * | FOGMODE_EXP2 | 2 |
  90412. * | FOGMODE_LINEAR | 3 |
  90413. */
  90414. fogMode: number;
  90415. /**
  90416. * Gets or sets the fog color to use
  90417. * @see http://doc.babylonjs.com/babylon101/environment#fog
  90418. * (Default is Color3(0.2, 0.2, 0.3))
  90419. */
  90420. fogColor: Color3;
  90421. /**
  90422. * Gets or sets the fog density to use
  90423. * @see http://doc.babylonjs.com/babylon101/environment#fog
  90424. * (Default is 0.1)
  90425. */
  90426. fogDensity: number;
  90427. /**
  90428. * Gets or sets the fog start distance to use
  90429. * @see http://doc.babylonjs.com/babylon101/environment#fog
  90430. * (Default is 0)
  90431. */
  90432. fogStart: number;
  90433. /**
  90434. * Gets or sets the fog end distance to use
  90435. * @see http://doc.babylonjs.com/babylon101/environment#fog
  90436. * (Default is 1000)
  90437. */
  90438. fogEnd: number;
  90439. private _shadowsEnabled;
  90440. /**
  90441. * Gets or sets a boolean indicating if shadows are enabled on this scene
  90442. */
  90443. shadowsEnabled: boolean;
  90444. private _lightsEnabled;
  90445. /**
  90446. * Gets or sets a boolean indicating if lights are enabled on this scene
  90447. */
  90448. lightsEnabled: boolean;
  90449. /** All of the active cameras added to this scene. */
  90450. activeCameras: Camera[];
  90451. private _activeCamera;
  90452. /** Gets or sets the current active camera */
  90453. activeCamera: Nullable<Camera>;
  90454. private _defaultMaterial;
  90455. /** The default material used on meshes when no material is affected */
  90456. /** The default material used on meshes when no material is affected */
  90457. defaultMaterial: Material;
  90458. private _texturesEnabled;
  90459. /**
  90460. * Gets or sets a boolean indicating if textures are enabled on this scene
  90461. */
  90462. texturesEnabled: boolean;
  90463. /**
  90464. * Gets or sets a boolean indicating if particles are enabled on this scene
  90465. */
  90466. particlesEnabled: boolean;
  90467. /**
  90468. * Gets or sets a boolean indicating if sprites are enabled on this scene
  90469. */
  90470. spritesEnabled: boolean;
  90471. private _skeletonsEnabled;
  90472. /**
  90473. * Gets or sets a boolean indicating if skeletons are enabled on this scene
  90474. */
  90475. skeletonsEnabled: boolean;
  90476. /**
  90477. * Gets or sets a boolean indicating if lens flares are enabled on this scene
  90478. */
  90479. lensFlaresEnabled: boolean;
  90480. /**
  90481. * Gets or sets a boolean indicating if collisions are enabled on this scene
  90482. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  90483. */
  90484. collisionsEnabled: boolean;
  90485. private _collisionCoordinator;
  90486. /** @hidden */
  90487. readonly collisionCoordinator: ICollisionCoordinator;
  90488. /**
  90489. * Defines the gravity applied to this scene (used only for collisions)
  90490. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  90491. */
  90492. gravity: Vector3;
  90493. /**
  90494. * Gets or sets a boolean indicating if postprocesses are enabled on this scene
  90495. */
  90496. postProcessesEnabled: boolean;
  90497. /**
  90498. * The list of postprocesses added to the scene
  90499. */
  90500. postProcesses: PostProcess[];
  90501. /**
  90502. * Gets the current postprocess manager
  90503. */
  90504. postProcessManager: PostProcessManager;
  90505. /**
  90506. * Gets or sets a boolean indicating if render targets are enabled on this scene
  90507. */
  90508. renderTargetsEnabled: boolean;
  90509. /**
  90510. * Gets or sets a boolean indicating if next render targets must be dumped as image for debugging purposes
  90511. * We recommend not using it and instead rely on Spector.js: http://spector.babylonjs.com
  90512. */
  90513. dumpNextRenderTargets: boolean;
  90514. /**
  90515. * The list of user defined render targets added to the scene
  90516. */
  90517. customRenderTargets: RenderTargetTexture[];
  90518. /**
  90519. * Defines if texture loading must be delayed
  90520. * If true, textures will only be loaded when they need to be rendered
  90521. */
  90522. useDelayedTextureLoading: boolean;
  90523. /**
  90524. * Gets the list of meshes imported to the scene through SceneLoader
  90525. */
  90526. importedMeshesFiles: String[];
  90527. /**
  90528. * Gets or sets a boolean indicating if probes are enabled on this scene
  90529. */
  90530. probesEnabled: boolean;
  90531. /**
  90532. * Gets or sets the current offline provider to use to store scene data
  90533. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  90534. */
  90535. offlineProvider: IOfflineProvider;
  90536. /**
  90537. * Gets or sets the action manager associated with the scene
  90538. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  90539. */
  90540. actionManager: AbstractActionManager;
  90541. private _meshesForIntersections;
  90542. /**
  90543. * Gets or sets a boolean indicating if procedural textures are enabled on this scene
  90544. */
  90545. proceduralTexturesEnabled: boolean;
  90546. private _engine;
  90547. private _totalVertices;
  90548. /** @hidden */
  90549. _activeIndices: PerfCounter;
  90550. /** @hidden */
  90551. _activeParticles: PerfCounter;
  90552. /** @hidden */
  90553. _activeBones: PerfCounter;
  90554. private _animationRatio;
  90555. /** @hidden */
  90556. _animationTimeLast: number;
  90557. /** @hidden */
  90558. _animationTime: number;
  90559. /**
  90560. * Gets or sets a general scale for animation speed
  90561. * @see https://www.babylonjs-playground.com/#IBU2W7#3
  90562. */
  90563. animationTimeScale: number;
  90564. /** @hidden */
  90565. _cachedMaterial: Nullable<Material>;
  90566. /** @hidden */
  90567. _cachedEffect: Nullable<Effect>;
  90568. /** @hidden */
  90569. _cachedVisibility: Nullable<number>;
  90570. private _renderId;
  90571. private _frameId;
  90572. private _executeWhenReadyTimeoutId;
  90573. private _intermediateRendering;
  90574. private _viewUpdateFlag;
  90575. private _projectionUpdateFlag;
  90576. private _alternateViewUpdateFlag;
  90577. private _alternateProjectionUpdateFlag;
  90578. /** @hidden */
  90579. _toBeDisposed: Nullable<IDisposable>[];
  90580. private _activeRequests;
  90581. /** @hidden */
  90582. _pendingData: any[];
  90583. private _isDisposed;
  90584. /**
  90585. * Gets or sets a boolean indicating that all submeshes of active meshes must be rendered
  90586. * Use this boolean to avoid computing frustum clipping on submeshes (This could help when you are CPU bound)
  90587. */
  90588. dispatchAllSubMeshesOfActiveMeshes: boolean;
  90589. private _activeMeshes;
  90590. private _processedMaterials;
  90591. private _renderTargets;
  90592. /** @hidden */
  90593. _activeParticleSystems: SmartArray<IParticleSystem>;
  90594. private _activeSkeletons;
  90595. private _softwareSkinnedMeshes;
  90596. private _renderingManager;
  90597. /** @hidden */
  90598. _activeAnimatables: Animatable[];
  90599. private _transformMatrix;
  90600. private _sceneUbo;
  90601. private _alternateSceneUbo;
  90602. private _viewMatrix;
  90603. private _projectionMatrix;
  90604. private _alternateViewMatrix;
  90605. private _alternateProjectionMatrix;
  90606. private _alternateTransformMatrix;
  90607. private _useAlternateCameraConfiguration;
  90608. private _alternateRendering;
  90609. private _wheelEventName;
  90610. /** @hidden */
  90611. _forcedViewPosition: Nullable<Vector3>;
  90612. /** @hidden */
  90613. readonly _isAlternateRenderingEnabled: boolean;
  90614. private _frustumPlanes;
  90615. /**
  90616. * Gets the list of frustum planes (built from the active camera)
  90617. */
  90618. readonly frustumPlanes: Plane[];
  90619. /**
  90620. * Gets or sets a boolean indicating if lights must be sorted by priority (off by default)
  90621. * This is useful if there are more lights that the maximum simulteanous authorized
  90622. */
  90623. requireLightSorting: boolean;
  90624. /** @hidden */
  90625. readonly useMaterialMeshMap: boolean;
  90626. /** @hidden */
  90627. readonly useClonedMeshhMap: boolean;
  90628. private _pointerOverMesh;
  90629. private _pickedDownMesh;
  90630. private _pickedUpMesh;
  90631. private _externalData;
  90632. private _uid;
  90633. /**
  90634. * @hidden
  90635. * Backing store of defined scene components.
  90636. */
  90637. _components: ISceneComponent[];
  90638. /**
  90639. * @hidden
  90640. * Backing store of defined scene components.
  90641. */
  90642. _serializableComponents: ISceneSerializableComponent[];
  90643. /**
  90644. * List of components to register on the next registration step.
  90645. */
  90646. private _transientComponents;
  90647. /**
  90648. * Registers the transient components if needed.
  90649. */
  90650. private _registerTransientComponents;
  90651. /**
  90652. * @hidden
  90653. * Add a component to the scene.
  90654. * Note that the ccomponent could be registered on th next frame if this is called after
  90655. * the register component stage.
  90656. * @param component Defines the component to add to the scene
  90657. */
  90658. _addComponent(component: ISceneComponent): void;
  90659. /**
  90660. * @hidden
  90661. * Gets a component from the scene.
  90662. * @param name defines the name of the component to retrieve
  90663. * @returns the component or null if not present
  90664. */
  90665. _getComponent(name: string): Nullable<ISceneComponent>;
  90666. /**
  90667. * @hidden
  90668. * Defines the actions happening before camera updates.
  90669. */
  90670. _beforeCameraUpdateStage: Stage<SimpleStageAction>;
  90671. /**
  90672. * @hidden
  90673. * Defines the actions happening before clear the canvas.
  90674. */
  90675. _beforeClearStage: Stage<SimpleStageAction>;
  90676. /**
  90677. * @hidden
  90678. * Defines the actions when collecting render targets for the frame.
  90679. */
  90680. _gatherRenderTargetsStage: Stage<RenderTargetsStageAction>;
  90681. /**
  90682. * @hidden
  90683. * Defines the actions happening for one camera in the frame.
  90684. */
  90685. _gatherActiveCameraRenderTargetsStage: Stage<RenderTargetsStageAction>;
  90686. /**
  90687. * @hidden
  90688. * Defines the actions happening during the per mesh ready checks.
  90689. */
  90690. _isReadyForMeshStage: Stage<MeshStageAction>;
  90691. /**
  90692. * @hidden
  90693. * Defines the actions happening before evaluate active mesh checks.
  90694. */
  90695. _beforeEvaluateActiveMeshStage: Stage<SimpleStageAction>;
  90696. /**
  90697. * @hidden
  90698. * Defines the actions happening during the evaluate sub mesh checks.
  90699. */
  90700. _evaluateSubMeshStage: Stage<EvaluateSubMeshStageAction>;
  90701. /**
  90702. * @hidden
  90703. * Defines the actions happening during the active mesh stage.
  90704. */
  90705. _activeMeshStage: Stage<ActiveMeshStageAction>;
  90706. /**
  90707. * @hidden
  90708. * Defines the actions happening during the per camera render target step.
  90709. */
  90710. _cameraDrawRenderTargetStage: Stage<CameraStageAction>;
  90711. /**
  90712. * @hidden
  90713. * Defines the actions happening just before the active camera is drawing.
  90714. */
  90715. _beforeCameraDrawStage: Stage<CameraStageAction>;
  90716. /**
  90717. * @hidden
  90718. * Defines the actions happening just before a render target is drawing.
  90719. */
  90720. _beforeRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  90721. /**
  90722. * @hidden
  90723. * Defines the actions happening just before a rendering group is drawing.
  90724. */
  90725. _beforeRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  90726. /**
  90727. * @hidden
  90728. * Defines the actions happening just before a mesh is drawing.
  90729. */
  90730. _beforeRenderingMeshStage: Stage<RenderingMeshStageAction>;
  90731. /**
  90732. * @hidden
  90733. * Defines the actions happening just after a mesh has been drawn.
  90734. */
  90735. _afterRenderingMeshStage: Stage<RenderingMeshStageAction>;
  90736. /**
  90737. * @hidden
  90738. * Defines the actions happening just after a rendering group has been drawn.
  90739. */
  90740. _afterRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  90741. /**
  90742. * @hidden
  90743. * Defines the actions happening just after the active camera has been drawn.
  90744. */
  90745. _afterCameraDrawStage: Stage<CameraStageAction>;
  90746. /**
  90747. * @hidden
  90748. * Defines the actions happening just after a render target has been drawn.
  90749. */
  90750. _afterRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  90751. /**
  90752. * @hidden
  90753. * Defines the actions happening just after rendering all cameras and computing intersections.
  90754. */
  90755. _afterRenderStage: Stage<SimpleStageAction>;
  90756. /**
  90757. * @hidden
  90758. * Defines the actions happening when a pointer move event happens.
  90759. */
  90760. _pointerMoveStage: Stage<PointerMoveStageAction>;
  90761. /**
  90762. * @hidden
  90763. * Defines the actions happening when a pointer down event happens.
  90764. */
  90765. _pointerDownStage: Stage<PointerUpDownStageAction>;
  90766. /**
  90767. * @hidden
  90768. * Defines the actions happening when a pointer up event happens.
  90769. */
  90770. _pointerUpStage: Stage<PointerUpDownStageAction>;
  90771. /**
  90772. * an optional map from Geometry Id to Geometry index in the 'geometries' array
  90773. */
  90774. private geometriesByUniqueId;
  90775. /**
  90776. * Creates a new Scene
  90777. * @param engine defines the engine to use to render this scene
  90778. * @param options defines the scene options
  90779. */
  90780. constructor(engine: Engine, options?: SceneOptions);
  90781. private _defaultMeshCandidates;
  90782. /**
  90783. * @hidden
  90784. */
  90785. _getDefaultMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  90786. private _defaultSubMeshCandidates;
  90787. /**
  90788. * @hidden
  90789. */
  90790. _getDefaultSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  90791. /**
  90792. * Sets the default candidate providers for the scene.
  90793. * This sets the getActiveMeshCandidates, getActiveSubMeshCandidates, getIntersectingSubMeshCandidates
  90794. * and getCollidingSubMeshCandidates to their default function
  90795. */
  90796. setDefaultCandidateProviders(): void;
  90797. /**
  90798. * Gets the mesh that is currently under the pointer
  90799. */
  90800. readonly meshUnderPointer: Nullable<AbstractMesh>;
  90801. /**
  90802. * Gets or sets the current on-screen X position of the pointer
  90803. */
  90804. pointerX: number;
  90805. /**
  90806. * Gets or sets the current on-screen Y position of the pointer
  90807. */
  90808. pointerY: number;
  90809. /**
  90810. * Gets the cached material (ie. the latest rendered one)
  90811. * @returns the cached material
  90812. */
  90813. getCachedMaterial(): Nullable<Material>;
  90814. /**
  90815. * Gets the cached effect (ie. the latest rendered one)
  90816. * @returns the cached effect
  90817. */
  90818. getCachedEffect(): Nullable<Effect>;
  90819. /**
  90820. * Gets the cached visibility state (ie. the latest rendered one)
  90821. * @returns the cached visibility state
  90822. */
  90823. getCachedVisibility(): Nullable<number>;
  90824. /**
  90825. * Gets a boolean indicating if the current material / effect / visibility must be bind again
  90826. * @param material defines the current material
  90827. * @param effect defines the current effect
  90828. * @param visibility defines the current visibility state
  90829. * @returns true if one parameter is not cached
  90830. */
  90831. isCachedMaterialInvalid(material: Material, effect: Effect, visibility?: number): boolean;
  90832. /**
  90833. * Gets the engine associated with the scene
  90834. * @returns an Engine
  90835. */
  90836. getEngine(): Engine;
  90837. /**
  90838. * Gets the total number of vertices rendered per frame
  90839. * @returns the total number of vertices rendered per frame
  90840. */
  90841. getTotalVertices(): number;
  90842. /**
  90843. * Gets the performance counter for total vertices
  90844. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  90845. */
  90846. readonly totalVerticesPerfCounter: PerfCounter;
  90847. /**
  90848. * Gets the total number of active indices rendered per frame (You can deduce the number of rendered triangles by dividing this number by 3)
  90849. * @returns the total number of active indices rendered per frame
  90850. */
  90851. getActiveIndices(): number;
  90852. /**
  90853. * Gets the performance counter for active indices
  90854. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  90855. */
  90856. readonly totalActiveIndicesPerfCounter: PerfCounter;
  90857. /**
  90858. * Gets the total number of active particles rendered per frame
  90859. * @returns the total number of active particles rendered per frame
  90860. */
  90861. getActiveParticles(): number;
  90862. /**
  90863. * Gets the performance counter for active particles
  90864. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  90865. */
  90866. readonly activeParticlesPerfCounter: PerfCounter;
  90867. /**
  90868. * Gets the total number of active bones rendered per frame
  90869. * @returns the total number of active bones rendered per frame
  90870. */
  90871. getActiveBones(): number;
  90872. /**
  90873. * Gets the performance counter for active bones
  90874. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  90875. */
  90876. readonly activeBonesPerfCounter: PerfCounter;
  90877. /**
  90878. * Gets the array of active meshes
  90879. * @returns an array of AbstractMesh
  90880. */
  90881. getActiveMeshes(): SmartArray<AbstractMesh>;
  90882. /**
  90883. * Gets the animation ratio (which is 1.0 is the scene renders at 60fps and 2 if the scene renders at 30fps, etc.)
  90884. * @returns a number
  90885. */
  90886. getAnimationRatio(): number;
  90887. /**
  90888. * Gets an unique Id for the current render phase
  90889. * @returns a number
  90890. */
  90891. getRenderId(): number;
  90892. /**
  90893. * Gets an unique Id for the current frame
  90894. * @returns a number
  90895. */
  90896. getFrameId(): number;
  90897. /** Call this function if you want to manually increment the render Id*/
  90898. incrementRenderId(): void;
  90899. private _updatePointerPosition;
  90900. private _createUbo;
  90901. private _createAlternateUbo;
  90902. private _setRayOnPointerInfo;
  90903. /**
  90904. * Use this method to simulate a pointer move on a mesh
  90905. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  90906. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  90907. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  90908. * @returns the current scene
  90909. */
  90910. simulatePointerMove(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  90911. private _processPointerMove;
  90912. private _checkPrePointerObservable;
  90913. /**
  90914. * Use this method to simulate a pointer down on a mesh
  90915. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  90916. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  90917. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  90918. * @returns the current scene
  90919. */
  90920. simulatePointerDown(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  90921. private _processPointerDown;
  90922. /**
  90923. * Use this method to simulate a pointer up on a mesh
  90924. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  90925. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  90926. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  90927. * @param doubleTap indicates that the pointer up event should be considered as part of a double click (false by default)
  90928. * @returns the current scene
  90929. */
  90930. simulatePointerUp(pickResult: PickingInfo, pointerEventInit?: PointerEventInit, doubleTap?: boolean): Scene;
  90931. private _processPointerUp;
  90932. /**
  90933. * Gets a boolean indicating if the current pointer event is captured (meaning that the scene has already handled the pointer down)
  90934. * @param pointerId defines the pointer id to use in a multi-touch scenario (0 by default)
  90935. * @returns true if the pointer was captured
  90936. */
  90937. isPointerCaptured(pointerId?: number): boolean;
  90938. /** @hidden */
  90939. _isPointerSwiping(): boolean;
  90940. /**
  90941. * Attach events to the canvas (To handle actionManagers triggers and raise onPointerMove, onPointerDown and onPointerUp
  90942. * @param attachUp defines if you want to attach events to pointerup
  90943. * @param attachDown defines if you want to attach events to pointerdown
  90944. * @param attachMove defines if you want to attach events to pointermove
  90945. */
  90946. attachControl(attachUp?: boolean, attachDown?: boolean, attachMove?: boolean): void;
  90947. /** Detaches all event handlers*/
  90948. detachControl(): void;
  90949. /**
  90950. * This function will check if the scene can be rendered (textures are loaded, shaders are compiled)
  90951. * Delay loaded resources are not taking in account
  90952. * @return true if all required resources are ready
  90953. */
  90954. isReady(): boolean;
  90955. /** Resets all cached information relative to material (including effect and visibility) */
  90956. resetCachedMaterial(): void;
  90957. /**
  90958. * Registers a function to be called before every frame render
  90959. * @param func defines the function to register
  90960. */
  90961. registerBeforeRender(func: () => void): void;
  90962. /**
  90963. * Unregisters a function called before every frame render
  90964. * @param func defines the function to unregister
  90965. */
  90966. unregisterBeforeRender(func: () => void): void;
  90967. /**
  90968. * Registers a function to be called after every frame render
  90969. * @param func defines the function to register
  90970. */
  90971. registerAfterRender(func: () => void): void;
  90972. /**
  90973. * Unregisters a function called after every frame render
  90974. * @param func defines the function to unregister
  90975. */
  90976. unregisterAfterRender(func: () => void): void;
  90977. private _executeOnceBeforeRender;
  90978. /**
  90979. * The provided function will run before render once and will be disposed afterwards.
  90980. * A timeout delay can be provided so that the function will be executed in N ms.
  90981. * The timeout is using the browser's native setTimeout so time percision cannot be guaranteed.
  90982. * @param func The function to be executed.
  90983. * @param timeout optional delay in ms
  90984. */
  90985. executeOnceBeforeRender(func: () => void, timeout?: number): void;
  90986. /** @hidden */
  90987. _addPendingData(data: any): void;
  90988. /** @hidden */
  90989. _removePendingData(data: any): void;
  90990. /**
  90991. * Returns the number of items waiting to be loaded
  90992. * @returns the number of items waiting to be loaded
  90993. */
  90994. getWaitingItemsCount(): number;
  90995. /**
  90996. * Returns a boolean indicating if the scene is still loading data
  90997. */
  90998. readonly isLoading: boolean;
  90999. /**
  91000. * Registers a function to be executed when the scene is ready
  91001. * @param {Function} func - the function to be executed
  91002. */
  91003. executeWhenReady(func: () => void): void;
  91004. /**
  91005. * Returns a promise that resolves when the scene is ready
  91006. * @returns A promise that resolves when the scene is ready
  91007. */
  91008. whenReadyAsync(): Promise<void>;
  91009. /** @hidden */
  91010. _checkIsReady(): void;
  91011. /**
  91012. * Gets all animatable attached to the scene
  91013. */
  91014. readonly animatables: Animatable[];
  91015. /**
  91016. * Resets the last animation time frame.
  91017. * Useful to override when animations start running when loading a scene for the first time.
  91018. */
  91019. resetLastAnimationTimeFrame(): void;
  91020. /** @hidden */
  91021. _switchToAlternateCameraConfiguration(active: boolean): void;
  91022. /**
  91023. * Gets the current view matrix
  91024. * @returns a Matrix
  91025. */
  91026. getViewMatrix(): Matrix;
  91027. /**
  91028. * Gets the current projection matrix
  91029. * @returns a Matrix
  91030. */
  91031. getProjectionMatrix(): Matrix;
  91032. /**
  91033. * Gets the current transform matrix
  91034. * @returns a Matrix made of View * Projection
  91035. */
  91036. getTransformMatrix(): Matrix;
  91037. /**
  91038. * Sets the current transform matrix
  91039. * @param view defines the View matrix to use
  91040. * @param projection defines the Projection matrix to use
  91041. */
  91042. setTransformMatrix(view: Matrix, projection: Matrix): void;
  91043. /** @hidden */
  91044. _setAlternateTransformMatrix(view: Matrix, projection: Matrix): void;
  91045. /**
  91046. * Gets the uniform buffer used to store scene data
  91047. * @returns a UniformBuffer
  91048. */
  91049. getSceneUniformBuffer(): UniformBuffer;
  91050. /**
  91051. * Gets an unique (relatively to the current scene) Id
  91052. * @returns an unique number for the scene
  91053. */
  91054. getUniqueId(): number;
  91055. /**
  91056. * Add a mesh to the list of scene's meshes
  91057. * @param newMesh defines the mesh to add
  91058. * @param recursive if all child meshes should also be added to the scene
  91059. */
  91060. addMesh(newMesh: AbstractMesh, recursive?: boolean): void;
  91061. /**
  91062. * Remove a mesh for the list of scene's meshes
  91063. * @param toRemove defines the mesh to remove
  91064. * @param recursive if all child meshes should also be removed from the scene
  91065. * @returns the index where the mesh was in the mesh list
  91066. */
  91067. removeMesh(toRemove: AbstractMesh, recursive?: boolean): number;
  91068. /**
  91069. * Add a transform node to the list of scene's transform nodes
  91070. * @param newTransformNode defines the transform node to add
  91071. */
  91072. addTransformNode(newTransformNode: TransformNode): void;
  91073. /**
  91074. * Remove a transform node for the list of scene's transform nodes
  91075. * @param toRemove defines the transform node to remove
  91076. * @returns the index where the transform node was in the transform node list
  91077. */
  91078. removeTransformNode(toRemove: TransformNode): number;
  91079. /**
  91080. * Remove a skeleton for the list of scene's skeletons
  91081. * @param toRemove defines the skeleton to remove
  91082. * @returns the index where the skeleton was in the skeleton list
  91083. */
  91084. removeSkeleton(toRemove: Skeleton): number;
  91085. /**
  91086. * Remove a morph target for the list of scene's morph targets
  91087. * @param toRemove defines the morph target to remove
  91088. * @returns the index where the morph target was in the morph target list
  91089. */
  91090. removeMorphTargetManager(toRemove: MorphTargetManager): number;
  91091. /**
  91092. * Remove a light for the list of scene's lights
  91093. * @param toRemove defines the light to remove
  91094. * @returns the index where the light was in the light list
  91095. */
  91096. removeLight(toRemove: Light): number;
  91097. /**
  91098. * Remove a camera for the list of scene's cameras
  91099. * @param toRemove defines the camera to remove
  91100. * @returns the index where the camera was in the camera list
  91101. */
  91102. removeCamera(toRemove: Camera): number;
  91103. /**
  91104. * Remove a particle system for the list of scene's particle systems
  91105. * @param toRemove defines the particle system to remove
  91106. * @returns the index where the particle system was in the particle system list
  91107. */
  91108. removeParticleSystem(toRemove: IParticleSystem): number;
  91109. /**
  91110. * Remove a animation for the list of scene's animations
  91111. * @param toRemove defines the animation to remove
  91112. * @returns the index where the animation was in the animation list
  91113. */
  91114. removeAnimation(toRemove: Animation): number;
  91115. /**
  91116. * Removes the given animation group from this scene.
  91117. * @param toRemove The animation group to remove
  91118. * @returns The index of the removed animation group
  91119. */
  91120. removeAnimationGroup(toRemove: AnimationGroup): number;
  91121. /**
  91122. * Removes the given multi-material from this scene.
  91123. * @param toRemove The multi-material to remove
  91124. * @returns The index of the removed multi-material
  91125. */
  91126. removeMultiMaterial(toRemove: MultiMaterial): number;
  91127. /**
  91128. * Removes the given material from this scene.
  91129. * @param toRemove The material to remove
  91130. * @returns The index of the removed material
  91131. */
  91132. removeMaterial(toRemove: Material): number;
  91133. /**
  91134. * Removes the given action manager from this scene.
  91135. * @param toRemove The action manager to remove
  91136. * @returns The index of the removed action manager
  91137. */
  91138. removeActionManager(toRemove: AbstractActionManager): number;
  91139. /**
  91140. * Removes the given texture from this scene.
  91141. * @param toRemove The texture to remove
  91142. * @returns The index of the removed texture
  91143. */
  91144. removeTexture(toRemove: BaseTexture): number;
  91145. /**
  91146. * Adds the given light to this scene
  91147. * @param newLight The light to add
  91148. */
  91149. addLight(newLight: Light): void;
  91150. /**
  91151. * Sorts the list list based on light priorities
  91152. */
  91153. sortLightsByPriority(): void;
  91154. /**
  91155. * Adds the given camera to this scene
  91156. * @param newCamera The camera to add
  91157. */
  91158. addCamera(newCamera: Camera): void;
  91159. /**
  91160. * Adds the given skeleton to this scene
  91161. * @param newSkeleton The skeleton to add
  91162. */
  91163. addSkeleton(newSkeleton: Skeleton): void;
  91164. /**
  91165. * Adds the given particle system to this scene
  91166. * @param newParticleSystem The particle system to add
  91167. */
  91168. addParticleSystem(newParticleSystem: IParticleSystem): void;
  91169. /**
  91170. * Adds the given animation to this scene
  91171. * @param newAnimation The animation to add
  91172. */
  91173. addAnimation(newAnimation: Animation): void;
  91174. /**
  91175. * Adds the given animation group to this scene.
  91176. * @param newAnimationGroup The animation group to add
  91177. */
  91178. addAnimationGroup(newAnimationGroup: AnimationGroup): void;
  91179. /**
  91180. * Adds the given multi-material to this scene
  91181. * @param newMultiMaterial The multi-material to add
  91182. */
  91183. addMultiMaterial(newMultiMaterial: MultiMaterial): void;
  91184. /**
  91185. * Adds the given material to this scene
  91186. * @param newMaterial The material to add
  91187. */
  91188. addMaterial(newMaterial: Material): void;
  91189. /**
  91190. * Adds the given morph target to this scene
  91191. * @param newMorphTargetManager The morph target to add
  91192. */
  91193. addMorphTargetManager(newMorphTargetManager: MorphTargetManager): void;
  91194. /**
  91195. * Adds the given geometry to this scene
  91196. * @param newGeometry The geometry to add
  91197. */
  91198. addGeometry(newGeometry: Geometry): void;
  91199. /**
  91200. * Adds the given action manager to this scene
  91201. * @param newActionManager The action manager to add
  91202. */
  91203. addActionManager(newActionManager: AbstractActionManager): void;
  91204. /**
  91205. * Adds the given texture to this scene.
  91206. * @param newTexture The texture to add
  91207. */
  91208. addTexture(newTexture: BaseTexture): void;
  91209. /**
  91210. * Switch active camera
  91211. * @param newCamera defines the new active camera
  91212. * @param attachControl defines if attachControl must be called for the new active camera (default: true)
  91213. */
  91214. switchActiveCamera(newCamera: Camera, attachControl?: boolean): void;
  91215. /**
  91216. * sets the active camera of the scene using its ID
  91217. * @param id defines the camera's ID
  91218. * @return the new active camera or null if none found.
  91219. */
  91220. setActiveCameraByID(id: string): Nullable<Camera>;
  91221. /**
  91222. * sets the active camera of the scene using its name
  91223. * @param name defines the camera's name
  91224. * @returns the new active camera or null if none found.
  91225. */
  91226. setActiveCameraByName(name: string): Nullable<Camera>;
  91227. /**
  91228. * get an animation group using its name
  91229. * @param name defines the material's name
  91230. * @return the animation group or null if none found.
  91231. */
  91232. getAnimationGroupByName(name: string): Nullable<AnimationGroup>;
  91233. /**
  91234. * Get a material using its unique id
  91235. * @param uniqueId defines the material's unique id
  91236. * @return the material or null if none found.
  91237. */
  91238. getMaterialByUniqueID(uniqueId: number): Nullable<Material>;
  91239. /**
  91240. * get a material using its id
  91241. * @param id defines the material's ID
  91242. * @return the material or null if none found.
  91243. */
  91244. getMaterialByID(id: string): Nullable<Material>;
  91245. /**
  91246. * Gets a material using its name
  91247. * @param name defines the material's name
  91248. * @return the material or null if none found.
  91249. */
  91250. getMaterialByName(name: string): Nullable<Material>;
  91251. /**
  91252. * Gets a camera using its id
  91253. * @param id defines the id to look for
  91254. * @returns the camera or null if not found
  91255. */
  91256. getCameraByID(id: string): Nullable<Camera>;
  91257. /**
  91258. * Gets a camera using its unique id
  91259. * @param uniqueId defines the unique id to look for
  91260. * @returns the camera or null if not found
  91261. */
  91262. getCameraByUniqueID(uniqueId: number): Nullable<Camera>;
  91263. /**
  91264. * Gets a camera using its name
  91265. * @param name defines the camera's name
  91266. * @return the camera or null if none found.
  91267. */
  91268. getCameraByName(name: string): Nullable<Camera>;
  91269. /**
  91270. * Gets a bone using its id
  91271. * @param id defines the bone's id
  91272. * @return the bone or null if not found
  91273. */
  91274. getBoneByID(id: string): Nullable<Bone>;
  91275. /**
  91276. * Gets a bone using its id
  91277. * @param name defines the bone's name
  91278. * @return the bone or null if not found
  91279. */
  91280. getBoneByName(name: string): Nullable<Bone>;
  91281. /**
  91282. * Gets a light node using its name
  91283. * @param name defines the the light's name
  91284. * @return the light or null if none found.
  91285. */
  91286. getLightByName(name: string): Nullable<Light>;
  91287. /**
  91288. * Gets a light node using its id
  91289. * @param id defines the light's id
  91290. * @return the light or null if none found.
  91291. */
  91292. getLightByID(id: string): Nullable<Light>;
  91293. /**
  91294. * Gets a light node using its scene-generated unique ID
  91295. * @param uniqueId defines the light's unique id
  91296. * @return the light or null if none found.
  91297. */
  91298. getLightByUniqueID(uniqueId: number): Nullable<Light>;
  91299. /**
  91300. * Gets a particle system by id
  91301. * @param id defines the particle system id
  91302. * @return the corresponding system or null if none found
  91303. */
  91304. getParticleSystemByID(id: string): Nullable<IParticleSystem>;
  91305. /**
  91306. * Gets a geometry using its ID
  91307. * @param id defines the geometry's id
  91308. * @return the geometry or null if none found.
  91309. */
  91310. getGeometryByID(id: string): Nullable<Geometry>;
  91311. private _getGeometryByUniqueID;
  91312. /**
  91313. * Add a new geometry to this scene
  91314. * @param geometry defines the geometry to be added to the scene.
  91315. * @param force defines if the geometry must be pushed even if a geometry with this id already exists
  91316. * @return a boolean defining if the geometry was added or not
  91317. */
  91318. pushGeometry(geometry: Geometry, force?: boolean): boolean;
  91319. /**
  91320. * Removes an existing geometry
  91321. * @param geometry defines the geometry to be removed from the scene
  91322. * @return a boolean defining if the geometry was removed or not
  91323. */
  91324. removeGeometry(geometry: Geometry): boolean;
  91325. /**
  91326. * Gets the list of geometries attached to the scene
  91327. * @returns an array of Geometry
  91328. */
  91329. getGeometries(): Geometry[];
  91330. /**
  91331. * Gets the first added mesh found of a given ID
  91332. * @param id defines the id to search for
  91333. * @return the mesh found or null if not found at all
  91334. */
  91335. getMeshByID(id: string): Nullable<AbstractMesh>;
  91336. /**
  91337. * Gets a list of meshes using their id
  91338. * @param id defines the id to search for
  91339. * @returns a list of meshes
  91340. */
  91341. getMeshesByID(id: string): Array<AbstractMesh>;
  91342. /**
  91343. * Gets the first added transform node found of a given ID
  91344. * @param id defines the id to search for
  91345. * @return the found transform node or null if not found at all.
  91346. */
  91347. getTransformNodeByID(id: string): Nullable<TransformNode>;
  91348. /**
  91349. * Gets a transform node with its auto-generated unique id
  91350. * @param uniqueId efines the unique id to search for
  91351. * @return the found transform node or null if not found at all.
  91352. */
  91353. getTransformNodeByUniqueID(uniqueId: number): Nullable<TransformNode>;
  91354. /**
  91355. * Gets a list of transform nodes using their id
  91356. * @param id defines the id to search for
  91357. * @returns a list of transform nodes
  91358. */
  91359. getTransformNodesByID(id: string): Array<TransformNode>;
  91360. /**
  91361. * Gets a mesh with its auto-generated unique id
  91362. * @param uniqueId defines the unique id to search for
  91363. * @return the found mesh or null if not found at all.
  91364. */
  91365. getMeshByUniqueID(uniqueId: number): Nullable<AbstractMesh>;
  91366. /**
  91367. * Gets a the last added mesh using a given id
  91368. * @param id defines the id to search for
  91369. * @return the found mesh or null if not found at all.
  91370. */
  91371. getLastMeshByID(id: string): Nullable<AbstractMesh>;
  91372. /**
  91373. * Gets a the last added node (Mesh, Camera, Light) using a given id
  91374. * @param id defines the id to search for
  91375. * @return the found node or null if not found at all
  91376. */
  91377. getLastEntryByID(id: string): Nullable<Node>;
  91378. /**
  91379. * Gets a node (Mesh, Camera, Light) using a given id
  91380. * @param id defines the id to search for
  91381. * @return the found node or null if not found at all
  91382. */
  91383. getNodeByID(id: string): Nullable<Node>;
  91384. /**
  91385. * Gets a node (Mesh, Camera, Light) using a given name
  91386. * @param name defines the name to search for
  91387. * @return the found node or null if not found at all.
  91388. */
  91389. getNodeByName(name: string): Nullable<Node>;
  91390. /**
  91391. * Gets a mesh using a given name
  91392. * @param name defines the name to search for
  91393. * @return the found mesh or null if not found at all.
  91394. */
  91395. getMeshByName(name: string): Nullable<AbstractMesh>;
  91396. /**
  91397. * Gets a transform node using a given name
  91398. * @param name defines the name to search for
  91399. * @return the found transform node or null if not found at all.
  91400. */
  91401. getTransformNodeByName(name: string): Nullable<TransformNode>;
  91402. /**
  91403. * Gets a skeleton using a given id (if many are found, this function will pick the last one)
  91404. * @param id defines the id to search for
  91405. * @return the found skeleton or null if not found at all.
  91406. */
  91407. getLastSkeletonByID(id: string): Nullable<Skeleton>;
  91408. /**
  91409. * Gets a skeleton using a given auto generated unique id
  91410. * @param uniqueId defines the unique id to search for
  91411. * @return the found skeleton or null if not found at all.
  91412. */
  91413. getSkeletonByUniqueId(uniqueId: number): Nullable<Skeleton>;
  91414. /**
  91415. * Gets a skeleton using a given id (if many are found, this function will pick the first one)
  91416. * @param id defines the id to search for
  91417. * @return the found skeleton or null if not found at all.
  91418. */
  91419. getSkeletonById(id: string): Nullable<Skeleton>;
  91420. /**
  91421. * Gets a skeleton using a given name
  91422. * @param name defines the name to search for
  91423. * @return the found skeleton or null if not found at all.
  91424. */
  91425. getSkeletonByName(name: string): Nullable<Skeleton>;
  91426. /**
  91427. * Gets a morph target manager using a given id (if many are found, this function will pick the last one)
  91428. * @param id defines the id to search for
  91429. * @return the found morph target manager or null if not found at all.
  91430. */
  91431. getMorphTargetManagerById(id: number): Nullable<MorphTargetManager>;
  91432. /**
  91433. * Gets a morph target using a given id (if many are found, this function will pick the first one)
  91434. * @param id defines the id to search for
  91435. * @return the found morph target or null if not found at all.
  91436. */
  91437. getMorphTargetById(id: string): Nullable<MorphTarget>;
  91438. /**
  91439. * Gets a boolean indicating if the given mesh is active
  91440. * @param mesh defines the mesh to look for
  91441. * @returns true if the mesh is in the active list
  91442. */
  91443. isActiveMesh(mesh: AbstractMesh): boolean;
  91444. /**
  91445. * Return a unique id as a string which can serve as an identifier for the scene
  91446. */
  91447. readonly uid: string;
  91448. /**
  91449. * Add an externaly attached data from its key.
  91450. * This method call will fail and return false, if such key already exists.
  91451. * If you don't care and just want to get the data no matter what, use the more convenient getOrAddExternalDataWithFactory() method.
  91452. * @param key the unique key that identifies the data
  91453. * @param data the data object to associate to the key for this Engine instance
  91454. * @return true if no such key were already present and the data was added successfully, false otherwise
  91455. */
  91456. addExternalData<T>(key: string, data: T): boolean;
  91457. /**
  91458. * Get an externaly attached data from its key
  91459. * @param key the unique key that identifies the data
  91460. * @return the associated data, if present (can be null), or undefined if not present
  91461. */
  91462. getExternalData<T>(key: string): Nullable<T>;
  91463. /**
  91464. * Get an externaly attached data from its key, create it using a factory if it's not already present
  91465. * @param key the unique key that identifies the data
  91466. * @param factory the factory that will be called to create the instance if and only if it doesn't exists
  91467. * @return the associated data, can be null if the factory returned null.
  91468. */
  91469. getOrAddExternalDataWithFactory<T>(key: string, factory: (k: string) => T): T;
  91470. /**
  91471. * Remove an externaly attached data from the Engine instance
  91472. * @param key the unique key that identifies the data
  91473. * @return true if the data was successfully removed, false if it doesn't exist
  91474. */
  91475. removeExternalData(key: string): boolean;
  91476. private _evaluateSubMesh;
  91477. /**
  91478. * Clear the processed materials smart array preventing retention point in material dispose.
  91479. */
  91480. freeProcessedMaterials(): void;
  91481. private _preventFreeActiveMeshesAndRenderingGroups;
  91482. /** Gets or sets a boolean blocking all the calls to freeActiveMeshes and freeRenderingGroups
  91483. * It can be used in order to prevent going through methods freeRenderingGroups and freeActiveMeshes several times to improve performance
  91484. * when disposing several meshes in a row or a hierarchy of meshes.
  91485. * When used, it is the responsability of the user to blockfreeActiveMeshesAndRenderingGroups back to false.
  91486. */
  91487. blockfreeActiveMeshesAndRenderingGroups: boolean;
  91488. /**
  91489. * Clear the active meshes smart array preventing retention point in mesh dispose.
  91490. */
  91491. freeActiveMeshes(): void;
  91492. /**
  91493. * Clear the info related to rendering groups preventing retention points during dispose.
  91494. */
  91495. freeRenderingGroups(): void;
  91496. /** @hidden */
  91497. _isInIntermediateRendering(): boolean;
  91498. /**
  91499. * Lambda returning the list of potentially active meshes.
  91500. */
  91501. getActiveMeshCandidates: () => ISmartArrayLike<AbstractMesh>;
  91502. /**
  91503. * Lambda returning the list of potentially active sub meshes.
  91504. */
  91505. getActiveSubMeshCandidates: (mesh: AbstractMesh) => ISmartArrayLike<SubMesh>;
  91506. /**
  91507. * Lambda returning the list of potentially intersecting sub meshes.
  91508. */
  91509. getIntersectingSubMeshCandidates: (mesh: AbstractMesh, localRay: Ray) => ISmartArrayLike<SubMesh>;
  91510. /**
  91511. * Lambda returning the list of potentially colliding sub meshes.
  91512. */
  91513. getCollidingSubMeshCandidates: (mesh: AbstractMesh, collider: Collider) => ISmartArrayLike<SubMesh>;
  91514. private _activeMeshesFrozen;
  91515. /**
  91516. * Use this function to stop evaluating active meshes. The current list will be keep alive between frames
  91517. * @returns the current scene
  91518. */
  91519. freezeActiveMeshes(): Scene;
  91520. /**
  91521. * Use this function to restart evaluating active meshes on every frame
  91522. * @returns the current scene
  91523. */
  91524. unfreezeActiveMeshes(): Scene;
  91525. private _evaluateActiveMeshes;
  91526. private _activeMesh;
  91527. /**
  91528. * Update the transform matrix to update from the current active camera
  91529. * @param force defines a boolean used to force the update even if cache is up to date
  91530. */
  91531. updateTransformMatrix(force?: boolean): void;
  91532. /**
  91533. * 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)
  91534. * @param alternateCamera defines the camera to use
  91535. */
  91536. updateAlternateTransformMatrix(alternateCamera: Camera): void;
  91537. /** @hidden */
  91538. _allowPostProcessClearColor: boolean;
  91539. private _renderForCamera;
  91540. private _processSubCameras;
  91541. private _checkIntersections;
  91542. /** @hidden */
  91543. _advancePhysicsEngineStep(step: number): void;
  91544. /**
  91545. * User updatable function that will return a deterministic frame time when engine is in deterministic lock step mode
  91546. */
  91547. getDeterministicFrameTime: () => number;
  91548. /** @hidden */
  91549. _animate(): void;
  91550. /**
  91551. * Render the scene
  91552. * @param updateCameras defines a boolean indicating if cameras must update according to their inputs (true by default)
  91553. */
  91554. render(updateCameras?: boolean): void;
  91555. /**
  91556. * Freeze all materials
  91557. * A frozen material will not be updatable but should be faster to render
  91558. */
  91559. freezeMaterials(): void;
  91560. /**
  91561. * Unfreeze all materials
  91562. * A frozen material will not be updatable but should be faster to render
  91563. */
  91564. unfreezeMaterials(): void;
  91565. /**
  91566. * Releases all held ressources
  91567. */
  91568. dispose(): void;
  91569. /**
  91570. * Gets if the scene is already disposed
  91571. */
  91572. readonly isDisposed: boolean;
  91573. /**
  91574. * Call this function to reduce memory footprint of the scene.
  91575. * Vertex buffers will not store CPU data anymore (this will prevent picking, collisions or physics to work correctly)
  91576. */
  91577. clearCachedVertexData(): void;
  91578. /**
  91579. * This function will remove the local cached buffer data from texture.
  91580. * It will save memory but will prevent the texture from being rebuilt
  91581. */
  91582. cleanCachedTextureBuffer(): void;
  91583. /**
  91584. * Get the world extend vectors with an optional filter
  91585. *
  91586. * @param filterPredicate the predicate - which meshes should be included when calculating the world size
  91587. * @returns {{ min: Vector3; max: Vector3 }} min and max vectors
  91588. */
  91589. getWorldExtends(filterPredicate?: (mesh: AbstractMesh) => boolean): {
  91590. min: Vector3;
  91591. max: Vector3;
  91592. };
  91593. /**
  91594. * Creates a ray that can be used to pick in the scene
  91595. * @param x defines the x coordinate of the origin (on-screen)
  91596. * @param y defines the y coordinate of the origin (on-screen)
  91597. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  91598. * @param camera defines the camera to use for the picking
  91599. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  91600. * @returns a Ray
  91601. */
  91602. createPickingRay(x: number, y: number, world: Matrix, camera: Nullable<Camera>, cameraViewSpace?: boolean): Ray;
  91603. /**
  91604. * Creates a ray that can be used to pick in the scene
  91605. * @param x defines the x coordinate of the origin (on-screen)
  91606. * @param y defines the y coordinate of the origin (on-screen)
  91607. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  91608. * @param result defines the ray where to store the picking ray
  91609. * @param camera defines the camera to use for the picking
  91610. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  91611. * @returns the current scene
  91612. */
  91613. createPickingRayToRef(x: number, y: number, world: Matrix, result: Ray, camera: Nullable<Camera>, cameraViewSpace?: boolean): Scene;
  91614. /**
  91615. * Creates a ray that can be used to pick in the scene
  91616. * @param x defines the x coordinate of the origin (on-screen)
  91617. * @param y defines the y coordinate of the origin (on-screen)
  91618. * @param camera defines the camera to use for the picking
  91619. * @returns a Ray
  91620. */
  91621. createPickingRayInCameraSpace(x: number, y: number, camera?: Camera): Ray;
  91622. /**
  91623. * Creates a ray that can be used to pick in the scene
  91624. * @param x defines the x coordinate of the origin (on-screen)
  91625. * @param y defines the y coordinate of the origin (on-screen)
  91626. * @param result defines the ray where to store the picking ray
  91627. * @param camera defines the camera to use for the picking
  91628. * @returns the current scene
  91629. */
  91630. createPickingRayInCameraSpaceToRef(x: number, y: number, result: Ray, camera?: Camera): Scene;
  91631. /** Launch a ray to try to pick a mesh in the scene
  91632. * @param x position on screen
  91633. * @param y position on screen
  91634. * @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
  91635. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  91636. * @param camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  91637. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  91638. * @returns a PickingInfo
  91639. */
  91640. pick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, camera?: Nullable<Camera>, trianglePredicate?: (p0: Vector3, p1: Vector3, p2: Vector3) => boolean): Nullable<PickingInfo>;
  91641. /** Use the given ray to pick a mesh in the scene
  91642. * @param ray The ray to use to pick meshes
  91643. * @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
  91644. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null
  91645. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  91646. * @returns a PickingInfo
  91647. */
  91648. pickWithRay(ray: Ray, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  91649. /**
  91650. * Launch a ray to try to pick a mesh in the scene
  91651. * @param x X position on screen
  91652. * @param y Y position on screen
  91653. * @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
  91654. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  91655. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  91656. * @returns an array of PickingInfo
  91657. */
  91658. multiPick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, camera?: Camera, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  91659. /**
  91660. * Launch a ray to try to pick a mesh in the scene
  91661. * @param ray Ray to use
  91662. * @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
  91663. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  91664. * @returns an array of PickingInfo
  91665. */
  91666. multiPickWithRay(ray: Ray, predicate: (mesh: AbstractMesh) => boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  91667. /**
  91668. * Force the value of meshUnderPointer
  91669. * @param mesh defines the mesh to use
  91670. */
  91671. setPointerOverMesh(mesh: Nullable<AbstractMesh>): void;
  91672. /**
  91673. * Gets the mesh under the pointer
  91674. * @returns a Mesh or null if no mesh is under the pointer
  91675. */
  91676. getPointerOverMesh(): Nullable<AbstractMesh>;
  91677. /** @hidden */
  91678. _rebuildGeometries(): void;
  91679. /** @hidden */
  91680. _rebuildTextures(): void;
  91681. private _getByTags;
  91682. /**
  91683. * Get a list of meshes by tags
  91684. * @param tagsQuery defines the tags query to use
  91685. * @param forEach defines a predicate used to filter results
  91686. * @returns an array of Mesh
  91687. */
  91688. getMeshesByTags(tagsQuery: string, forEach?: (mesh: AbstractMesh) => void): Mesh[];
  91689. /**
  91690. * Get a list of cameras by tags
  91691. * @param tagsQuery defines the tags query to use
  91692. * @param forEach defines a predicate used to filter results
  91693. * @returns an array of Camera
  91694. */
  91695. getCamerasByTags(tagsQuery: string, forEach?: (camera: Camera) => void): Camera[];
  91696. /**
  91697. * Get a list of lights by tags
  91698. * @param tagsQuery defines the tags query to use
  91699. * @param forEach defines a predicate used to filter results
  91700. * @returns an array of Light
  91701. */
  91702. getLightsByTags(tagsQuery: string, forEach?: (light: Light) => void): Light[];
  91703. /**
  91704. * Get a list of materials by tags
  91705. * @param tagsQuery defines the tags query to use
  91706. * @param forEach defines a predicate used to filter results
  91707. * @returns an array of Material
  91708. */
  91709. getMaterialByTags(tagsQuery: string, forEach?: (material: Material) => void): Material[];
  91710. /**
  91711. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  91712. * This allowed control for front to back rendering or reversly depending of the special needs.
  91713. *
  91714. * @param renderingGroupId The rendering group id corresponding to its index
  91715. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  91716. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  91717. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  91718. */
  91719. 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;
  91720. /**
  91721. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  91722. *
  91723. * @param renderingGroupId The rendering group id corresponding to its index
  91724. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  91725. * @param depth Automatically clears depth between groups if true and autoClear is true.
  91726. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  91727. */
  91728. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  91729. /**
  91730. * Gets the current auto clear configuration for one rendering group of the rendering
  91731. * manager.
  91732. * @param index the rendering group index to get the information for
  91733. * @returns The auto clear setup for the requested rendering group
  91734. */
  91735. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  91736. private _blockMaterialDirtyMechanism;
  91737. /** Gets or sets a boolean blocking all the calls to markAllMaterialsAsDirty (ie. the materials won't be updated if they are out of sync) */
  91738. blockMaterialDirtyMechanism: boolean;
  91739. /**
  91740. * Will flag all materials as dirty to trigger new shader compilation
  91741. * @param flag defines the flag used to specify which material part must be marked as dirty
  91742. * @param predicate If not null, it will be used to specifiy if a material has to be marked as dirty
  91743. */
  91744. markAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  91745. /** @hidden */
  91746. _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;
  91747. /** @hidden */
  91748. _loadFileAsync(url: string, useOfflineSupport?: boolean, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  91749. }
  91750. }
  91751. declare module BABYLON {
  91752. /**
  91753. * Set of assets to keep when moving a scene into an asset container.
  91754. */
  91755. export class KeepAssets extends AbstractScene {
  91756. }
  91757. /**
  91758. * Container with a set of assets that can be added or removed from a scene.
  91759. */
  91760. export class AssetContainer extends AbstractScene {
  91761. /**
  91762. * The scene the AssetContainer belongs to.
  91763. */
  91764. scene: Scene;
  91765. /**
  91766. * Instantiates an AssetContainer.
  91767. * @param scene The scene the AssetContainer belongs to.
  91768. */
  91769. constructor(scene: Scene);
  91770. /**
  91771. * Adds all the assets from the container to the scene.
  91772. */
  91773. addAllToScene(): void;
  91774. /**
  91775. * Removes all the assets in the container from the scene
  91776. */
  91777. removeAllFromScene(): void;
  91778. /**
  91779. * Disposes all the assets in the container
  91780. */
  91781. dispose(): void;
  91782. private _moveAssets;
  91783. /**
  91784. * Removes all the assets contained in the scene and adds them to the container.
  91785. * @param keepAssets Set of assets to keep in the scene. (default: empty)
  91786. */
  91787. moveAllFromScene(keepAssets?: KeepAssets): void;
  91788. /**
  91789. * 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.
  91790. * @returns the root mesh
  91791. */
  91792. createRootMesh(): Mesh;
  91793. }
  91794. }
  91795. declare module BABYLON {
  91796. /**
  91797. * Defines how the parser contract is defined.
  91798. * These parsers are used to parse a list of specific assets (like particle systems, etc..)
  91799. */
  91800. export type BabylonFileParser = (parsedData: any, scene: Scene, container: AssetContainer, rootUrl: string) => void;
  91801. /**
  91802. * Defines how the individual parser contract is defined.
  91803. * These parser can parse an individual asset
  91804. */
  91805. export type IndividualBabylonFileParser = (parsedData: any, scene: Scene, rootUrl: string) => any;
  91806. /**
  91807. * Base class of the scene acting as a container for the different elements composing a scene.
  91808. * This class is dynamically extended by the different components of the scene increasing
  91809. * flexibility and reducing coupling
  91810. */
  91811. export abstract class AbstractScene {
  91812. /**
  91813. * Stores the list of available parsers in the application.
  91814. */
  91815. private static _BabylonFileParsers;
  91816. /**
  91817. * Stores the list of available individual parsers in the application.
  91818. */
  91819. private static _IndividualBabylonFileParsers;
  91820. /**
  91821. * Adds a parser in the list of available ones
  91822. * @param name Defines the name of the parser
  91823. * @param parser Defines the parser to add
  91824. */
  91825. static AddParser(name: string, parser: BabylonFileParser): void;
  91826. /**
  91827. * Gets a general parser from the list of avaialble ones
  91828. * @param name Defines the name of the parser
  91829. * @returns the requested parser or null
  91830. */
  91831. static GetParser(name: string): Nullable<BabylonFileParser>;
  91832. /**
  91833. * Adds n individual parser in the list of available ones
  91834. * @param name Defines the name of the parser
  91835. * @param parser Defines the parser to add
  91836. */
  91837. static AddIndividualParser(name: string, parser: IndividualBabylonFileParser): void;
  91838. /**
  91839. * Gets an individual parser from the list of avaialble ones
  91840. * @param name Defines the name of the parser
  91841. * @returns the requested parser or null
  91842. */
  91843. static GetIndividualParser(name: string): Nullable<IndividualBabylonFileParser>;
  91844. /**
  91845. * Parser json data and populate both a scene and its associated container object
  91846. * @param jsonData Defines the data to parse
  91847. * @param scene Defines the scene to parse the data for
  91848. * @param container Defines the container attached to the parsing sequence
  91849. * @param rootUrl Defines the root url of the data
  91850. */
  91851. static Parse(jsonData: any, scene: Scene, container: AssetContainer, rootUrl: string): void;
  91852. /**
  91853. * Gets the list of root nodes (ie. nodes with no parent)
  91854. */
  91855. rootNodes: Node[];
  91856. /** All of the cameras added to this scene
  91857. * @see http://doc.babylonjs.com/babylon101/cameras
  91858. */
  91859. cameras: Camera[];
  91860. /**
  91861. * All of the lights added to this scene
  91862. * @see http://doc.babylonjs.com/babylon101/lights
  91863. */
  91864. lights: Light[];
  91865. /**
  91866. * All of the (abstract) meshes added to this scene
  91867. */
  91868. meshes: AbstractMesh[];
  91869. /**
  91870. * The list of skeletons added to the scene
  91871. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  91872. */
  91873. skeletons: Skeleton[];
  91874. /**
  91875. * All of the particle systems added to this scene
  91876. * @see http://doc.babylonjs.com/babylon101/particles
  91877. */
  91878. particleSystems: IParticleSystem[];
  91879. /**
  91880. * Gets a list of Animations associated with the scene
  91881. */
  91882. animations: Animation[];
  91883. /**
  91884. * All of the animation groups added to this scene
  91885. * @see http://doc.babylonjs.com/how_to/group
  91886. */
  91887. animationGroups: AnimationGroup[];
  91888. /**
  91889. * All of the multi-materials added to this scene
  91890. * @see http://doc.babylonjs.com/how_to/multi_materials
  91891. */
  91892. multiMaterials: MultiMaterial[];
  91893. /**
  91894. * All of the materials added to this scene
  91895. * In the context of a Scene, it is not supposed to be modified manually.
  91896. * Any addition or removal should be done using the addMaterial and removeMAterial Scene methods.
  91897. * Note also that the order of the Material wihin the array is not significant and might change.
  91898. * @see http://doc.babylonjs.com/babylon101/materials
  91899. */
  91900. materials: Material[];
  91901. /**
  91902. * The list of morph target managers added to the scene
  91903. * @see http://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh
  91904. */
  91905. morphTargetManagers: MorphTargetManager[];
  91906. /**
  91907. * The list of geometries used in the scene.
  91908. */
  91909. geometries: Geometry[];
  91910. /**
  91911. * All of the tranform nodes added to this scene
  91912. * In the context of a Scene, it is not supposed to be modified manually.
  91913. * Any addition or removal should be done using the addTransformNode and removeTransformNode Scene methods.
  91914. * Note also that the order of the TransformNode wihin the array is not significant and might change.
  91915. * @see http://doc.babylonjs.com/how_to/transformnode
  91916. */
  91917. transformNodes: TransformNode[];
  91918. /**
  91919. * ActionManagers available on the scene.
  91920. */
  91921. actionManagers: AbstractActionManager[];
  91922. /**
  91923. * Textures to keep.
  91924. */
  91925. textures: BaseTexture[];
  91926. }
  91927. }
  91928. declare module BABYLON {
  91929. /**
  91930. * Defines a sound that can be played in the application.
  91931. * The sound can either be an ambient track or a simple sound played in reaction to a user action.
  91932. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  91933. */
  91934. export class Sound {
  91935. /**
  91936. * The name of the sound in the scene.
  91937. */
  91938. name: string;
  91939. /**
  91940. * Does the sound autoplay once loaded.
  91941. */
  91942. autoplay: boolean;
  91943. /**
  91944. * Does the sound loop after it finishes playing once.
  91945. */
  91946. loop: boolean;
  91947. /**
  91948. * Does the sound use a custom attenuation curve to simulate the falloff
  91949. * happening when the source gets further away from the camera.
  91950. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  91951. */
  91952. useCustomAttenuation: boolean;
  91953. /**
  91954. * The sound track id this sound belongs to.
  91955. */
  91956. soundTrackId: number;
  91957. /**
  91958. * Is this sound currently played.
  91959. */
  91960. isPlaying: boolean;
  91961. /**
  91962. * Is this sound currently paused.
  91963. */
  91964. isPaused: boolean;
  91965. /**
  91966. * Does this sound enables spatial sound.
  91967. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  91968. */
  91969. spatialSound: boolean;
  91970. /**
  91971. * Define the reference distance the sound should be heard perfectly.
  91972. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  91973. */
  91974. refDistance: number;
  91975. /**
  91976. * Define the roll off factor of spatial sounds.
  91977. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  91978. */
  91979. rolloffFactor: number;
  91980. /**
  91981. * Define the max distance the sound should be heard (intensity just became 0 at this point).
  91982. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  91983. */
  91984. maxDistance: number;
  91985. /**
  91986. * Define the distance attenuation model the sound will follow.
  91987. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  91988. */
  91989. distanceModel: string;
  91990. /**
  91991. * @hidden
  91992. * Back Compat
  91993. **/
  91994. onended: () => any;
  91995. /**
  91996. * Observable event when the current playing sound finishes.
  91997. */
  91998. onEndedObservable: Observable<Sound>;
  91999. private _panningModel;
  92000. private _playbackRate;
  92001. private _streaming;
  92002. private _startTime;
  92003. private _startOffset;
  92004. private _position;
  92005. /** @hidden */
  92006. _positionInEmitterSpace: boolean;
  92007. private _localDirection;
  92008. private _volume;
  92009. private _isReadyToPlay;
  92010. private _isDirectional;
  92011. private _readyToPlayCallback;
  92012. private _audioBuffer;
  92013. private _soundSource;
  92014. private _streamingSource;
  92015. private _soundPanner;
  92016. private _soundGain;
  92017. private _inputAudioNode;
  92018. private _outputAudioNode;
  92019. private _coneInnerAngle;
  92020. private _coneOuterAngle;
  92021. private _coneOuterGain;
  92022. private _scene;
  92023. private _connectedTransformNode;
  92024. private _customAttenuationFunction;
  92025. private _registerFunc;
  92026. private _isOutputConnected;
  92027. private _htmlAudioElement;
  92028. private _urlType;
  92029. /** @hidden */
  92030. static _SceneComponentInitialization: (scene: Scene) => void;
  92031. /**
  92032. * Create a sound and attach it to a scene
  92033. * @param name Name of your sound
  92034. * @param urlOrArrayBuffer Url to the sound to load async or ArrayBuffer, it also works with MediaStreams
  92035. * @param scene defines the scene the sound belongs to
  92036. * @param readyToPlayCallback Provide a callback function if you'd like to load your code once the sound is ready to be played
  92037. * @param options Objects to provide with the current available options: autoplay, loop, volume, spatialSound, maxDistance, rolloffFactor, refDistance, distanceModel, panningModel, streaming
  92038. */
  92039. constructor(name: string, urlOrArrayBuffer: any, scene: Scene, readyToPlayCallback?: Nullable<() => void>, options?: any);
  92040. /**
  92041. * Release the sound and its associated resources
  92042. */
  92043. dispose(): void;
  92044. /**
  92045. * Gets if the sounds is ready to be played or not.
  92046. * @returns true if ready, otherwise false
  92047. */
  92048. isReady(): boolean;
  92049. private _soundLoaded;
  92050. /**
  92051. * Sets the data of the sound from an audiobuffer
  92052. * @param audioBuffer The audioBuffer containing the data
  92053. */
  92054. setAudioBuffer(audioBuffer: AudioBuffer): void;
  92055. /**
  92056. * Updates the current sounds options such as maxdistance, loop...
  92057. * @param options A JSON object containing values named as the object properties
  92058. */
  92059. updateOptions(options: any): void;
  92060. private _createSpatialParameters;
  92061. private _updateSpatialParameters;
  92062. /**
  92063. * Switch the panning model to HRTF:
  92064. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  92065. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  92066. */
  92067. switchPanningModelToHRTF(): void;
  92068. /**
  92069. * Switch the panning model to Equal Power:
  92070. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  92071. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  92072. */
  92073. switchPanningModelToEqualPower(): void;
  92074. private _switchPanningModel;
  92075. /**
  92076. * Connect this sound to a sound track audio node like gain...
  92077. * @param soundTrackAudioNode the sound track audio node to connect to
  92078. */
  92079. connectToSoundTrackAudioNode(soundTrackAudioNode: AudioNode): void;
  92080. /**
  92081. * Transform this sound into a directional source
  92082. * @param coneInnerAngle Size of the inner cone in degree
  92083. * @param coneOuterAngle Size of the outer cone in degree
  92084. * @param coneOuterGain Volume of the sound outside the outer cone (between 0.0 and 1.0)
  92085. */
  92086. setDirectionalCone(coneInnerAngle: number, coneOuterAngle: number, coneOuterGain: number): void;
  92087. /**
  92088. * Gets or sets the inner angle for the directional cone.
  92089. */
  92090. /**
  92091. * Gets or sets the inner angle for the directional cone.
  92092. */
  92093. directionalConeInnerAngle: number;
  92094. /**
  92095. * Gets or sets the outer angle for the directional cone.
  92096. */
  92097. /**
  92098. * Gets or sets the outer angle for the directional cone.
  92099. */
  92100. directionalConeOuterAngle: number;
  92101. /**
  92102. * Sets the position of the emitter if spatial sound is enabled
  92103. * @param newPosition Defines the new posisiton
  92104. */
  92105. setPosition(newPosition: Vector3): void;
  92106. /**
  92107. * Sets the local direction of the emitter if spatial sound is enabled
  92108. * @param newLocalDirection Defines the new local direction
  92109. */
  92110. setLocalDirectionToMesh(newLocalDirection: Vector3): void;
  92111. private _updateDirection;
  92112. /** @hidden */
  92113. updateDistanceFromListener(): void;
  92114. /**
  92115. * Sets a new custom attenuation function for the sound.
  92116. * @param callback Defines the function used for the attenuation
  92117. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  92118. */
  92119. setAttenuationFunction(callback: (currentVolume: number, currentDistance: number, maxDistance: number, refDistance: number, rolloffFactor: number) => number): void;
  92120. /**
  92121. * Play the sound
  92122. * @param time (optional) Start the sound after X seconds. Start immediately (0) by default.
  92123. * @param offset (optional) Start the sound setting it at a specific time
  92124. */
  92125. play(time?: number, offset?: number): void;
  92126. private _onended;
  92127. /**
  92128. * Stop the sound
  92129. * @param time (optional) Stop the sound after X seconds. Stop immediately (0) by default.
  92130. */
  92131. stop(time?: number): void;
  92132. /**
  92133. * Put the sound in pause
  92134. */
  92135. pause(): void;
  92136. /**
  92137. * Sets a dedicated volume for this sounds
  92138. * @param newVolume Define the new volume of the sound
  92139. * @param time Define in how long the sound should be at this value
  92140. */
  92141. setVolume(newVolume: number, time?: number): void;
  92142. /**
  92143. * Set the sound play back rate
  92144. * @param newPlaybackRate Define the playback rate the sound should be played at
  92145. */
  92146. setPlaybackRate(newPlaybackRate: number): void;
  92147. /**
  92148. * Gets the volume of the sound.
  92149. * @returns the volume of the sound
  92150. */
  92151. getVolume(): number;
  92152. /**
  92153. * Attach the sound to a dedicated mesh
  92154. * @param transformNode The transform node to connect the sound with
  92155. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  92156. */
  92157. attachToMesh(transformNode: TransformNode): void;
  92158. /**
  92159. * Detach the sound from the previously attached mesh
  92160. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  92161. */
  92162. detachFromMesh(): void;
  92163. private _onRegisterAfterWorldMatrixUpdate;
  92164. /**
  92165. * Clone the current sound in the scene.
  92166. * @returns the new sound clone
  92167. */
  92168. clone(): Nullable<Sound>;
  92169. /**
  92170. * Gets the current underlying audio buffer containing the data
  92171. * @returns the audio buffer
  92172. */
  92173. getAudioBuffer(): Nullable<AudioBuffer>;
  92174. /**
  92175. * Serializes the Sound in a JSON representation
  92176. * @returns the JSON representation of the sound
  92177. */
  92178. serialize(): any;
  92179. /**
  92180. * Parse a JSON representation of a sound to innstantiate in a given scene
  92181. * @param parsedSound Define the JSON representation of the sound (usually coming from the serialize method)
  92182. * @param scene Define the scene the new parsed sound should be created in
  92183. * @param rootUrl Define the rooturl of the load in case we need to fetch relative dependencies
  92184. * @param sourceSound Define a cound place holder if do not need to instantiate a new one
  92185. * @returns the newly parsed sound
  92186. */
  92187. static Parse(parsedSound: any, scene: Scene, rootUrl: string, sourceSound?: Sound): Sound;
  92188. }
  92189. }
  92190. declare module BABYLON {
  92191. /**
  92192. * This defines an action helpful to play a defined sound on a triggered action.
  92193. */
  92194. export class PlaySoundAction extends Action {
  92195. private _sound;
  92196. /**
  92197. * Instantiate the action
  92198. * @param triggerOptions defines the trigger options
  92199. * @param sound defines the sound to play
  92200. * @param condition defines the trigger related conditions
  92201. */
  92202. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  92203. /** @hidden */
  92204. _prepare(): void;
  92205. /**
  92206. * Execute the action and play the sound.
  92207. */
  92208. execute(): void;
  92209. /**
  92210. * Serializes the actions and its related information.
  92211. * @param parent defines the object to serialize in
  92212. * @returns the serialized object
  92213. */
  92214. serialize(parent: any): any;
  92215. }
  92216. /**
  92217. * This defines an action helpful to stop a defined sound on a triggered action.
  92218. */
  92219. export class StopSoundAction extends Action {
  92220. private _sound;
  92221. /**
  92222. * Instantiate the action
  92223. * @param triggerOptions defines the trigger options
  92224. * @param sound defines the sound to stop
  92225. * @param condition defines the trigger related conditions
  92226. */
  92227. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  92228. /** @hidden */
  92229. _prepare(): void;
  92230. /**
  92231. * Execute the action and stop the sound.
  92232. */
  92233. execute(): void;
  92234. /**
  92235. * Serializes the actions and its related information.
  92236. * @param parent defines the object to serialize in
  92237. * @returns the serialized object
  92238. */
  92239. serialize(parent: any): any;
  92240. }
  92241. }
  92242. declare module BABYLON {
  92243. /**
  92244. * This defines an action responsible to change the value of a property
  92245. * by interpolating between its current value and the newly set one once triggered.
  92246. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  92247. */
  92248. export class InterpolateValueAction extends Action {
  92249. /**
  92250. * Defines the path of the property where the value should be interpolated
  92251. */
  92252. propertyPath: string;
  92253. /**
  92254. * Defines the target value at the end of the interpolation.
  92255. */
  92256. value: any;
  92257. /**
  92258. * Defines the time it will take for the property to interpolate to the value.
  92259. */
  92260. duration: number;
  92261. /**
  92262. * Defines if the other scene animations should be stopped when the action has been triggered
  92263. */
  92264. stopOtherAnimations?: boolean;
  92265. /**
  92266. * Defines a callback raised once the interpolation animation has been done.
  92267. */
  92268. onInterpolationDone?: () => void;
  92269. /**
  92270. * Observable triggered once the interpolation animation has been done.
  92271. */
  92272. onInterpolationDoneObservable: Observable<InterpolateValueAction>;
  92273. private _target;
  92274. private _effectiveTarget;
  92275. private _property;
  92276. /**
  92277. * Instantiate the action
  92278. * @param triggerOptions defines the trigger options
  92279. * @param target defines the object containing the value to interpolate
  92280. * @param propertyPath defines the path to the property in the target object
  92281. * @param value defines the target value at the end of the interpolation
  92282. * @param duration deines the time it will take for the property to interpolate to the value.
  92283. * @param condition defines the trigger related conditions
  92284. * @param stopOtherAnimations defines if the other scene animations should be stopped when the action has been triggered
  92285. * @param onInterpolationDone defines a callback raised once the interpolation animation has been done
  92286. */
  92287. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, duration?: number, condition?: Condition, stopOtherAnimations?: boolean, onInterpolationDone?: () => void);
  92288. /** @hidden */
  92289. _prepare(): void;
  92290. /**
  92291. * Execute the action starts the value interpolation.
  92292. */
  92293. execute(): void;
  92294. /**
  92295. * Serializes the actions and its related information.
  92296. * @param parent defines the object to serialize in
  92297. * @returns the serialized object
  92298. */
  92299. serialize(parent: any): any;
  92300. }
  92301. }
  92302. declare module BABYLON {
  92303. /**
  92304. * Options allowed during the creation of a sound track.
  92305. */
  92306. export interface ISoundTrackOptions {
  92307. /**
  92308. * The volume the sound track should take during creation
  92309. */
  92310. volume?: number;
  92311. /**
  92312. * Define if the sound track is the main sound track of the scene
  92313. */
  92314. mainTrack?: boolean;
  92315. }
  92316. /**
  92317. * It could be useful to isolate your music & sounds on several tracks to better manage volume on a grouped instance of sounds.
  92318. * It will be also used in a future release to apply effects on a specific track.
  92319. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  92320. */
  92321. export class SoundTrack {
  92322. /**
  92323. * The unique identifier of the sound track in the scene.
  92324. */
  92325. id: number;
  92326. /**
  92327. * The list of sounds included in the sound track.
  92328. */
  92329. soundCollection: Array<Sound>;
  92330. private _outputAudioNode;
  92331. private _scene;
  92332. private _isMainTrack;
  92333. private _connectedAnalyser;
  92334. private _options;
  92335. private _isInitialized;
  92336. /**
  92337. * Creates a new sound track.
  92338. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  92339. * @param scene Define the scene the sound track belongs to
  92340. * @param options
  92341. */
  92342. constructor(scene: Scene, options?: ISoundTrackOptions);
  92343. private _initializeSoundTrackAudioGraph;
  92344. /**
  92345. * Release the sound track and its associated resources
  92346. */
  92347. dispose(): void;
  92348. /**
  92349. * Adds a sound to this sound track
  92350. * @param sound define the cound to add
  92351. * @ignoreNaming
  92352. */
  92353. AddSound(sound: Sound): void;
  92354. /**
  92355. * Removes a sound to this sound track
  92356. * @param sound define the cound to remove
  92357. * @ignoreNaming
  92358. */
  92359. RemoveSound(sound: Sound): void;
  92360. /**
  92361. * Set a global volume for the full sound track.
  92362. * @param newVolume Define the new volume of the sound track
  92363. */
  92364. setVolume(newVolume: number): void;
  92365. /**
  92366. * Switch the panning model to HRTF:
  92367. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  92368. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  92369. */
  92370. switchPanningModelToHRTF(): void;
  92371. /**
  92372. * Switch the panning model to Equal Power:
  92373. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  92374. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  92375. */
  92376. switchPanningModelToEqualPower(): void;
  92377. /**
  92378. * Connect the sound track to an audio analyser allowing some amazing
  92379. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  92380. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  92381. * @param analyser The analyser to connect to the engine
  92382. */
  92383. connectToAnalyser(analyser: Analyser): void;
  92384. }
  92385. }
  92386. declare module BABYLON {
  92387. interface AbstractScene {
  92388. /**
  92389. * The list of sounds used in the scene.
  92390. */
  92391. sounds: Nullable<Array<Sound>>;
  92392. }
  92393. interface Scene {
  92394. /**
  92395. * @hidden
  92396. * Backing field
  92397. */
  92398. _mainSoundTrack: SoundTrack;
  92399. /**
  92400. * The main sound track played by the scene.
  92401. * It cotains your primary collection of sounds.
  92402. */
  92403. mainSoundTrack: SoundTrack;
  92404. /**
  92405. * The list of sound tracks added to the scene
  92406. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  92407. */
  92408. soundTracks: Nullable<Array<SoundTrack>>;
  92409. /**
  92410. * Gets a sound using a given name
  92411. * @param name defines the name to search for
  92412. * @return the found sound or null if not found at all.
  92413. */
  92414. getSoundByName(name: string): Nullable<Sound>;
  92415. /**
  92416. * Gets or sets if audio support is enabled
  92417. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  92418. */
  92419. audioEnabled: boolean;
  92420. /**
  92421. * Gets or sets if audio will be output to headphones
  92422. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  92423. */
  92424. headphone: boolean;
  92425. }
  92426. /**
  92427. * Defines the sound scene component responsible to manage any sounds
  92428. * in a given scene.
  92429. */
  92430. export class AudioSceneComponent implements ISceneSerializableComponent {
  92431. /**
  92432. * The component name helpfull to identify the component in the list of scene components.
  92433. */
  92434. readonly name: string;
  92435. /**
  92436. * The scene the component belongs to.
  92437. */
  92438. scene: Scene;
  92439. private _audioEnabled;
  92440. /**
  92441. * Gets whether audio is enabled or not.
  92442. * Please use related enable/disable method to switch state.
  92443. */
  92444. readonly audioEnabled: boolean;
  92445. private _headphone;
  92446. /**
  92447. * Gets whether audio is outputing to headphone or not.
  92448. * Please use the according Switch methods to change output.
  92449. */
  92450. readonly headphone: boolean;
  92451. /**
  92452. * Creates a new instance of the component for the given scene
  92453. * @param scene Defines the scene to register the component in
  92454. */
  92455. constructor(scene: Scene);
  92456. /**
  92457. * Registers the component in a given scene
  92458. */
  92459. register(): void;
  92460. /**
  92461. * Rebuilds the elements related to this component in case of
  92462. * context lost for instance.
  92463. */
  92464. rebuild(): void;
  92465. /**
  92466. * Serializes the component data to the specified json object
  92467. * @param serializationObject The object to serialize to
  92468. */
  92469. serialize(serializationObject: any): void;
  92470. /**
  92471. * Adds all the element from the container to the scene
  92472. * @param container the container holding the elements
  92473. */
  92474. addFromContainer(container: AbstractScene): void;
  92475. /**
  92476. * Removes all the elements in the container from the scene
  92477. * @param container contains the elements to remove
  92478. */
  92479. removeFromContainer(container: AbstractScene): void;
  92480. /**
  92481. * Disposes the component and the associated ressources.
  92482. */
  92483. dispose(): void;
  92484. /**
  92485. * Disables audio in the associated scene.
  92486. */
  92487. disableAudio(): void;
  92488. /**
  92489. * Enables audio in the associated scene.
  92490. */
  92491. enableAudio(): void;
  92492. /**
  92493. * Switch audio to headphone output.
  92494. */
  92495. switchAudioModeForHeadphones(): void;
  92496. /**
  92497. * Switch audio to normal speakers.
  92498. */
  92499. switchAudioModeForNormalSpeakers(): void;
  92500. private _afterRender;
  92501. }
  92502. }
  92503. declare module BABYLON {
  92504. /**
  92505. * Wraps one or more Sound objects and selects one with random weight for playback.
  92506. */
  92507. export class WeightedSound {
  92508. /** When true a Sound will be selected and played when the current playing Sound completes. */
  92509. loop: boolean;
  92510. private _coneInnerAngle;
  92511. private _coneOuterAngle;
  92512. private _volume;
  92513. /** A Sound is currently playing. */
  92514. isPlaying: boolean;
  92515. /** A Sound is currently paused. */
  92516. isPaused: boolean;
  92517. private _sounds;
  92518. private _weights;
  92519. private _currentIndex?;
  92520. /**
  92521. * Creates a new WeightedSound from the list of sounds given.
  92522. * @param loop When true a Sound will be selected and played when the current playing Sound completes.
  92523. * @param sounds Array of Sounds that will be selected from.
  92524. * @param weights Array of number values for selection weights; length must equal sounds, values will be normalized to 1
  92525. */
  92526. constructor(loop: boolean, sounds: Sound[], weights: number[]);
  92527. /**
  92528. * The size of cone in degrees for a directional sound in which there will be no attenuation.
  92529. */
  92530. /**
  92531. * The size of cone in degress for a directional sound in which there will be no attenuation.
  92532. */
  92533. directionalConeInnerAngle: number;
  92534. /**
  92535. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  92536. * Listener angles between innerAngle and outerAngle will falloff linearly.
  92537. */
  92538. /**
  92539. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  92540. * Listener angles between innerAngle and outerAngle will falloff linearly.
  92541. */
  92542. directionalConeOuterAngle: number;
  92543. /**
  92544. * Playback volume.
  92545. */
  92546. /**
  92547. * Playback volume.
  92548. */
  92549. volume: number;
  92550. private _onended;
  92551. /**
  92552. * Suspend playback
  92553. */
  92554. pause(): void;
  92555. /**
  92556. * Stop playback
  92557. */
  92558. stop(): void;
  92559. /**
  92560. * Start playback.
  92561. * @param startOffset Position the clip head at a specific time in seconds.
  92562. */
  92563. play(startOffset?: number): void;
  92564. }
  92565. }
  92566. declare module BABYLON {
  92567. /**
  92568. * Add a bouncing effect to an ArcRotateCamera when reaching a specified minimum and maximum radius
  92569. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  92570. */
  92571. export class BouncingBehavior implements Behavior<ArcRotateCamera> {
  92572. /**
  92573. * Gets the name of the behavior.
  92574. */
  92575. readonly name: string;
  92576. /**
  92577. * The easing function used by animations
  92578. */
  92579. static EasingFunction: BackEase;
  92580. /**
  92581. * The easing mode used by animations
  92582. */
  92583. static EasingMode: number;
  92584. /**
  92585. * The duration of the animation, in milliseconds
  92586. */
  92587. transitionDuration: number;
  92588. /**
  92589. * Length of the distance animated by the transition when lower radius is reached
  92590. */
  92591. lowerRadiusTransitionRange: number;
  92592. /**
  92593. * Length of the distance animated by the transition when upper radius is reached
  92594. */
  92595. upperRadiusTransitionRange: number;
  92596. private _autoTransitionRange;
  92597. /**
  92598. * Gets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  92599. */
  92600. /**
  92601. * Sets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  92602. * Transition ranges will be set to 5% of the bounding box diagonal in world space
  92603. */
  92604. autoTransitionRange: boolean;
  92605. private _attachedCamera;
  92606. private _onAfterCheckInputsObserver;
  92607. private _onMeshTargetChangedObserver;
  92608. /**
  92609. * Initializes the behavior.
  92610. */
  92611. init(): void;
  92612. /**
  92613. * Attaches the behavior to its arc rotate camera.
  92614. * @param camera Defines the camera to attach the behavior to
  92615. */
  92616. attach(camera: ArcRotateCamera): void;
  92617. /**
  92618. * Detaches the behavior from its current arc rotate camera.
  92619. */
  92620. detach(): void;
  92621. private _radiusIsAnimating;
  92622. private _radiusBounceTransition;
  92623. private _animatables;
  92624. private _cachedWheelPrecision;
  92625. /**
  92626. * Checks if the camera radius is at the specified limit. Takes into account animation locks.
  92627. * @param radiusLimit The limit to check against.
  92628. * @return Bool to indicate if at limit.
  92629. */
  92630. private _isRadiusAtLimit;
  92631. /**
  92632. * Applies an animation to the radius of the camera, extending by the radiusDelta.
  92633. * @param radiusDelta The delta by which to animate to. Can be negative.
  92634. */
  92635. private _applyBoundRadiusAnimation;
  92636. /**
  92637. * Removes all animation locks. Allows new animations to be added to any of the camera properties.
  92638. */
  92639. protected _clearAnimationLocks(): void;
  92640. /**
  92641. * Stops and removes all animations that have been applied to the camera
  92642. */
  92643. stopAllAnimations(): void;
  92644. }
  92645. }
  92646. declare module BABYLON {
  92647. /**
  92648. * 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.
  92649. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  92650. */
  92651. export class FramingBehavior implements Behavior<ArcRotateCamera> {
  92652. /**
  92653. * Gets the name of the behavior.
  92654. */
  92655. readonly name: string;
  92656. private _mode;
  92657. private _radiusScale;
  92658. private _positionScale;
  92659. private _defaultElevation;
  92660. private _elevationReturnTime;
  92661. private _elevationReturnWaitTime;
  92662. private _zoomStopsAnimation;
  92663. private _framingTime;
  92664. /**
  92665. * The easing function used by animations
  92666. */
  92667. static EasingFunction: ExponentialEase;
  92668. /**
  92669. * The easing mode used by animations
  92670. */
  92671. static EasingMode: number;
  92672. /**
  92673. * Sets the current mode used by the behavior
  92674. */
  92675. /**
  92676. * Gets current mode used by the behavior.
  92677. */
  92678. mode: number;
  92679. /**
  92680. * Sets the scale applied to the radius (1 by default)
  92681. */
  92682. /**
  92683. * Gets the scale applied to the radius
  92684. */
  92685. radiusScale: number;
  92686. /**
  92687. * Sets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  92688. */
  92689. /**
  92690. * Gets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  92691. */
  92692. positionScale: number;
  92693. /**
  92694. * Sets the angle above/below the horizontal plane to return to when the return to default elevation idle
  92695. * behaviour is triggered, in radians.
  92696. */
  92697. /**
  92698. * Gets the angle above/below the horizontal plane to return to when the return to default elevation idle
  92699. * behaviour is triggered, in radians.
  92700. */
  92701. defaultElevation: number;
  92702. /**
  92703. * Sets the time (in milliseconds) taken to return to the default beta position.
  92704. * Negative value indicates camera should not return to default.
  92705. */
  92706. /**
  92707. * Gets the time (in milliseconds) taken to return to the default beta position.
  92708. * Negative value indicates camera should not return to default.
  92709. */
  92710. elevationReturnTime: number;
  92711. /**
  92712. * Sets the delay (in milliseconds) taken before the camera returns to the default beta position.
  92713. */
  92714. /**
  92715. * Gets the delay (in milliseconds) taken before the camera returns to the default beta position.
  92716. */
  92717. elevationReturnWaitTime: number;
  92718. /**
  92719. * Sets the flag that indicates if user zooming should stop animation.
  92720. */
  92721. /**
  92722. * Gets the flag that indicates if user zooming should stop animation.
  92723. */
  92724. zoomStopsAnimation: boolean;
  92725. /**
  92726. * Sets the transition time when framing the mesh, in milliseconds
  92727. */
  92728. /**
  92729. * Gets the transition time when framing the mesh, in milliseconds
  92730. */
  92731. framingTime: number;
  92732. /**
  92733. * Define if the behavior should automatically change the configured
  92734. * camera limits and sensibilities.
  92735. */
  92736. autoCorrectCameraLimitsAndSensibility: boolean;
  92737. private _onPrePointerObservableObserver;
  92738. private _onAfterCheckInputsObserver;
  92739. private _onMeshTargetChangedObserver;
  92740. private _attachedCamera;
  92741. private _isPointerDown;
  92742. private _lastInteractionTime;
  92743. /**
  92744. * Initializes the behavior.
  92745. */
  92746. init(): void;
  92747. /**
  92748. * Attaches the behavior to its arc rotate camera.
  92749. * @param camera Defines the camera to attach the behavior to
  92750. */
  92751. attach(camera: ArcRotateCamera): void;
  92752. /**
  92753. * Detaches the behavior from its current arc rotate camera.
  92754. */
  92755. detach(): void;
  92756. private _animatables;
  92757. private _betaIsAnimating;
  92758. private _betaTransition;
  92759. private _radiusTransition;
  92760. private _vectorTransition;
  92761. /**
  92762. * Targets the given mesh and updates zoom level accordingly.
  92763. * @param mesh The mesh to target.
  92764. * @param radius Optional. If a cached radius position already exists, overrides default.
  92765. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  92766. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  92767. * @param onAnimationEnd Callback triggered at the end of the framing animation
  92768. */
  92769. zoomOnMesh(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  92770. /**
  92771. * Targets the given mesh with its children and updates zoom level accordingly.
  92772. * @param mesh The mesh to target.
  92773. * @param radius Optional. If a cached radius position already exists, overrides default.
  92774. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  92775. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  92776. * @param onAnimationEnd Callback triggered at the end of the framing animation
  92777. */
  92778. zoomOnMeshHierarchy(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  92779. /**
  92780. * Targets the given meshes with their children and updates zoom level accordingly.
  92781. * @param meshes The mesh to target.
  92782. * @param radius Optional. If a cached radius position already exists, overrides default.
  92783. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  92784. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  92785. * @param onAnimationEnd Callback triggered at the end of the framing animation
  92786. */
  92787. zoomOnMeshesHierarchy(meshes: AbstractMesh[], focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  92788. /**
  92789. * Targets the bounding box info defined by its extends and updates zoom level accordingly.
  92790. * @param minimumWorld Determines the smaller position of the bounding box extend
  92791. * @param maximumWorld Determines the bigger position of the bounding box extend
  92792. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  92793. * @param onAnimationEnd Callback triggered at the end of the framing animation
  92794. */
  92795. zoomOnBoundingInfo(minimumWorld: Vector3, maximumWorld: Vector3, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  92796. /**
  92797. * Calculates the lowest radius for the camera based on the bounding box of the mesh.
  92798. * @param mesh The mesh on which to base the calculation. mesh boundingInfo used to estimate necessary
  92799. * frustum width.
  92800. * @return The minimum distance from the primary mesh's center point at which the camera must be kept in order
  92801. * to fully enclose the mesh in the viewing frustum.
  92802. */
  92803. protected _calculateLowerRadiusFromModelBoundingSphere(minimumWorld: Vector3, maximumWorld: Vector3): number;
  92804. /**
  92805. * Keeps the camera above the ground plane. If the user pulls the camera below the ground plane, the camera
  92806. * is automatically returned to its default position (expected to be above ground plane).
  92807. */
  92808. private _maintainCameraAboveGround;
  92809. /**
  92810. * Returns the frustum slope based on the canvas ratio and camera FOV
  92811. * @returns The frustum slope represented as a Vector2 with X and Y slopes
  92812. */
  92813. private _getFrustumSlope;
  92814. /**
  92815. * Removes all animation locks. Allows new animations to be added to any of the arcCamera properties.
  92816. */
  92817. private _clearAnimationLocks;
  92818. /**
  92819. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  92820. */
  92821. private _applyUserInteraction;
  92822. /**
  92823. * Stops and removes all animations that have been applied to the camera
  92824. */
  92825. stopAllAnimations(): void;
  92826. /**
  92827. * Gets a value indicating if the user is moving the camera
  92828. */
  92829. readonly isUserIsMoving: boolean;
  92830. /**
  92831. * The camera can move all the way towards the mesh.
  92832. */
  92833. static IgnoreBoundsSizeMode: number;
  92834. /**
  92835. * The camera is not allowed to zoom closer to the mesh than the point at which the adjusted bounding sphere touches the frustum sides
  92836. */
  92837. static FitFrustumSidesMode: number;
  92838. }
  92839. }
  92840. declare module BABYLON {
  92841. /**
  92842. * Base class for Camera Pointer Inputs.
  92843. * See FollowCameraPointersInput in src/Cameras/Inputs/followCameraPointersInput.ts
  92844. * for example usage.
  92845. */
  92846. export abstract class BaseCameraPointersInput implements ICameraInput<Camera> {
  92847. /**
  92848. * Defines the camera the input is attached to.
  92849. */
  92850. abstract camera: Camera;
  92851. /**
  92852. * Whether keyboard modifier keys are pressed at time of last mouse event.
  92853. */
  92854. protected _altKey: boolean;
  92855. protected _ctrlKey: boolean;
  92856. protected _metaKey: boolean;
  92857. protected _shiftKey: boolean;
  92858. /**
  92859. * Which mouse buttons were pressed at time of last mouse event.
  92860. * https://developer.mozilla.org/en-US/docs/Web/API/MouseEvent/buttons
  92861. */
  92862. protected _buttonsPressed: number;
  92863. /**
  92864. * Defines the buttons associated with the input to handle camera move.
  92865. */
  92866. buttons: number[];
  92867. /**
  92868. * Attach the input controls to a specific dom element to get the input from.
  92869. * @param element Defines the element the controls should be listened from
  92870. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  92871. */
  92872. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  92873. /**
  92874. * Detach the current controls from the specified dom element.
  92875. * @param element Defines the element to stop listening the inputs from
  92876. */
  92877. detachControl(element: Nullable<HTMLElement>): void;
  92878. /**
  92879. * Gets the class name of the current input.
  92880. * @returns the class name
  92881. */
  92882. getClassName(): string;
  92883. /**
  92884. * Get the friendly name associated with the input class.
  92885. * @returns the input friendly name
  92886. */
  92887. getSimpleName(): string;
  92888. /**
  92889. * Called on pointer POINTERDOUBLETAP event.
  92890. * Override this method to provide functionality on POINTERDOUBLETAP event.
  92891. */
  92892. protected onDoubleTap(type: string): void;
  92893. /**
  92894. * Called on pointer POINTERMOVE event if only a single touch is active.
  92895. * Override this method to provide functionality.
  92896. */
  92897. protected onTouch(point: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  92898. /**
  92899. * Called on pointer POINTERMOVE event if multiple touches are active.
  92900. * Override this method to provide functionality.
  92901. */
  92902. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  92903. /**
  92904. * Called on JS contextmenu event.
  92905. * Override this method to provide functionality.
  92906. */
  92907. protected onContextMenu(evt: PointerEvent): void;
  92908. /**
  92909. * Called each time a new POINTERDOWN event occurs. Ie, for each button
  92910. * press.
  92911. * Override this method to provide functionality.
  92912. */
  92913. protected onButtonDown(evt: PointerEvent): void;
  92914. /**
  92915. * Called each time a new POINTERUP event occurs. Ie, for each button
  92916. * release.
  92917. * Override this method to provide functionality.
  92918. */
  92919. protected onButtonUp(evt: PointerEvent): void;
  92920. /**
  92921. * Called when window becomes inactive.
  92922. * Override this method to provide functionality.
  92923. */
  92924. protected onLostFocus(): void;
  92925. private _pointerInput;
  92926. private _observer;
  92927. private _onLostFocus;
  92928. private pointA;
  92929. private pointB;
  92930. }
  92931. }
  92932. declare module BABYLON {
  92933. /**
  92934. * Manage the pointers inputs to control an arc rotate camera.
  92935. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  92936. */
  92937. export class ArcRotateCameraPointersInput extends BaseCameraPointersInput {
  92938. /**
  92939. * Defines the camera the input is attached to.
  92940. */
  92941. camera: ArcRotateCamera;
  92942. /**
  92943. * Gets the class name of the current input.
  92944. * @returns the class name
  92945. */
  92946. getClassName(): string;
  92947. /**
  92948. * Defines the buttons associated with the input to handle camera move.
  92949. */
  92950. buttons: number[];
  92951. /**
  92952. * Defines the pointer angular sensibility along the X axis or how fast is
  92953. * the camera rotating.
  92954. */
  92955. angularSensibilityX: number;
  92956. /**
  92957. * Defines the pointer angular sensibility along the Y axis or how fast is
  92958. * the camera rotating.
  92959. */
  92960. angularSensibilityY: number;
  92961. /**
  92962. * Defines the pointer pinch precision or how fast is the camera zooming.
  92963. */
  92964. pinchPrecision: number;
  92965. /**
  92966. * pinchDeltaPercentage will be used instead of pinchPrecision if different
  92967. * from 0.
  92968. * It defines the percentage of current camera.radius to use as delta when
  92969. * pinch zoom is used.
  92970. */
  92971. pinchDeltaPercentage: number;
  92972. /**
  92973. * Defines the pointer panning sensibility or how fast is the camera moving.
  92974. */
  92975. panningSensibility: number;
  92976. /**
  92977. * Defines whether panning (2 fingers swipe) is enabled through multitouch.
  92978. */
  92979. multiTouchPanning: boolean;
  92980. /**
  92981. * Defines whether panning is enabled for both pan (2 fingers swipe) and
  92982. * zoom (pinch) through multitouch.
  92983. */
  92984. multiTouchPanAndZoom: boolean;
  92985. /**
  92986. * Revers pinch action direction.
  92987. */
  92988. pinchInwards: boolean;
  92989. private _isPanClick;
  92990. private _twoFingerActivityCount;
  92991. private _isPinching;
  92992. /**
  92993. * Called on pointer POINTERMOVE event if only a single touch is active.
  92994. */
  92995. protected onTouch(point: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  92996. /**
  92997. * Called on pointer POINTERDOUBLETAP event.
  92998. */
  92999. protected onDoubleTap(type: string): void;
  93000. /**
  93001. * Called on pointer POINTERMOVE event if multiple touches are active.
  93002. */
  93003. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  93004. /**
  93005. * Called each time a new POINTERDOWN event occurs. Ie, for each button
  93006. * press.
  93007. */
  93008. protected onButtonDown(evt: PointerEvent): void;
  93009. /**
  93010. * Called each time a new POINTERUP event occurs. Ie, for each button
  93011. * release.
  93012. */
  93013. protected onButtonUp(evt: PointerEvent): void;
  93014. /**
  93015. * Called when window becomes inactive.
  93016. */
  93017. protected onLostFocus(): void;
  93018. }
  93019. }
  93020. declare module BABYLON {
  93021. /**
  93022. * Manage the keyboard inputs to control the movement of an arc rotate camera.
  93023. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  93024. */
  93025. export class ArcRotateCameraKeyboardMoveInput implements ICameraInput<ArcRotateCamera> {
  93026. /**
  93027. * Defines the camera the input is attached to.
  93028. */
  93029. camera: ArcRotateCamera;
  93030. /**
  93031. * Defines the list of key codes associated with the up action (increase alpha)
  93032. */
  93033. keysUp: number[];
  93034. /**
  93035. * Defines the list of key codes associated with the down action (decrease alpha)
  93036. */
  93037. keysDown: number[];
  93038. /**
  93039. * Defines the list of key codes associated with the left action (increase beta)
  93040. */
  93041. keysLeft: number[];
  93042. /**
  93043. * Defines the list of key codes associated with the right action (decrease beta)
  93044. */
  93045. keysRight: number[];
  93046. /**
  93047. * Defines the list of key codes associated with the reset action.
  93048. * Those keys reset the camera to its last stored state (with the method camera.storeState())
  93049. */
  93050. keysReset: number[];
  93051. /**
  93052. * Defines the panning sensibility of the inputs.
  93053. * (How fast is the camera paning)
  93054. */
  93055. panningSensibility: number;
  93056. /**
  93057. * Defines the zooming sensibility of the inputs.
  93058. * (How fast is the camera zooming)
  93059. */
  93060. zoomingSensibility: number;
  93061. /**
  93062. * Defines wether maintaining the alt key down switch the movement mode from
  93063. * orientation to zoom.
  93064. */
  93065. useAltToZoom: boolean;
  93066. /**
  93067. * Rotation speed of the camera
  93068. */
  93069. angularSpeed: number;
  93070. private _keys;
  93071. private _ctrlPressed;
  93072. private _altPressed;
  93073. private _onCanvasBlurObserver;
  93074. private _onKeyboardObserver;
  93075. private _engine;
  93076. private _scene;
  93077. /**
  93078. * Attach the input controls to a specific dom element to get the input from.
  93079. * @param element Defines the element the controls should be listened from
  93080. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  93081. */
  93082. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  93083. /**
  93084. * Detach the current controls from the specified dom element.
  93085. * @param element Defines the element to stop listening the inputs from
  93086. */
  93087. detachControl(element: Nullable<HTMLElement>): void;
  93088. /**
  93089. * Update the current camera state depending on the inputs that have been used this frame.
  93090. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  93091. */
  93092. checkInputs(): void;
  93093. /**
  93094. * Gets the class name of the current intput.
  93095. * @returns the class name
  93096. */
  93097. getClassName(): string;
  93098. /**
  93099. * Get the friendly name associated with the input class.
  93100. * @returns the input friendly name
  93101. */
  93102. getSimpleName(): string;
  93103. }
  93104. }
  93105. declare module BABYLON {
  93106. /**
  93107. * Manage the mouse wheel inputs to control an arc rotate camera.
  93108. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  93109. */
  93110. export class ArcRotateCameraMouseWheelInput implements ICameraInput<ArcRotateCamera> {
  93111. /**
  93112. * Defines the camera the input is attached to.
  93113. */
  93114. camera: ArcRotateCamera;
  93115. /**
  93116. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  93117. */
  93118. wheelPrecision: number;
  93119. /**
  93120. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  93121. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  93122. */
  93123. wheelDeltaPercentage: number;
  93124. private _wheel;
  93125. private _observer;
  93126. /**
  93127. * Attach the input controls to a specific dom element to get the input from.
  93128. * @param element Defines the element the controls should be listened from
  93129. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  93130. */
  93131. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  93132. /**
  93133. * Detach the current controls from the specified dom element.
  93134. * @param element Defines the element to stop listening the inputs from
  93135. */
  93136. detachControl(element: Nullable<HTMLElement>): void;
  93137. /**
  93138. * Gets the class name of the current intput.
  93139. * @returns the class name
  93140. */
  93141. getClassName(): string;
  93142. /**
  93143. * Get the friendly name associated with the input class.
  93144. * @returns the input friendly name
  93145. */
  93146. getSimpleName(): string;
  93147. }
  93148. }
  93149. declare module BABYLON {
  93150. /**
  93151. * Default Inputs manager for the ArcRotateCamera.
  93152. * It groups all the default supported inputs for ease of use.
  93153. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  93154. */
  93155. export class ArcRotateCameraInputsManager extends CameraInputsManager<ArcRotateCamera> {
  93156. /**
  93157. * Instantiates a new ArcRotateCameraInputsManager.
  93158. * @param camera Defines the camera the inputs belong to
  93159. */
  93160. constructor(camera: ArcRotateCamera);
  93161. /**
  93162. * Add mouse wheel input support to the input manager.
  93163. * @returns the current input manager
  93164. */
  93165. addMouseWheel(): ArcRotateCameraInputsManager;
  93166. /**
  93167. * Add pointers input support to the input manager.
  93168. * @returns the current input manager
  93169. */
  93170. addPointers(): ArcRotateCameraInputsManager;
  93171. /**
  93172. * Add keyboard input support to the input manager.
  93173. * @returns the current input manager
  93174. */
  93175. addKeyboard(): ArcRotateCameraInputsManager;
  93176. }
  93177. }
  93178. declare module BABYLON {
  93179. /**
  93180. * This represents an orbital type of camera.
  93181. *
  93182. * 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.
  93183. * 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.
  93184. * @see http://doc.babylonjs.com/babylon101/cameras#arc-rotate-camera
  93185. */
  93186. export class ArcRotateCamera extends TargetCamera {
  93187. /**
  93188. * Defines the rotation angle of the camera along the longitudinal axis.
  93189. */
  93190. alpha: number;
  93191. /**
  93192. * Defines the rotation angle of the camera along the latitudinal axis.
  93193. */
  93194. beta: number;
  93195. /**
  93196. * Defines the radius of the camera from it s target point.
  93197. */
  93198. radius: number;
  93199. protected _target: Vector3;
  93200. protected _targetHost: Nullable<AbstractMesh>;
  93201. /**
  93202. * Defines the target point of the camera.
  93203. * The camera looks towards it form the radius distance.
  93204. */
  93205. target: Vector3;
  93206. /**
  93207. * Define the current local position of the camera in the scene
  93208. */
  93209. position: Vector3;
  93210. /**
  93211. * Current inertia value on the longitudinal axis.
  93212. * The bigger this number the longer it will take for the camera to stop.
  93213. */
  93214. inertialAlphaOffset: number;
  93215. /**
  93216. * Current inertia value on the latitudinal axis.
  93217. * The bigger this number the longer it will take for the camera to stop.
  93218. */
  93219. inertialBetaOffset: number;
  93220. /**
  93221. * Current inertia value on the radius axis.
  93222. * The bigger this number the longer it will take for the camera to stop.
  93223. */
  93224. inertialRadiusOffset: number;
  93225. /**
  93226. * Minimum allowed angle on the longitudinal axis.
  93227. * This can help limiting how the Camera is able to move in the scene.
  93228. */
  93229. lowerAlphaLimit: Nullable<number>;
  93230. /**
  93231. * Maximum allowed angle on the longitudinal axis.
  93232. * This can help limiting how the Camera is able to move in the scene.
  93233. */
  93234. upperAlphaLimit: Nullable<number>;
  93235. /**
  93236. * Minimum allowed angle on the latitudinal axis.
  93237. * This can help limiting how the Camera is able to move in the scene.
  93238. */
  93239. lowerBetaLimit: number;
  93240. /**
  93241. * Maximum allowed angle on the latitudinal axis.
  93242. * This can help limiting how the Camera is able to move in the scene.
  93243. */
  93244. upperBetaLimit: number;
  93245. /**
  93246. * Minimum allowed distance of the camera to the target (The camera can not get closer).
  93247. * This can help limiting how the Camera is able to move in the scene.
  93248. */
  93249. lowerRadiusLimit: Nullable<number>;
  93250. /**
  93251. * Maximum allowed distance of the camera to the target (The camera can not get further).
  93252. * This can help limiting how the Camera is able to move in the scene.
  93253. */
  93254. upperRadiusLimit: Nullable<number>;
  93255. /**
  93256. * Defines the current inertia value used during panning of the camera along the X axis.
  93257. */
  93258. inertialPanningX: number;
  93259. /**
  93260. * Defines the current inertia value used during panning of the camera along the Y axis.
  93261. */
  93262. inertialPanningY: number;
  93263. /**
  93264. * Defines the distance used to consider the camera in pan mode vs pinch/zoom.
  93265. * Basically if your fingers moves away from more than this distance you will be considered
  93266. * in pinch mode.
  93267. */
  93268. pinchToPanMaxDistance: number;
  93269. /**
  93270. * Defines the maximum distance the camera can pan.
  93271. * This could help keeping the cammera always in your scene.
  93272. */
  93273. panningDistanceLimit: Nullable<number>;
  93274. /**
  93275. * Defines the target of the camera before paning.
  93276. */
  93277. panningOriginTarget: Vector3;
  93278. /**
  93279. * Defines the value of the inertia used during panning.
  93280. * 0 would mean stop inertia and one would mean no decelleration at all.
  93281. */
  93282. panningInertia: number;
  93283. /**
  93284. * Gets or Set the pointer angular sensibility along the X axis or how fast is the camera rotating.
  93285. */
  93286. angularSensibilityX: number;
  93287. /**
  93288. * Gets or Set the pointer angular sensibility along the Y axis or how fast is the camera rotating.
  93289. */
  93290. angularSensibilityY: number;
  93291. /**
  93292. * Gets or Set the pointer pinch precision or how fast is the camera zooming.
  93293. */
  93294. pinchPrecision: number;
  93295. /**
  93296. * Gets or Set the pointer pinch delta percentage or how fast is the camera zooming.
  93297. * It will be used instead of pinchDeltaPrecision if different from 0.
  93298. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  93299. */
  93300. pinchDeltaPercentage: number;
  93301. /**
  93302. * Gets or Set the pointer panning sensibility or how fast is the camera moving.
  93303. */
  93304. panningSensibility: number;
  93305. /**
  93306. * Gets or Set the list of keyboard keys used to control beta angle in a positive direction.
  93307. */
  93308. keysUp: number[];
  93309. /**
  93310. * Gets or Set the list of keyboard keys used to control beta angle in a negative direction.
  93311. */
  93312. keysDown: number[];
  93313. /**
  93314. * Gets or Set the list of keyboard keys used to control alpha angle in a negative direction.
  93315. */
  93316. keysLeft: number[];
  93317. /**
  93318. * Gets or Set the list of keyboard keys used to control alpha angle in a positive direction.
  93319. */
  93320. keysRight: number[];
  93321. /**
  93322. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  93323. */
  93324. wheelPrecision: number;
  93325. /**
  93326. * Gets or Set the mouse wheel delta percentage or how fast is the camera zooming.
  93327. * It will be used instead of pinchDeltaPrecision if different from 0.
  93328. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  93329. */
  93330. wheelDeltaPercentage: number;
  93331. /**
  93332. * Defines how much the radius should be scaled while zomming on a particular mesh (through the zoomOn function)
  93333. */
  93334. zoomOnFactor: number;
  93335. /**
  93336. * Defines a screen offset for the camera position.
  93337. */
  93338. targetScreenOffset: Vector2;
  93339. /**
  93340. * Allows the camera to be completely reversed.
  93341. * If false the camera can not arrive upside down.
  93342. */
  93343. allowUpsideDown: boolean;
  93344. /**
  93345. * Define if double tap/click is used to restore the previously saved state of the camera.
  93346. */
  93347. useInputToRestoreState: boolean;
  93348. /** @hidden */
  93349. _viewMatrix: Matrix;
  93350. /** @hidden */
  93351. _useCtrlForPanning: boolean;
  93352. /** @hidden */
  93353. _panningMouseButton: number;
  93354. /**
  93355. * Defines the input associated to the camera.
  93356. */
  93357. inputs: ArcRotateCameraInputsManager;
  93358. /** @hidden */
  93359. _reset: () => void;
  93360. /**
  93361. * Defines the allowed panning axis.
  93362. */
  93363. panningAxis: Vector3;
  93364. protected _localDirection: Vector3;
  93365. protected _transformedDirection: Vector3;
  93366. private _bouncingBehavior;
  93367. /**
  93368. * Gets the bouncing behavior of the camera if it has been enabled.
  93369. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  93370. */
  93371. readonly bouncingBehavior: Nullable<BouncingBehavior>;
  93372. /**
  93373. * Defines if the bouncing behavior of the camera is enabled on the camera.
  93374. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  93375. */
  93376. useBouncingBehavior: boolean;
  93377. private _framingBehavior;
  93378. /**
  93379. * Gets the framing behavior of the camera if it has been enabled.
  93380. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  93381. */
  93382. readonly framingBehavior: Nullable<FramingBehavior>;
  93383. /**
  93384. * Defines if the framing behavior of the camera is enabled on the camera.
  93385. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  93386. */
  93387. useFramingBehavior: boolean;
  93388. private _autoRotationBehavior;
  93389. /**
  93390. * Gets the auto rotation behavior of the camera if it has been enabled.
  93391. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  93392. */
  93393. readonly autoRotationBehavior: Nullable<AutoRotationBehavior>;
  93394. /**
  93395. * Defines if the auto rotation behavior of the camera is enabled on the camera.
  93396. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  93397. */
  93398. useAutoRotationBehavior: boolean;
  93399. /**
  93400. * Observable triggered when the mesh target has been changed on the camera.
  93401. */
  93402. onMeshTargetChangedObservable: Observable<Nullable<AbstractMesh>>;
  93403. /**
  93404. * Event raised when the camera is colliding with a mesh.
  93405. */
  93406. onCollide: (collidedMesh: AbstractMesh) => void;
  93407. /**
  93408. * Defines whether the camera should check collision with the objects oh the scene.
  93409. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#how-can-i-do-this
  93410. */
  93411. checkCollisions: boolean;
  93412. /**
  93413. * Defines the collision radius of the camera.
  93414. * This simulates a sphere around the camera.
  93415. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  93416. */
  93417. collisionRadius: Vector3;
  93418. protected _collider: Collider;
  93419. protected _previousPosition: Vector3;
  93420. protected _collisionVelocity: Vector3;
  93421. protected _newPosition: Vector3;
  93422. protected _previousAlpha: number;
  93423. protected _previousBeta: number;
  93424. protected _previousRadius: number;
  93425. protected _collisionTriggered: boolean;
  93426. protected _targetBoundingCenter: Nullable<Vector3>;
  93427. private _computationVector;
  93428. private _tempAxisVector;
  93429. private _tempAxisRotationMatrix;
  93430. /**
  93431. * Instantiates a new ArcRotateCamera in a given scene
  93432. * @param name Defines the name of the camera
  93433. * @param alpha Defines the camera rotation along the logitudinal axis
  93434. * @param beta Defines the camera rotation along the latitudinal axis
  93435. * @param radius Defines the camera distance from its target
  93436. * @param target Defines the camera target
  93437. * @param scene Defines the scene the camera belongs to
  93438. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  93439. */
  93440. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  93441. /** @hidden */
  93442. _initCache(): void;
  93443. /** @hidden */
  93444. _updateCache(ignoreParentClass?: boolean): void;
  93445. protected _getTargetPosition(): Vector3;
  93446. private _storedAlpha;
  93447. private _storedBeta;
  93448. private _storedRadius;
  93449. private _storedTarget;
  93450. /**
  93451. * Stores the current state of the camera (alpha, beta, radius and target)
  93452. * @returns the camera itself
  93453. */
  93454. storeState(): Camera;
  93455. /**
  93456. * @hidden
  93457. * Restored camera state. You must call storeState() first
  93458. */
  93459. _restoreStateValues(): boolean;
  93460. /** @hidden */
  93461. _isSynchronizedViewMatrix(): boolean;
  93462. /**
  93463. * Attached controls to the current camera.
  93464. * @param element Defines the element the controls should be listened from
  93465. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  93466. * @param useCtrlForPanning Defines whether ctrl is used for paning within the controls
  93467. * @param panningMouseButton Defines whether panning is allowed through mouse click button
  93468. */
  93469. attachControl(element: HTMLElement, noPreventDefault?: boolean, useCtrlForPanning?: boolean, panningMouseButton?: number): void;
  93470. /**
  93471. * Detach the current controls from the camera.
  93472. * The camera will stop reacting to inputs.
  93473. * @param element Defines the element to stop listening the inputs from
  93474. */
  93475. detachControl(element: HTMLElement): void;
  93476. /** @hidden */
  93477. _checkInputs(): void;
  93478. protected _checkLimits(): void;
  93479. /**
  93480. * Rebuilds angles (alpha, beta) and radius from the give position and target
  93481. * @param updateView defines a boolean forcing the camera to update its position with a view matrix computation first (default is true)
  93482. */
  93483. rebuildAnglesAndRadius(updateView?: boolean): void;
  93484. /**
  93485. * Use a position to define the current camera related information like aplha, beta and radius
  93486. * @param position Defines the position to set the camera at
  93487. */
  93488. setPosition(position: Vector3): void;
  93489. /**
  93490. * Defines the target the camera should look at.
  93491. * This will automatically adapt alpha beta and radius to fit within the new target.
  93492. * @param target Defines the new target as a Vector or a mesh
  93493. * @param toBoundingCenter In case of a mesh target, defines wether to target the mesh position or its bounding information center
  93494. * @param allowSamePosition If false, prevents reapplying the new computed position if it is identical to the current one (optim)
  93495. */
  93496. setTarget(target: AbstractMesh | Vector3, toBoundingCenter?: boolean, allowSamePosition?: boolean): void;
  93497. /** @hidden */
  93498. _getViewMatrix(): Matrix;
  93499. protected _onCollisionPositionChange: (collisionId: number, newPosition: Vector3, collidedMesh?: Nullable<AbstractMesh>) => void;
  93500. /**
  93501. * Zooms on a mesh to be at the min distance where we could see it fully in the current viewport.
  93502. * @param meshes Defines the mesh to zoom on
  93503. * @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)
  93504. */
  93505. zoomOn(meshes?: AbstractMesh[], doNotUpdateMaxZ?: boolean): void;
  93506. /**
  93507. * Focus on a mesh or a bounding box. This adapts the target and maxRadius if necessary but does not update the current radius.
  93508. * The target will be changed but the radius
  93509. * @param meshesOrMinMaxVectorAndDistance Defines the mesh or bounding info to focus on
  93510. * @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)
  93511. */
  93512. focusOn(meshesOrMinMaxVectorAndDistance: AbstractMesh[] | {
  93513. min: Vector3;
  93514. max: Vector3;
  93515. distance: number;
  93516. }, doNotUpdateMaxZ?: boolean): void;
  93517. /**
  93518. * @override
  93519. * Override Camera.createRigCamera
  93520. */
  93521. createRigCamera(name: string, cameraIndex: number): Camera;
  93522. /**
  93523. * @hidden
  93524. * @override
  93525. * Override Camera._updateRigCameras
  93526. */
  93527. _updateRigCameras(): void;
  93528. /**
  93529. * Destroy the camera and release the current resources hold by it.
  93530. */
  93531. dispose(): void;
  93532. /**
  93533. * Gets the current object class name.
  93534. * @return the class name
  93535. */
  93536. getClassName(): string;
  93537. }
  93538. }
  93539. declare module BABYLON {
  93540. /**
  93541. * The autoRotation behavior (AutoRotationBehavior) is designed to create a smooth rotation of an ArcRotateCamera when there is no user interaction.
  93542. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  93543. */
  93544. export class AutoRotationBehavior implements Behavior<ArcRotateCamera> {
  93545. /**
  93546. * Gets the name of the behavior.
  93547. */
  93548. readonly name: string;
  93549. private _zoomStopsAnimation;
  93550. private _idleRotationSpeed;
  93551. private _idleRotationWaitTime;
  93552. private _idleRotationSpinupTime;
  93553. /**
  93554. * Sets the flag that indicates if user zooming should stop animation.
  93555. */
  93556. /**
  93557. * Gets the flag that indicates if user zooming should stop animation.
  93558. */
  93559. zoomStopsAnimation: boolean;
  93560. /**
  93561. * Sets the default speed at which the camera rotates around the model.
  93562. */
  93563. /**
  93564. * Gets the default speed at which the camera rotates around the model.
  93565. */
  93566. idleRotationSpeed: number;
  93567. /**
  93568. * Sets the time (in milliseconds) to wait after user interaction before the camera starts rotating.
  93569. */
  93570. /**
  93571. * Gets the time (milliseconds) to wait after user interaction before the camera starts rotating.
  93572. */
  93573. idleRotationWaitTime: number;
  93574. /**
  93575. * Sets the time (milliseconds) to take to spin up to the full idle rotation speed.
  93576. */
  93577. /**
  93578. * Gets the time (milliseconds) to take to spin up to the full idle rotation speed.
  93579. */
  93580. idleRotationSpinupTime: number;
  93581. /**
  93582. * Gets a value indicating if the camera is currently rotating because of this behavior
  93583. */
  93584. readonly rotationInProgress: boolean;
  93585. private _onPrePointerObservableObserver;
  93586. private _onAfterCheckInputsObserver;
  93587. private _attachedCamera;
  93588. private _isPointerDown;
  93589. private _lastFrameTime;
  93590. private _lastInteractionTime;
  93591. private _cameraRotationSpeed;
  93592. /**
  93593. * Initializes the behavior.
  93594. */
  93595. init(): void;
  93596. /**
  93597. * Attaches the behavior to its arc rotate camera.
  93598. * @param camera Defines the camera to attach the behavior to
  93599. */
  93600. attach(camera: ArcRotateCamera): void;
  93601. /**
  93602. * Detaches the behavior from its current arc rotate camera.
  93603. */
  93604. detach(): void;
  93605. /**
  93606. * Returns true if user is scrolling.
  93607. * @return true if user is scrolling.
  93608. */
  93609. private _userIsZooming;
  93610. private _lastFrameRadius;
  93611. private _shouldAnimationStopForInteraction;
  93612. /**
  93613. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  93614. */
  93615. private _applyUserInteraction;
  93616. private _userIsMoving;
  93617. }
  93618. }
  93619. declare module BABYLON {
  93620. /**
  93621. * A behavior that when attached to a mesh will will place a specified node on the meshes face pointing towards the camera
  93622. */
  93623. export class AttachToBoxBehavior implements Behavior<Mesh> {
  93624. private ui;
  93625. /**
  93626. * The name of the behavior
  93627. */
  93628. name: string;
  93629. /**
  93630. * The distance away from the face of the mesh that the UI should be attached to (default: 0.15)
  93631. */
  93632. distanceAwayFromFace: number;
  93633. /**
  93634. * The distance from the bottom of the face that the UI should be attached to (default: 0.15)
  93635. */
  93636. distanceAwayFromBottomOfFace: number;
  93637. private _faceVectors;
  93638. private _target;
  93639. private _scene;
  93640. private _onRenderObserver;
  93641. private _tmpMatrix;
  93642. private _tmpVector;
  93643. /**
  93644. * Creates the AttachToBoxBehavior, used to attach UI to the closest face of the box to a camera
  93645. * @param ui The transform node that should be attched to the mesh
  93646. */
  93647. constructor(ui: TransformNode);
  93648. /**
  93649. * Initializes the behavior
  93650. */
  93651. init(): void;
  93652. private _closestFace;
  93653. private _zeroVector;
  93654. private _lookAtTmpMatrix;
  93655. private _lookAtToRef;
  93656. /**
  93657. * Attaches the AttachToBoxBehavior to the passed in mesh
  93658. * @param target The mesh that the specified node will be attached to
  93659. */
  93660. attach(target: Mesh): void;
  93661. /**
  93662. * Detaches the behavior from the mesh
  93663. */
  93664. detach(): void;
  93665. }
  93666. }
  93667. declare module BABYLON {
  93668. /**
  93669. * A behavior that when attached to a mesh will allow the mesh to fade in and out
  93670. */
  93671. export class FadeInOutBehavior implements Behavior<Mesh> {
  93672. /**
  93673. * Time in milliseconds to delay before fading in (Default: 0)
  93674. */
  93675. delay: number;
  93676. /**
  93677. * Time in milliseconds for the mesh to fade in (Default: 300)
  93678. */
  93679. fadeInTime: number;
  93680. private _millisecondsPerFrame;
  93681. private _hovered;
  93682. private _hoverValue;
  93683. private _ownerNode;
  93684. /**
  93685. * Instatiates the FadeInOutBehavior
  93686. */
  93687. constructor();
  93688. /**
  93689. * The name of the behavior
  93690. */
  93691. readonly name: string;
  93692. /**
  93693. * Initializes the behavior
  93694. */
  93695. init(): void;
  93696. /**
  93697. * Attaches the fade behavior on the passed in mesh
  93698. * @param ownerNode The mesh that will be faded in/out once attached
  93699. */
  93700. attach(ownerNode: Mesh): void;
  93701. /**
  93702. * Detaches the behavior from the mesh
  93703. */
  93704. detach(): void;
  93705. /**
  93706. * Triggers the mesh to begin fading in or out
  93707. * @param value if the object should fade in or out (true to fade in)
  93708. */
  93709. fadeIn(value: boolean): void;
  93710. private _update;
  93711. private _setAllVisibility;
  93712. }
  93713. }
  93714. declare module BABYLON {
  93715. /**
  93716. * Class containing a set of static utilities functions for managing Pivots
  93717. * @hidden
  93718. */
  93719. export class PivotTools {
  93720. private static _PivotCached;
  93721. private static _OldPivotPoint;
  93722. private static _PivotTranslation;
  93723. private static _PivotTmpVector;
  93724. /** @hidden */
  93725. static _RemoveAndStorePivotPoint(mesh: AbstractMesh): void;
  93726. /** @hidden */
  93727. static _RestorePivotPoint(mesh: AbstractMesh): void;
  93728. }
  93729. }
  93730. declare module BABYLON {
  93731. /**
  93732. * Class containing static functions to help procedurally build meshes
  93733. */
  93734. export class PlaneBuilder {
  93735. /**
  93736. * Creates a plane mesh
  93737. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  93738. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  93739. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  93740. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  93741. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  93742. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  93743. * @param name defines the name of the mesh
  93744. * @param options defines the options used to create the mesh
  93745. * @param scene defines the hosting scene
  93746. * @returns the plane mesh
  93747. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  93748. */
  93749. static CreatePlane(name: string, options: {
  93750. size?: number;
  93751. width?: number;
  93752. height?: number;
  93753. sideOrientation?: number;
  93754. frontUVs?: Vector4;
  93755. backUVs?: Vector4;
  93756. updatable?: boolean;
  93757. sourcePlane?: Plane;
  93758. }, scene: Scene): Mesh;
  93759. }
  93760. }
  93761. declare module BABYLON {
  93762. /**
  93763. * A behavior that when attached to a mesh will allow the mesh to be dragged around the screen based on pointer events
  93764. */
  93765. export class PointerDragBehavior implements Behavior<AbstractMesh> {
  93766. private static _AnyMouseID;
  93767. private _attachedNode;
  93768. private _dragPlane;
  93769. private _scene;
  93770. private _pointerObserver;
  93771. private _beforeRenderObserver;
  93772. private static _planeScene;
  93773. private _useAlternatePickedPointAboveMaxDragAngleDragSpeed;
  93774. /**
  93775. * 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)
  93776. */
  93777. maxDragAngle: number;
  93778. /**
  93779. * @hidden
  93780. */
  93781. _useAlternatePickedPointAboveMaxDragAngle: boolean;
  93782. /**
  93783. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  93784. */
  93785. currentDraggingPointerID: number;
  93786. /**
  93787. * The last position where the pointer hit the drag plane in world space
  93788. */
  93789. lastDragPosition: Vector3;
  93790. /**
  93791. * If the behavior is currently in a dragging state
  93792. */
  93793. dragging: boolean;
  93794. /**
  93795. * 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)
  93796. */
  93797. dragDeltaRatio: number;
  93798. /**
  93799. * If the drag plane orientation should be updated during the dragging (Default: true)
  93800. */
  93801. updateDragPlane: boolean;
  93802. private _debugMode;
  93803. private _moving;
  93804. /**
  93805. * Fires each time the attached mesh is dragged with the pointer
  93806. * * delta between last drag position and current drag position in world space
  93807. * * dragDistance along the drag axis
  93808. * * dragPlaneNormal normal of the current drag plane used during the drag
  93809. * * dragPlanePoint in world space where the drag intersects the drag plane
  93810. */
  93811. onDragObservable: Observable<{
  93812. delta: Vector3;
  93813. dragPlanePoint: Vector3;
  93814. dragPlaneNormal: Vector3;
  93815. dragDistance: number;
  93816. pointerId: number;
  93817. }>;
  93818. /**
  93819. * Fires each time a drag begins (eg. mouse down on mesh)
  93820. */
  93821. onDragStartObservable: Observable<{
  93822. dragPlanePoint: Vector3;
  93823. pointerId: number;
  93824. }>;
  93825. /**
  93826. * Fires each time a drag ends (eg. mouse release after drag)
  93827. */
  93828. onDragEndObservable: Observable<{
  93829. dragPlanePoint: Vector3;
  93830. pointerId: number;
  93831. }>;
  93832. /**
  93833. * If the attached mesh should be moved when dragged
  93834. */
  93835. moveAttached: boolean;
  93836. /**
  93837. * If the drag behavior will react to drag events (Default: true)
  93838. */
  93839. enabled: boolean;
  93840. /**
  93841. * If camera controls should be detached during the drag
  93842. */
  93843. detachCameraControls: boolean;
  93844. /**
  93845. * If set, the drag plane/axis will be rotated based on the attached mesh's world rotation (Default: true)
  93846. */
  93847. useObjectOrienationForDragging: boolean;
  93848. private _options;
  93849. /**
  93850. * Creates a pointer drag behavior that can be attached to a mesh
  93851. * @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)
  93852. */
  93853. constructor(options?: {
  93854. dragAxis?: Vector3;
  93855. dragPlaneNormal?: Vector3;
  93856. });
  93857. /**
  93858. * Predicate to determine if it is valid to move the object to a new position when it is moved
  93859. */
  93860. validateDrag: (targetPosition: Vector3) => boolean;
  93861. /**
  93862. * The name of the behavior
  93863. */
  93864. readonly name: string;
  93865. /**
  93866. * Initializes the behavior
  93867. */
  93868. init(): void;
  93869. private _tmpVector;
  93870. private _alternatePickedPoint;
  93871. private _worldDragAxis;
  93872. private _targetPosition;
  93873. private _attachedElement;
  93874. /**
  93875. * Attaches the drag behavior the passed in mesh
  93876. * @param ownerNode The mesh that will be dragged around once attached
  93877. */
  93878. attach(ownerNode: AbstractMesh): void;
  93879. /**
  93880. * Force relase the drag action by code.
  93881. */
  93882. releaseDrag(): void;
  93883. private _startDragRay;
  93884. private _lastPointerRay;
  93885. /**
  93886. * Simulates the start of a pointer drag event on the behavior
  93887. * @param pointerId pointerID of the pointer that should be simulated (Default: Any mouse pointer ID)
  93888. * @param fromRay initial ray of the pointer to be simulated (Default: Ray from camera to attached mesh)
  93889. * @param startPickedPoint picked point of the pointer to be simulated (Default: attached mesh position)
  93890. */
  93891. startDrag(pointerId?: number, fromRay?: Ray, startPickedPoint?: Vector3): void;
  93892. private _startDrag;
  93893. private _dragDelta;
  93894. private _moveDrag;
  93895. private _pickWithRayOnDragPlane;
  93896. private _pointA;
  93897. private _pointB;
  93898. private _pointC;
  93899. private _lineA;
  93900. private _lineB;
  93901. private _localAxis;
  93902. private _lookAt;
  93903. private _updateDragPlanePosition;
  93904. /**
  93905. * Detaches the behavior from the mesh
  93906. */
  93907. detach(): void;
  93908. }
  93909. }
  93910. declare module BABYLON {
  93911. /**
  93912. * A behavior that when attached to a mesh will allow the mesh to be scaled
  93913. */
  93914. export class MultiPointerScaleBehavior implements Behavior<Mesh> {
  93915. private _dragBehaviorA;
  93916. private _dragBehaviorB;
  93917. private _startDistance;
  93918. private _initialScale;
  93919. private _targetScale;
  93920. private _ownerNode;
  93921. private _sceneRenderObserver;
  93922. /**
  93923. * Instantiate a new behavior that when attached to a mesh will allow the mesh to be scaled
  93924. */
  93925. constructor();
  93926. /**
  93927. * The name of the behavior
  93928. */
  93929. readonly name: string;
  93930. /**
  93931. * Initializes the behavior
  93932. */
  93933. init(): void;
  93934. private _getCurrentDistance;
  93935. /**
  93936. * Attaches the scale behavior the passed in mesh
  93937. * @param ownerNode The mesh that will be scaled around once attached
  93938. */
  93939. attach(ownerNode: Mesh): void;
  93940. /**
  93941. * Detaches the behavior from the mesh
  93942. */
  93943. detach(): void;
  93944. }
  93945. }
  93946. declare module BABYLON {
  93947. /**
  93948. * 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
  93949. */
  93950. export class SixDofDragBehavior implements Behavior<Mesh> {
  93951. private static _virtualScene;
  93952. private _ownerNode;
  93953. private _sceneRenderObserver;
  93954. private _scene;
  93955. private _targetPosition;
  93956. private _virtualOriginMesh;
  93957. private _virtualDragMesh;
  93958. private _pointerObserver;
  93959. private _moving;
  93960. private _startingOrientation;
  93961. /**
  93962. * 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)
  93963. */
  93964. private zDragFactor;
  93965. /**
  93966. * If the object should rotate to face the drag origin
  93967. */
  93968. rotateDraggedObject: boolean;
  93969. /**
  93970. * If the behavior is currently in a dragging state
  93971. */
  93972. dragging: boolean;
  93973. /**
  93974. * 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)
  93975. */
  93976. dragDeltaRatio: number;
  93977. /**
  93978. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  93979. */
  93980. currentDraggingPointerID: number;
  93981. /**
  93982. * If camera controls should be detached during the drag
  93983. */
  93984. detachCameraControls: boolean;
  93985. /**
  93986. * Fires each time a drag starts
  93987. */
  93988. onDragStartObservable: Observable<{}>;
  93989. /**
  93990. * Fires each time a drag ends (eg. mouse release after drag)
  93991. */
  93992. onDragEndObservable: Observable<{}>;
  93993. /**
  93994. * 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
  93995. */
  93996. constructor();
  93997. /**
  93998. * The name of the behavior
  93999. */
  94000. readonly name: string;
  94001. /**
  94002. * Initializes the behavior
  94003. */
  94004. init(): void;
  94005. /**
  94006. * Attaches the scale behavior the passed in mesh
  94007. * @param ownerNode The mesh that will be scaled around once attached
  94008. */
  94009. attach(ownerNode: Mesh): void;
  94010. /**
  94011. * Detaches the behavior from the mesh
  94012. */
  94013. detach(): void;
  94014. }
  94015. }
  94016. declare module BABYLON {
  94017. /**
  94018. * Class used to apply inverse kinematics to bones
  94019. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#boneikcontroller
  94020. */
  94021. export class BoneIKController {
  94022. private static _tmpVecs;
  94023. private static _tmpQuat;
  94024. private static _tmpMats;
  94025. /**
  94026. * Gets or sets the target mesh
  94027. */
  94028. targetMesh: AbstractMesh;
  94029. /** Gets or sets the mesh used as pole */
  94030. poleTargetMesh: AbstractMesh;
  94031. /**
  94032. * Gets or sets the bone used as pole
  94033. */
  94034. poleTargetBone: Nullable<Bone>;
  94035. /**
  94036. * Gets or sets the target position
  94037. */
  94038. targetPosition: Vector3;
  94039. /**
  94040. * Gets or sets the pole target position
  94041. */
  94042. poleTargetPosition: Vector3;
  94043. /**
  94044. * Gets or sets the pole target local offset
  94045. */
  94046. poleTargetLocalOffset: Vector3;
  94047. /**
  94048. * Gets or sets the pole angle
  94049. */
  94050. poleAngle: number;
  94051. /**
  94052. * Gets or sets the mesh associated with the controller
  94053. */
  94054. mesh: AbstractMesh;
  94055. /**
  94056. * 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)
  94057. */
  94058. slerpAmount: number;
  94059. private _bone1Quat;
  94060. private _bone1Mat;
  94061. private _bone2Ang;
  94062. private _bone1;
  94063. private _bone2;
  94064. private _bone1Length;
  94065. private _bone2Length;
  94066. private _maxAngle;
  94067. private _maxReach;
  94068. private _rightHandedSystem;
  94069. private _bendAxis;
  94070. private _slerping;
  94071. private _adjustRoll;
  94072. /**
  94073. * Gets or sets maximum allowed angle
  94074. */
  94075. maxAngle: number;
  94076. /**
  94077. * Creates a new BoneIKController
  94078. * @param mesh defines the mesh to control
  94079. * @param bone defines the bone to control
  94080. * @param options defines options to set up the controller
  94081. */
  94082. constructor(mesh: AbstractMesh, bone: Bone, options?: {
  94083. targetMesh?: AbstractMesh;
  94084. poleTargetMesh?: AbstractMesh;
  94085. poleTargetBone?: Bone;
  94086. poleTargetLocalOffset?: Vector3;
  94087. poleAngle?: number;
  94088. bendAxis?: Vector3;
  94089. maxAngle?: number;
  94090. slerpAmount?: number;
  94091. });
  94092. private _setMaxAngle;
  94093. /**
  94094. * Force the controller to update the bones
  94095. */
  94096. update(): void;
  94097. }
  94098. }
  94099. declare module BABYLON {
  94100. /**
  94101. * Class used to make a bone look toward a point in space
  94102. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#bonelookcontroller
  94103. */
  94104. export class BoneLookController {
  94105. private static _tmpVecs;
  94106. private static _tmpQuat;
  94107. private static _tmpMats;
  94108. /**
  94109. * The target Vector3 that the bone will look at
  94110. */
  94111. target: Vector3;
  94112. /**
  94113. * The mesh that the bone is attached to
  94114. */
  94115. mesh: AbstractMesh;
  94116. /**
  94117. * The bone that will be looking to the target
  94118. */
  94119. bone: Bone;
  94120. /**
  94121. * The up axis of the coordinate system that is used when the bone is rotated
  94122. */
  94123. upAxis: Vector3;
  94124. /**
  94125. * The space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD
  94126. */
  94127. upAxisSpace: Space;
  94128. /**
  94129. * Used to make an adjustment to the yaw of the bone
  94130. */
  94131. adjustYaw: number;
  94132. /**
  94133. * Used to make an adjustment to the pitch of the bone
  94134. */
  94135. adjustPitch: number;
  94136. /**
  94137. * Used to make an adjustment to the roll of the bone
  94138. */
  94139. adjustRoll: number;
  94140. /**
  94141. * 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)
  94142. */
  94143. slerpAmount: number;
  94144. private _minYaw;
  94145. private _maxYaw;
  94146. private _minPitch;
  94147. private _maxPitch;
  94148. private _minYawSin;
  94149. private _minYawCos;
  94150. private _maxYawSin;
  94151. private _maxYawCos;
  94152. private _midYawConstraint;
  94153. private _minPitchTan;
  94154. private _maxPitchTan;
  94155. private _boneQuat;
  94156. private _slerping;
  94157. private _transformYawPitch;
  94158. private _transformYawPitchInv;
  94159. private _firstFrameSkipped;
  94160. private _yawRange;
  94161. private _fowardAxis;
  94162. /**
  94163. * Gets or sets the minimum yaw angle that the bone can look to
  94164. */
  94165. minYaw: number;
  94166. /**
  94167. * Gets or sets the maximum yaw angle that the bone can look to
  94168. */
  94169. maxYaw: number;
  94170. /**
  94171. * Gets or sets the minimum pitch angle that the bone can look to
  94172. */
  94173. minPitch: number;
  94174. /**
  94175. * Gets or sets the maximum pitch angle that the bone can look to
  94176. */
  94177. maxPitch: number;
  94178. /**
  94179. * Create a BoneLookController
  94180. * @param mesh the mesh that the bone belongs to
  94181. * @param bone the bone that will be looking to the target
  94182. * @param target the target Vector3 to look at
  94183. * @param options optional settings:
  94184. * * maxYaw: the maximum angle the bone will yaw to
  94185. * * minYaw: the minimum angle the bone will yaw to
  94186. * * maxPitch: the maximum angle the bone will pitch to
  94187. * * minPitch: the minimum angle the bone will yaw to
  94188. * * slerpAmount: set the between 0 and 1 to make the bone slerp to the target.
  94189. * * upAxis: the up axis of the coordinate system
  94190. * * upAxisSpace: the space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD.
  94191. * * yawAxis: set yawAxis if the bone does not yaw on the y axis
  94192. * * pitchAxis: set pitchAxis if the bone does not pitch on the x axis
  94193. * * adjustYaw: used to make an adjustment to the yaw of the bone
  94194. * * adjustPitch: used to make an adjustment to the pitch of the bone
  94195. * * adjustRoll: used to make an adjustment to the roll of the bone
  94196. **/
  94197. constructor(mesh: AbstractMesh, bone: Bone, target: Vector3, options?: {
  94198. maxYaw?: number;
  94199. minYaw?: number;
  94200. maxPitch?: number;
  94201. minPitch?: number;
  94202. slerpAmount?: number;
  94203. upAxis?: Vector3;
  94204. upAxisSpace?: Space;
  94205. yawAxis?: Vector3;
  94206. pitchAxis?: Vector3;
  94207. adjustYaw?: number;
  94208. adjustPitch?: number;
  94209. adjustRoll?: number;
  94210. });
  94211. /**
  94212. * Update the bone to look at the target. This should be called before the scene is rendered (use scene.registerBeforeRender())
  94213. */
  94214. update(): void;
  94215. private _getAngleDiff;
  94216. private _getAngleBetween;
  94217. private _isAngleBetween;
  94218. }
  94219. }
  94220. declare module BABYLON {
  94221. /**
  94222. * Manage the gamepad inputs to control an arc rotate camera.
  94223. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  94224. */
  94225. export class ArcRotateCameraGamepadInput implements ICameraInput<ArcRotateCamera> {
  94226. /**
  94227. * Defines the camera the input is attached to.
  94228. */
  94229. camera: ArcRotateCamera;
  94230. /**
  94231. * Defines the gamepad the input is gathering event from.
  94232. */
  94233. gamepad: Nullable<Gamepad>;
  94234. /**
  94235. * Defines the gamepad rotation sensiblity.
  94236. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  94237. */
  94238. gamepadRotationSensibility: number;
  94239. /**
  94240. * Defines the gamepad move sensiblity.
  94241. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  94242. */
  94243. gamepadMoveSensibility: number;
  94244. private _onGamepadConnectedObserver;
  94245. private _onGamepadDisconnectedObserver;
  94246. /**
  94247. * Attach the input controls to a specific dom element to get the input from.
  94248. * @param element Defines the element the controls should be listened from
  94249. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  94250. */
  94251. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  94252. /**
  94253. * Detach the current controls from the specified dom element.
  94254. * @param element Defines the element to stop listening the inputs from
  94255. */
  94256. detachControl(element: Nullable<HTMLElement>): void;
  94257. /**
  94258. * Update the current camera state depending on the inputs that have been used this frame.
  94259. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  94260. */
  94261. checkInputs(): void;
  94262. /**
  94263. * Gets the class name of the current intput.
  94264. * @returns the class name
  94265. */
  94266. getClassName(): string;
  94267. /**
  94268. * Get the friendly name associated with the input class.
  94269. * @returns the input friendly name
  94270. */
  94271. getSimpleName(): string;
  94272. }
  94273. }
  94274. declare module BABYLON {
  94275. interface ArcRotateCameraInputsManager {
  94276. /**
  94277. * Add orientation input support to the input manager.
  94278. * @returns the current input manager
  94279. */
  94280. addVRDeviceOrientation(): ArcRotateCameraInputsManager;
  94281. }
  94282. /**
  94283. * Manage the device orientation inputs (gyroscope) to control an arc rotate camera.
  94284. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  94285. */
  94286. export class ArcRotateCameraVRDeviceOrientationInput implements ICameraInput<ArcRotateCamera> {
  94287. /**
  94288. * Defines the camera the input is attached to.
  94289. */
  94290. camera: ArcRotateCamera;
  94291. /**
  94292. * Defines a correction factor applied on the alpha value retrieved from the orientation events.
  94293. */
  94294. alphaCorrection: number;
  94295. /**
  94296. * Defines a correction factor applied on the gamma value retrieved from the orientation events.
  94297. */
  94298. gammaCorrection: number;
  94299. private _alpha;
  94300. private _gamma;
  94301. private _dirty;
  94302. private _deviceOrientationHandler;
  94303. /**
  94304. * Instantiate a new ArcRotateCameraVRDeviceOrientationInput.
  94305. */
  94306. constructor();
  94307. /**
  94308. * Attach the input controls to a specific dom element to get the input from.
  94309. * @param element Defines the element the controls should be listened from
  94310. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  94311. */
  94312. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  94313. /** @hidden */
  94314. _onOrientationEvent(evt: DeviceOrientationEvent): void;
  94315. /**
  94316. * Update the current camera state depending on the inputs that have been used this frame.
  94317. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  94318. */
  94319. checkInputs(): void;
  94320. /**
  94321. * Detach the current controls from the specified dom element.
  94322. * @param element Defines the element to stop listening the inputs from
  94323. */
  94324. detachControl(element: Nullable<HTMLElement>): void;
  94325. /**
  94326. * Gets the class name of the current intput.
  94327. * @returns the class name
  94328. */
  94329. getClassName(): string;
  94330. /**
  94331. * Get the friendly name associated with the input class.
  94332. * @returns the input friendly name
  94333. */
  94334. getSimpleName(): string;
  94335. }
  94336. }
  94337. declare module BABYLON {
  94338. /**
  94339. * Listen to mouse events to control the camera.
  94340. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  94341. */
  94342. export class FlyCameraMouseInput implements ICameraInput<FlyCamera> {
  94343. /**
  94344. * Defines the camera the input is attached to.
  94345. */
  94346. camera: FlyCamera;
  94347. /**
  94348. * Defines if touch is enabled. (Default is true.)
  94349. */
  94350. touchEnabled: boolean;
  94351. /**
  94352. * Defines the buttons associated with the input to handle camera rotation.
  94353. */
  94354. buttons: number[];
  94355. /**
  94356. * Assign buttons for Yaw control.
  94357. */
  94358. buttonsYaw: number[];
  94359. /**
  94360. * Assign buttons for Pitch control.
  94361. */
  94362. buttonsPitch: number[];
  94363. /**
  94364. * Assign buttons for Roll control.
  94365. */
  94366. buttonsRoll: number[];
  94367. /**
  94368. * Detect if any button is being pressed while mouse is moved.
  94369. * -1 = Mouse locked.
  94370. * 0 = Left button.
  94371. * 1 = Middle Button.
  94372. * 2 = Right Button.
  94373. */
  94374. activeButton: number;
  94375. /**
  94376. * Defines the pointer's angular sensibility, to control the camera rotation speed.
  94377. * Higher values reduce its sensitivity.
  94378. */
  94379. angularSensibility: number;
  94380. private _mousemoveCallback;
  94381. private _observer;
  94382. private _rollObserver;
  94383. private previousPosition;
  94384. private noPreventDefault;
  94385. private element;
  94386. /**
  94387. * Listen to mouse events to control the camera.
  94388. * @param touchEnabled Define if touch is enabled. (Default is true.)
  94389. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  94390. */
  94391. constructor(touchEnabled?: boolean);
  94392. /**
  94393. * Attach the mouse control to the HTML DOM element.
  94394. * @param element Defines the element that listens to the input events.
  94395. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault().
  94396. */
  94397. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  94398. /**
  94399. * Detach the current controls from the specified dom element.
  94400. * @param element Defines the element to stop listening the inputs from
  94401. */
  94402. detachControl(element: Nullable<HTMLElement>): void;
  94403. /**
  94404. * Gets the class name of the current input.
  94405. * @returns the class name.
  94406. */
  94407. getClassName(): string;
  94408. /**
  94409. * Get the friendly name associated with the input class.
  94410. * @returns the input's friendly name.
  94411. */
  94412. getSimpleName(): string;
  94413. private _pointerInput;
  94414. private _onMouseMove;
  94415. /**
  94416. * Rotate camera by mouse offset.
  94417. */
  94418. private rotateCamera;
  94419. }
  94420. }
  94421. declare module BABYLON {
  94422. /**
  94423. * Default Inputs manager for the FlyCamera.
  94424. * It groups all the default supported inputs for ease of use.
  94425. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  94426. */
  94427. export class FlyCameraInputsManager extends CameraInputsManager<FlyCamera> {
  94428. /**
  94429. * Instantiates a new FlyCameraInputsManager.
  94430. * @param camera Defines the camera the inputs belong to.
  94431. */
  94432. constructor(camera: FlyCamera);
  94433. /**
  94434. * Add keyboard input support to the input manager.
  94435. * @returns the new FlyCameraKeyboardMoveInput().
  94436. */
  94437. addKeyboard(): FlyCameraInputsManager;
  94438. /**
  94439. * Add mouse input support to the input manager.
  94440. * @param touchEnabled Enable touch screen support.
  94441. * @returns the new FlyCameraMouseInput().
  94442. */
  94443. addMouse(touchEnabled?: boolean): FlyCameraInputsManager;
  94444. }
  94445. }
  94446. declare module BABYLON {
  94447. /**
  94448. * This is a flying camera, designed for 3D movement and rotation in all directions,
  94449. * such as in a 3D Space Shooter or a Flight Simulator.
  94450. */
  94451. export class FlyCamera extends TargetCamera {
  94452. /**
  94453. * Define the collision ellipsoid of the camera.
  94454. * This is helpful for simulating a camera body, like a player's body.
  94455. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  94456. */
  94457. ellipsoid: Vector3;
  94458. /**
  94459. * Define an offset for the position of the ellipsoid around the camera.
  94460. * This can be helpful if the camera is attached away from the player's body center,
  94461. * such as at its head.
  94462. */
  94463. ellipsoidOffset: Vector3;
  94464. /**
  94465. * Enable or disable collisions of the camera with the rest of the scene objects.
  94466. */
  94467. checkCollisions: boolean;
  94468. /**
  94469. * Enable or disable gravity on the camera.
  94470. */
  94471. applyGravity: boolean;
  94472. /**
  94473. * Define the current direction the camera is moving to.
  94474. */
  94475. cameraDirection: Vector3;
  94476. /**
  94477. * Define the current local rotation of the camera as a quaternion to prevent Gimbal lock.
  94478. * This overrides and empties cameraRotation.
  94479. */
  94480. rotationQuaternion: Quaternion;
  94481. /**
  94482. * Track Roll to maintain the wanted Rolling when looking around.
  94483. */
  94484. _trackRoll: number;
  94485. /**
  94486. * Slowly correct the Roll to its original value after a Pitch+Yaw rotation.
  94487. */
  94488. rollCorrect: number;
  94489. /**
  94490. * Mimic a banked turn, Rolling the camera when Yawing.
  94491. * It's recommended to use rollCorrect = 10 for faster banking correction.
  94492. */
  94493. bankedTurn: boolean;
  94494. /**
  94495. * Limit in radians for how much Roll banking will add. (Default: 90°)
  94496. */
  94497. bankedTurnLimit: number;
  94498. /**
  94499. * Value of 0 disables the banked Roll.
  94500. * Value of 1 is equal to the Yaw angle in radians.
  94501. */
  94502. bankedTurnMultiplier: number;
  94503. /**
  94504. * The inputs manager loads all the input sources, such as keyboard and mouse.
  94505. */
  94506. inputs: FlyCameraInputsManager;
  94507. /**
  94508. * Gets the input sensibility for mouse input.
  94509. * Higher values reduce sensitivity.
  94510. */
  94511. /**
  94512. * Sets the input sensibility for a mouse input.
  94513. * Higher values reduce sensitivity.
  94514. */
  94515. angularSensibility: number;
  94516. /**
  94517. * Get the keys for camera movement forward.
  94518. */
  94519. /**
  94520. * Set the keys for camera movement forward.
  94521. */
  94522. keysForward: number[];
  94523. /**
  94524. * Get the keys for camera movement backward.
  94525. */
  94526. keysBackward: number[];
  94527. /**
  94528. * Get the keys for camera movement up.
  94529. */
  94530. /**
  94531. * Set the keys for camera movement up.
  94532. */
  94533. keysUp: number[];
  94534. /**
  94535. * Get the keys for camera movement down.
  94536. */
  94537. /**
  94538. * Set the keys for camera movement down.
  94539. */
  94540. keysDown: number[];
  94541. /**
  94542. * Get the keys for camera movement left.
  94543. */
  94544. /**
  94545. * Set the keys for camera movement left.
  94546. */
  94547. keysLeft: number[];
  94548. /**
  94549. * Set the keys for camera movement right.
  94550. */
  94551. /**
  94552. * Set the keys for camera movement right.
  94553. */
  94554. keysRight: number[];
  94555. /**
  94556. * Event raised when the camera collides with a mesh in the scene.
  94557. */
  94558. onCollide: (collidedMesh: AbstractMesh) => void;
  94559. private _collider;
  94560. private _needMoveForGravity;
  94561. private _oldPosition;
  94562. private _diffPosition;
  94563. private _newPosition;
  94564. /** @hidden */
  94565. _localDirection: Vector3;
  94566. /** @hidden */
  94567. _transformedDirection: Vector3;
  94568. /**
  94569. * Instantiates a FlyCamera.
  94570. * This is a flying camera, designed for 3D movement and rotation in all directions,
  94571. * such as in a 3D Space Shooter or a Flight Simulator.
  94572. * @param name Define the name of the camera in the scene.
  94573. * @param position Define the starting position of the camera in the scene.
  94574. * @param scene Define the scene the camera belongs to.
  94575. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active, if no other camera has been defined as active.
  94576. */
  94577. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  94578. /**
  94579. * Attach a control to the HTML DOM element.
  94580. * @param element Defines the element that listens to the input events.
  94581. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault(). https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault
  94582. */
  94583. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  94584. /**
  94585. * Detach a control from the HTML DOM element.
  94586. * The camera will stop reacting to that input.
  94587. * @param element Defines the element that listens to the input events.
  94588. */
  94589. detachControl(element: HTMLElement): void;
  94590. private _collisionMask;
  94591. /**
  94592. * Get the mask that the camera ignores in collision events.
  94593. */
  94594. /**
  94595. * Set the mask that the camera ignores in collision events.
  94596. */
  94597. collisionMask: number;
  94598. /** @hidden */
  94599. _collideWithWorld(displacement: Vector3): void;
  94600. /** @hidden */
  94601. private _onCollisionPositionChange;
  94602. /** @hidden */
  94603. _checkInputs(): void;
  94604. /** @hidden */
  94605. _decideIfNeedsToMove(): boolean;
  94606. /** @hidden */
  94607. _updatePosition(): void;
  94608. /**
  94609. * Restore the Roll to its target value at the rate specified.
  94610. * @param rate - Higher means slower restoring.
  94611. * @hidden
  94612. */
  94613. restoreRoll(rate: number): void;
  94614. /**
  94615. * Destroy the camera and release the current resources held by it.
  94616. */
  94617. dispose(): void;
  94618. /**
  94619. * Get the current object class name.
  94620. * @returns the class name.
  94621. */
  94622. getClassName(): string;
  94623. }
  94624. }
  94625. declare module BABYLON {
  94626. /**
  94627. * Listen to keyboard events to control the camera.
  94628. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  94629. */
  94630. export class FlyCameraKeyboardInput implements ICameraInput<FlyCamera> {
  94631. /**
  94632. * Defines the camera the input is attached to.
  94633. */
  94634. camera: FlyCamera;
  94635. /**
  94636. * The list of keyboard keys used to control the forward move of the camera.
  94637. */
  94638. keysForward: number[];
  94639. /**
  94640. * The list of keyboard keys used to control the backward move of the camera.
  94641. */
  94642. keysBackward: number[];
  94643. /**
  94644. * The list of keyboard keys used to control the forward move of the camera.
  94645. */
  94646. keysUp: number[];
  94647. /**
  94648. * The list of keyboard keys used to control the backward move of the camera.
  94649. */
  94650. keysDown: number[];
  94651. /**
  94652. * The list of keyboard keys used to control the right strafe move of the camera.
  94653. */
  94654. keysRight: number[];
  94655. /**
  94656. * The list of keyboard keys used to control the left strafe move of the camera.
  94657. */
  94658. keysLeft: number[];
  94659. private _keys;
  94660. private _onCanvasBlurObserver;
  94661. private _onKeyboardObserver;
  94662. private _engine;
  94663. private _scene;
  94664. /**
  94665. * Attach the input controls to a specific dom element to get the input from.
  94666. * @param element Defines the element the controls should be listened from
  94667. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  94668. */
  94669. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  94670. /**
  94671. * Detach the current controls from the specified dom element.
  94672. * @param element Defines the element to stop listening the inputs from
  94673. */
  94674. detachControl(element: Nullable<HTMLElement>): void;
  94675. /**
  94676. * Gets the class name of the current intput.
  94677. * @returns the class name
  94678. */
  94679. getClassName(): string;
  94680. /** @hidden */
  94681. _onLostFocus(e: FocusEvent): void;
  94682. /**
  94683. * Get the friendly name associated with the input class.
  94684. * @returns the input friendly name
  94685. */
  94686. getSimpleName(): string;
  94687. /**
  94688. * Update the current camera state depending on the inputs that have been used this frame.
  94689. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  94690. */
  94691. checkInputs(): void;
  94692. }
  94693. }
  94694. declare module BABYLON {
  94695. /**
  94696. * Manage the mouse wheel inputs to control a follow camera.
  94697. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  94698. */
  94699. export class FollowCameraMouseWheelInput implements ICameraInput<FollowCamera> {
  94700. /**
  94701. * Defines the camera the input is attached to.
  94702. */
  94703. camera: FollowCamera;
  94704. /**
  94705. * Moue wheel controls zoom. (Mouse wheel modifies camera.radius value.)
  94706. */
  94707. axisControlRadius: boolean;
  94708. /**
  94709. * Moue wheel controls height. (Mouse wheel modifies camera.heightOffset value.)
  94710. */
  94711. axisControlHeight: boolean;
  94712. /**
  94713. * Moue wheel controls angle. (Mouse wheel modifies camera.rotationOffset value.)
  94714. */
  94715. axisControlRotation: boolean;
  94716. /**
  94717. * Gets or Set the mouse wheel precision or how fast is the camera moves in
  94718. * relation to mouseWheel events.
  94719. */
  94720. wheelPrecision: number;
  94721. /**
  94722. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  94723. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  94724. */
  94725. wheelDeltaPercentage: number;
  94726. private _wheel;
  94727. private _observer;
  94728. /**
  94729. * Attach the input controls to a specific dom element to get the input from.
  94730. * @param element Defines the element the controls should be listened from
  94731. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  94732. */
  94733. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  94734. /**
  94735. * Detach the current controls from the specified dom element.
  94736. * @param element Defines the element to stop listening the inputs from
  94737. */
  94738. detachControl(element: Nullable<HTMLElement>): void;
  94739. /**
  94740. * Gets the class name of the current intput.
  94741. * @returns the class name
  94742. */
  94743. getClassName(): string;
  94744. /**
  94745. * Get the friendly name associated with the input class.
  94746. * @returns the input friendly name
  94747. */
  94748. getSimpleName(): string;
  94749. }
  94750. }
  94751. declare module BABYLON {
  94752. /**
  94753. * Manage the pointers inputs to control an follow camera.
  94754. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  94755. */
  94756. export class FollowCameraPointersInput extends BaseCameraPointersInput {
  94757. /**
  94758. * Defines the camera the input is attached to.
  94759. */
  94760. camera: FollowCamera;
  94761. /**
  94762. * Gets the class name of the current input.
  94763. * @returns the class name
  94764. */
  94765. getClassName(): string;
  94766. /**
  94767. * Defines the pointer angular sensibility along the X axis or how fast is
  94768. * the camera rotating.
  94769. * A negative number will reverse the axis direction.
  94770. */
  94771. angularSensibilityX: number;
  94772. /**
  94773. * Defines the pointer angular sensibility along the Y axis or how fast is
  94774. * the camera rotating.
  94775. * A negative number will reverse the axis direction.
  94776. */
  94777. angularSensibilityY: number;
  94778. /**
  94779. * Defines the pointer pinch precision or how fast is the camera zooming.
  94780. * A negative number will reverse the axis direction.
  94781. */
  94782. pinchPrecision: number;
  94783. /**
  94784. * pinchDeltaPercentage will be used instead of pinchPrecision if different
  94785. * from 0.
  94786. * It defines the percentage of current camera.radius to use as delta when
  94787. * pinch zoom is used.
  94788. */
  94789. pinchDeltaPercentage: number;
  94790. /**
  94791. * Pointer X axis controls zoom. (X axis modifies camera.radius value.)
  94792. */
  94793. axisXControlRadius: boolean;
  94794. /**
  94795. * Pointer X axis controls height. (X axis modifies camera.heightOffset value.)
  94796. */
  94797. axisXControlHeight: boolean;
  94798. /**
  94799. * Pointer X axis controls angle. (X axis modifies camera.rotationOffset value.)
  94800. */
  94801. axisXControlRotation: boolean;
  94802. /**
  94803. * Pointer Y axis controls zoom. (Y axis modifies camera.radius value.)
  94804. */
  94805. axisYControlRadius: boolean;
  94806. /**
  94807. * Pointer Y axis controls height. (Y axis modifies camera.heightOffset value.)
  94808. */
  94809. axisYControlHeight: boolean;
  94810. /**
  94811. * Pointer Y axis controls angle. (Y axis modifies camera.rotationOffset value.)
  94812. */
  94813. axisYControlRotation: boolean;
  94814. /**
  94815. * Pinch controls zoom. (Pinch modifies camera.radius value.)
  94816. */
  94817. axisPinchControlRadius: boolean;
  94818. /**
  94819. * Pinch controls height. (Pinch modifies camera.heightOffset value.)
  94820. */
  94821. axisPinchControlHeight: boolean;
  94822. /**
  94823. * Pinch controls angle. (Pinch modifies camera.rotationOffset value.)
  94824. */
  94825. axisPinchControlRotation: boolean;
  94826. /**
  94827. * Log error messages if basic misconfiguration has occurred.
  94828. */
  94829. warningEnable: boolean;
  94830. protected onTouch(pointA: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  94831. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  94832. private _warningCounter;
  94833. private _warning;
  94834. }
  94835. }
  94836. declare module BABYLON {
  94837. /**
  94838. * Default Inputs manager for the FollowCamera.
  94839. * It groups all the default supported inputs for ease of use.
  94840. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  94841. */
  94842. export class FollowCameraInputsManager extends CameraInputsManager<FollowCamera> {
  94843. /**
  94844. * Instantiates a new FollowCameraInputsManager.
  94845. * @param camera Defines the camera the inputs belong to
  94846. */
  94847. constructor(camera: FollowCamera);
  94848. /**
  94849. * Add keyboard input support to the input manager.
  94850. * @returns the current input manager
  94851. */
  94852. addKeyboard(): FollowCameraInputsManager;
  94853. /**
  94854. * Add mouse wheel input support to the input manager.
  94855. * @returns the current input manager
  94856. */
  94857. addMouseWheel(): FollowCameraInputsManager;
  94858. /**
  94859. * Add pointers input support to the input manager.
  94860. * @returns the current input manager
  94861. */
  94862. addPointers(): FollowCameraInputsManager;
  94863. /**
  94864. * Add orientation input support to the input manager.
  94865. * @returns the current input manager
  94866. */
  94867. addVRDeviceOrientation(): FollowCameraInputsManager;
  94868. }
  94869. }
  94870. declare module BABYLON {
  94871. /**
  94872. * A follow camera takes a mesh as a target and follows it as it moves. Both a free camera version followCamera and
  94873. * an arc rotate version arcFollowCamera are available.
  94874. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  94875. */
  94876. export class FollowCamera extends TargetCamera {
  94877. /**
  94878. * Distance the follow camera should follow an object at
  94879. */
  94880. radius: number;
  94881. /**
  94882. * Minimum allowed distance of the camera to the axis of rotation
  94883. * (The camera can not get closer).
  94884. * This can help limiting how the Camera is able to move in the scene.
  94885. */
  94886. lowerRadiusLimit: Nullable<number>;
  94887. /**
  94888. * Maximum allowed distance of the camera to the axis of rotation
  94889. * (The camera can not get further).
  94890. * This can help limiting how the Camera is able to move in the scene.
  94891. */
  94892. upperRadiusLimit: Nullable<number>;
  94893. /**
  94894. * Define a rotation offset between the camera and the object it follows
  94895. */
  94896. rotationOffset: number;
  94897. /**
  94898. * Minimum allowed angle to camera position relative to target object.
  94899. * This can help limiting how the Camera is able to move in the scene.
  94900. */
  94901. lowerRotationOffsetLimit: Nullable<number>;
  94902. /**
  94903. * Maximum allowed angle to camera position relative to target object.
  94904. * This can help limiting how the Camera is able to move in the scene.
  94905. */
  94906. upperRotationOffsetLimit: Nullable<number>;
  94907. /**
  94908. * Define a height offset between the camera and the object it follows.
  94909. * It can help following an object from the top (like a car chaing a plane)
  94910. */
  94911. heightOffset: number;
  94912. /**
  94913. * Minimum allowed height of camera position relative to target object.
  94914. * This can help limiting how the Camera is able to move in the scene.
  94915. */
  94916. lowerHeightOffsetLimit: Nullable<number>;
  94917. /**
  94918. * Maximum allowed height of camera position relative to target object.
  94919. * This can help limiting how the Camera is able to move in the scene.
  94920. */
  94921. upperHeightOffsetLimit: Nullable<number>;
  94922. /**
  94923. * Define how fast the camera can accelerate to follow it s target.
  94924. */
  94925. cameraAcceleration: number;
  94926. /**
  94927. * Define the speed limit of the camera following an object.
  94928. */
  94929. maxCameraSpeed: number;
  94930. /**
  94931. * Define the target of the camera.
  94932. */
  94933. lockedTarget: Nullable<AbstractMesh>;
  94934. /**
  94935. * Defines the input associated with the camera.
  94936. */
  94937. inputs: FollowCameraInputsManager;
  94938. /**
  94939. * Instantiates the follow camera.
  94940. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  94941. * @param name Define the name of the camera in the scene
  94942. * @param position Define the position of the camera
  94943. * @param scene Define the scene the camera belong to
  94944. * @param lockedTarget Define the target of the camera
  94945. */
  94946. constructor(name: string, position: Vector3, scene: Scene, lockedTarget?: Nullable<AbstractMesh>);
  94947. private _follow;
  94948. /**
  94949. * Attached controls to the current camera.
  94950. * @param element Defines the element the controls should be listened from
  94951. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  94952. */
  94953. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  94954. /**
  94955. * Detach the current controls from the camera.
  94956. * The camera will stop reacting to inputs.
  94957. * @param element Defines the element to stop listening the inputs from
  94958. */
  94959. detachControl(element: HTMLElement): void;
  94960. /** @hidden */
  94961. _checkInputs(): void;
  94962. private _checkLimits;
  94963. /**
  94964. * Gets the camera class name.
  94965. * @returns the class name
  94966. */
  94967. getClassName(): string;
  94968. }
  94969. /**
  94970. * Arc Rotate version of the follow camera.
  94971. * It still follows a Defined mesh but in an Arc Rotate Camera fashion.
  94972. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  94973. */
  94974. export class ArcFollowCamera extends TargetCamera {
  94975. /** The longitudinal angle of the camera */
  94976. alpha: number;
  94977. /** The latitudinal angle of the camera */
  94978. beta: number;
  94979. /** The radius of the camera from its target */
  94980. radius: number;
  94981. /** Define the camera target (the messh it should follow) */
  94982. target: Nullable<AbstractMesh>;
  94983. private _cartesianCoordinates;
  94984. /**
  94985. * Instantiates a new ArcFollowCamera
  94986. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  94987. * @param name Define the name of the camera
  94988. * @param alpha Define the rotation angle of the camera around the logitudinal axis
  94989. * @param beta Define the rotation angle of the camera around the elevation axis
  94990. * @param radius Define the radius of the camera from its target point
  94991. * @param target Define the target of the camera
  94992. * @param scene Define the scene the camera belongs to
  94993. */
  94994. constructor(name: string,
  94995. /** The longitudinal angle of the camera */
  94996. alpha: number,
  94997. /** The latitudinal angle of the camera */
  94998. beta: number,
  94999. /** The radius of the camera from its target */
  95000. radius: number,
  95001. /** Define the camera target (the messh it should follow) */
  95002. target: Nullable<AbstractMesh>, scene: Scene);
  95003. private _follow;
  95004. /** @hidden */
  95005. _checkInputs(): void;
  95006. /**
  95007. * Returns the class name of the object.
  95008. * It is mostly used internally for serialization purposes.
  95009. */
  95010. getClassName(): string;
  95011. }
  95012. }
  95013. declare module BABYLON {
  95014. /**
  95015. * Manage the keyboard inputs to control the movement of a follow camera.
  95016. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  95017. */
  95018. export class FollowCameraKeyboardMoveInput implements ICameraInput<FollowCamera> {
  95019. /**
  95020. * Defines the camera the input is attached to.
  95021. */
  95022. camera: FollowCamera;
  95023. /**
  95024. * Defines the list of key codes associated with the up action (increase heightOffset)
  95025. */
  95026. keysHeightOffsetIncr: number[];
  95027. /**
  95028. * Defines the list of key codes associated with the down action (decrease heightOffset)
  95029. */
  95030. keysHeightOffsetDecr: number[];
  95031. /**
  95032. * Defines whether the Alt modifier key is required to move up/down (alter heightOffset)
  95033. */
  95034. keysHeightOffsetModifierAlt: boolean;
  95035. /**
  95036. * Defines whether the Ctrl modifier key is required to move up/down (alter heightOffset)
  95037. */
  95038. keysHeightOffsetModifierCtrl: boolean;
  95039. /**
  95040. * Defines whether the Shift modifier key is required to move up/down (alter heightOffset)
  95041. */
  95042. keysHeightOffsetModifierShift: boolean;
  95043. /**
  95044. * Defines the list of key codes associated with the left action (increase rotationOffset)
  95045. */
  95046. keysRotationOffsetIncr: number[];
  95047. /**
  95048. * Defines the list of key codes associated with the right action (decrease rotationOffset)
  95049. */
  95050. keysRotationOffsetDecr: number[];
  95051. /**
  95052. * Defines whether the Alt modifier key is required to move left/right (alter rotationOffset)
  95053. */
  95054. keysRotationOffsetModifierAlt: boolean;
  95055. /**
  95056. * Defines whether the Ctrl modifier key is required to move left/right (alter rotationOffset)
  95057. */
  95058. keysRotationOffsetModifierCtrl: boolean;
  95059. /**
  95060. * Defines whether the Shift modifier key is required to move left/right (alter rotationOffset)
  95061. */
  95062. keysRotationOffsetModifierShift: boolean;
  95063. /**
  95064. * Defines the list of key codes associated with the zoom-in action (decrease radius)
  95065. */
  95066. keysRadiusIncr: number[];
  95067. /**
  95068. * Defines the list of key codes associated with the zoom-out action (increase radius)
  95069. */
  95070. keysRadiusDecr: number[];
  95071. /**
  95072. * Defines whether the Alt modifier key is required to zoom in/out (alter radius value)
  95073. */
  95074. keysRadiusModifierAlt: boolean;
  95075. /**
  95076. * Defines whether the Ctrl modifier key is required to zoom in/out (alter radius value)
  95077. */
  95078. keysRadiusModifierCtrl: boolean;
  95079. /**
  95080. * Defines whether the Shift modifier key is required to zoom in/out (alter radius value)
  95081. */
  95082. keysRadiusModifierShift: boolean;
  95083. /**
  95084. * Defines the rate of change of heightOffset.
  95085. */
  95086. heightSensibility: number;
  95087. /**
  95088. * Defines the rate of change of rotationOffset.
  95089. */
  95090. rotationSensibility: number;
  95091. /**
  95092. * Defines the rate of change of radius.
  95093. */
  95094. radiusSensibility: number;
  95095. private _keys;
  95096. private _ctrlPressed;
  95097. private _altPressed;
  95098. private _shiftPressed;
  95099. private _onCanvasBlurObserver;
  95100. private _onKeyboardObserver;
  95101. private _engine;
  95102. private _scene;
  95103. /**
  95104. * Attach the input controls to a specific dom element to get the input from.
  95105. * @param element Defines the element the controls should be listened from
  95106. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  95107. */
  95108. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  95109. /**
  95110. * Detach the current controls from the specified dom element.
  95111. * @param element Defines the element to stop listening the inputs from
  95112. */
  95113. detachControl(element: Nullable<HTMLElement>): void;
  95114. /**
  95115. * Update the current camera state depending on the inputs that have been used this frame.
  95116. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  95117. */
  95118. checkInputs(): void;
  95119. /**
  95120. * Gets the class name of the current input.
  95121. * @returns the class name
  95122. */
  95123. getClassName(): string;
  95124. /**
  95125. * Get the friendly name associated with the input class.
  95126. * @returns the input friendly name
  95127. */
  95128. getSimpleName(): string;
  95129. /**
  95130. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  95131. * allow modification of the heightOffset value.
  95132. */
  95133. private _modifierHeightOffset;
  95134. /**
  95135. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  95136. * allow modification of the rotationOffset value.
  95137. */
  95138. private _modifierRotationOffset;
  95139. /**
  95140. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  95141. * allow modification of the radius value.
  95142. */
  95143. private _modifierRadius;
  95144. }
  95145. }
  95146. declare module BABYLON {
  95147. interface FreeCameraInputsManager {
  95148. /**
  95149. * Add orientation input support to the input manager.
  95150. * @returns the current input manager
  95151. */
  95152. addDeviceOrientation(): FreeCameraInputsManager;
  95153. }
  95154. /**
  95155. * Takes information about the orientation of the device as reported by the deviceorientation event to orient the camera.
  95156. * Screen rotation is taken into account.
  95157. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  95158. */
  95159. export class FreeCameraDeviceOrientationInput implements ICameraInput<FreeCamera> {
  95160. private _camera;
  95161. private _screenOrientationAngle;
  95162. private _constantTranform;
  95163. private _screenQuaternion;
  95164. private _alpha;
  95165. private _beta;
  95166. private _gamma;
  95167. /**
  95168. * Instantiates a new input
  95169. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  95170. */
  95171. constructor();
  95172. /**
  95173. * Define the camera controlled by the input.
  95174. */
  95175. camera: FreeCamera;
  95176. /**
  95177. * Attach the input controls to a specific dom element to get the input from.
  95178. * @param element Defines the element the controls should be listened from
  95179. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  95180. */
  95181. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  95182. private _orientationChanged;
  95183. private _deviceOrientation;
  95184. /**
  95185. * Detach the current controls from the specified dom element.
  95186. * @param element Defines the element to stop listening the inputs from
  95187. */
  95188. detachControl(element: Nullable<HTMLElement>): void;
  95189. /**
  95190. * Update the current camera state depending on the inputs that have been used this frame.
  95191. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  95192. */
  95193. checkInputs(): void;
  95194. /**
  95195. * Gets the class name of the current intput.
  95196. * @returns the class name
  95197. */
  95198. getClassName(): string;
  95199. /**
  95200. * Get the friendly name associated with the input class.
  95201. * @returns the input friendly name
  95202. */
  95203. getSimpleName(): string;
  95204. }
  95205. }
  95206. declare module BABYLON {
  95207. /**
  95208. * Manage the gamepad inputs to control a free camera.
  95209. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  95210. */
  95211. export class FreeCameraGamepadInput implements ICameraInput<FreeCamera> {
  95212. /**
  95213. * Define the camera the input is attached to.
  95214. */
  95215. camera: FreeCamera;
  95216. /**
  95217. * Define the Gamepad controlling the input
  95218. */
  95219. gamepad: Nullable<Gamepad>;
  95220. /**
  95221. * Defines the gamepad rotation sensiblity.
  95222. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  95223. */
  95224. gamepadAngularSensibility: number;
  95225. /**
  95226. * Defines the gamepad move sensiblity.
  95227. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  95228. */
  95229. gamepadMoveSensibility: number;
  95230. private _onGamepadConnectedObserver;
  95231. private _onGamepadDisconnectedObserver;
  95232. private _cameraTransform;
  95233. private _deltaTransform;
  95234. private _vector3;
  95235. private _vector2;
  95236. /**
  95237. * Attach the input controls to a specific dom element to get the input from.
  95238. * @param element Defines the element the controls should be listened from
  95239. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  95240. */
  95241. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  95242. /**
  95243. * Detach the current controls from the specified dom element.
  95244. * @param element Defines the element to stop listening the inputs from
  95245. */
  95246. detachControl(element: Nullable<HTMLElement>): void;
  95247. /**
  95248. * Update the current camera state depending on the inputs that have been used this frame.
  95249. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  95250. */
  95251. checkInputs(): void;
  95252. /**
  95253. * Gets the class name of the current intput.
  95254. * @returns the class name
  95255. */
  95256. getClassName(): string;
  95257. /**
  95258. * Get the friendly name associated with the input class.
  95259. * @returns the input friendly name
  95260. */
  95261. getSimpleName(): string;
  95262. }
  95263. }
  95264. declare module BABYLON {
  95265. /**
  95266. * Defines the potential axis of a Joystick
  95267. */
  95268. export enum JoystickAxis {
  95269. /** X axis */
  95270. X = 0,
  95271. /** Y axis */
  95272. Y = 1,
  95273. /** Z axis */
  95274. Z = 2
  95275. }
  95276. /**
  95277. * Class used to define virtual joystick (used in touch mode)
  95278. */
  95279. export class VirtualJoystick {
  95280. /**
  95281. * Gets or sets a boolean indicating that left and right values must be inverted
  95282. */
  95283. reverseLeftRight: boolean;
  95284. /**
  95285. * Gets or sets a boolean indicating that up and down values must be inverted
  95286. */
  95287. reverseUpDown: boolean;
  95288. /**
  95289. * Gets the offset value for the position (ie. the change of the position value)
  95290. */
  95291. deltaPosition: Vector3;
  95292. /**
  95293. * Gets a boolean indicating if the virtual joystick was pressed
  95294. */
  95295. pressed: boolean;
  95296. /**
  95297. * Canvas the virtual joystick will render onto, default z-index of this is 5
  95298. */
  95299. static Canvas: Nullable<HTMLCanvasElement>;
  95300. private static _globalJoystickIndex;
  95301. private static vjCanvasContext;
  95302. private static vjCanvasWidth;
  95303. private static vjCanvasHeight;
  95304. private static halfWidth;
  95305. private _action;
  95306. private _axisTargetedByLeftAndRight;
  95307. private _axisTargetedByUpAndDown;
  95308. private _joystickSensibility;
  95309. private _inversedSensibility;
  95310. private _joystickPointerID;
  95311. private _joystickColor;
  95312. private _joystickPointerPos;
  95313. private _joystickPreviousPointerPos;
  95314. private _joystickPointerStartPos;
  95315. private _deltaJoystickVector;
  95316. private _leftJoystick;
  95317. private _touches;
  95318. private _onPointerDownHandlerRef;
  95319. private _onPointerMoveHandlerRef;
  95320. private _onPointerUpHandlerRef;
  95321. private _onResize;
  95322. /**
  95323. * Creates a new virtual joystick
  95324. * @param leftJoystick defines that the joystick is for left hand (false by default)
  95325. */
  95326. constructor(leftJoystick?: boolean);
  95327. /**
  95328. * Defines joystick sensibility (ie. the ratio beteen a physical move and virtual joystick position change)
  95329. * @param newJoystickSensibility defines the new sensibility
  95330. */
  95331. setJoystickSensibility(newJoystickSensibility: number): void;
  95332. private _onPointerDown;
  95333. private _onPointerMove;
  95334. private _onPointerUp;
  95335. /**
  95336. * Change the color of the virtual joystick
  95337. * @param newColor a string that must be a CSS color value (like "red") or the hexa value (like "#FF0000")
  95338. */
  95339. setJoystickColor(newColor: string): void;
  95340. /**
  95341. * Defines a callback to call when the joystick is touched
  95342. * @param action defines the callback
  95343. */
  95344. setActionOnTouch(action: () => any): void;
  95345. /**
  95346. * Defines which axis you'd like to control for left & right
  95347. * @param axis defines the axis to use
  95348. */
  95349. setAxisForLeftRight(axis: JoystickAxis): void;
  95350. /**
  95351. * Defines which axis you'd like to control for up & down
  95352. * @param axis defines the axis to use
  95353. */
  95354. setAxisForUpDown(axis: JoystickAxis): void;
  95355. private _drawVirtualJoystick;
  95356. /**
  95357. * Release internal HTML canvas
  95358. */
  95359. releaseCanvas(): void;
  95360. }
  95361. }
  95362. declare module BABYLON {
  95363. interface FreeCameraInputsManager {
  95364. /**
  95365. * Add virtual joystick input support to the input manager.
  95366. * @returns the current input manager
  95367. */
  95368. addVirtualJoystick(): FreeCameraInputsManager;
  95369. }
  95370. /**
  95371. * Manage the Virtual Joystick inputs to control the movement of a free camera.
  95372. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  95373. */
  95374. export class FreeCameraVirtualJoystickInput implements ICameraInput<FreeCamera> {
  95375. /**
  95376. * Defines the camera the input is attached to.
  95377. */
  95378. camera: FreeCamera;
  95379. private _leftjoystick;
  95380. private _rightjoystick;
  95381. /**
  95382. * Gets the left stick of the virtual joystick.
  95383. * @returns The virtual Joystick
  95384. */
  95385. getLeftJoystick(): VirtualJoystick;
  95386. /**
  95387. * Gets the right stick of the virtual joystick.
  95388. * @returns The virtual Joystick
  95389. */
  95390. getRightJoystick(): VirtualJoystick;
  95391. /**
  95392. * Update the current camera state depending on the inputs that have been used this frame.
  95393. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  95394. */
  95395. checkInputs(): void;
  95396. /**
  95397. * Attach the input controls to a specific dom element to get the input from.
  95398. * @param element Defines the element the controls should be listened from
  95399. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  95400. */
  95401. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  95402. /**
  95403. * Detach the current controls from the specified dom element.
  95404. * @param element Defines the element to stop listening the inputs from
  95405. */
  95406. detachControl(element: Nullable<HTMLElement>): void;
  95407. /**
  95408. * Gets the class name of the current intput.
  95409. * @returns the class name
  95410. */
  95411. getClassName(): string;
  95412. /**
  95413. * Get the friendly name associated with the input class.
  95414. * @returns the input friendly name
  95415. */
  95416. getSimpleName(): string;
  95417. }
  95418. }
  95419. declare module BABYLON {
  95420. /**
  95421. * This represents a FPS type of camera controlled by touch.
  95422. * This is like a universal camera minus the Gamepad controls.
  95423. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  95424. */
  95425. export class TouchCamera extends FreeCamera {
  95426. /**
  95427. * Defines the touch sensibility for rotation.
  95428. * The higher the faster.
  95429. */
  95430. touchAngularSensibility: number;
  95431. /**
  95432. * Defines the touch sensibility for move.
  95433. * The higher the faster.
  95434. */
  95435. touchMoveSensibility: number;
  95436. /**
  95437. * Instantiates a new touch camera.
  95438. * This represents a FPS type of camera controlled by touch.
  95439. * This is like a universal camera minus the Gamepad controls.
  95440. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  95441. * @param name Define the name of the camera in the scene
  95442. * @param position Define the start position of the camera in the scene
  95443. * @param scene Define the scene the camera belongs to
  95444. */
  95445. constructor(name: string, position: Vector3, scene: Scene);
  95446. /**
  95447. * Gets the current object class name.
  95448. * @return the class name
  95449. */
  95450. getClassName(): string;
  95451. /** @hidden */
  95452. _setupInputs(): void;
  95453. }
  95454. }
  95455. declare module BABYLON {
  95456. /**
  95457. * This is a camera specifically designed to react to device orientation events such as a modern mobile device
  95458. * being tilted forward or back and left or right.
  95459. */
  95460. export class DeviceOrientationCamera extends FreeCamera {
  95461. private _initialQuaternion;
  95462. private _quaternionCache;
  95463. /**
  95464. * Creates a new device orientation camera
  95465. * @param name The name of the camera
  95466. * @param position The start position camera
  95467. * @param scene The scene the camera belongs to
  95468. */
  95469. constructor(name: string, position: Vector3, scene: Scene);
  95470. /**
  95471. * Gets the current instance class name ("DeviceOrientationCamera").
  95472. * This helps avoiding instanceof at run time.
  95473. * @returns the class name
  95474. */
  95475. getClassName(): string;
  95476. /**
  95477. * @hidden
  95478. * Checks and applies the current values of the inputs to the camera. (Internal use only)
  95479. */
  95480. _checkInputs(): void;
  95481. /**
  95482. * Reset the camera to its default orientation on the specified axis only.
  95483. * @param axis The axis to reset
  95484. */
  95485. resetToCurrentRotation(axis?: Axis): void;
  95486. }
  95487. }
  95488. declare module BABYLON {
  95489. /**
  95490. * 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,
  95491. * which still works and will still be found in many Playgrounds.
  95492. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  95493. */
  95494. export class UniversalCamera extends TouchCamera {
  95495. /**
  95496. * Defines the gamepad rotation sensiblity.
  95497. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  95498. */
  95499. gamepadAngularSensibility: number;
  95500. /**
  95501. * Defines the gamepad move sensiblity.
  95502. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  95503. */
  95504. gamepadMoveSensibility: number;
  95505. /**
  95506. * 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,
  95507. * which still works and will still be found in many Playgrounds.
  95508. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  95509. * @param name Define the name of the camera in the scene
  95510. * @param position Define the start position of the camera in the scene
  95511. * @param scene Define the scene the camera belongs to
  95512. */
  95513. constructor(name: string, position: Vector3, scene: Scene);
  95514. /**
  95515. * Gets the current object class name.
  95516. * @return the class name
  95517. */
  95518. getClassName(): string;
  95519. }
  95520. }
  95521. declare module BABYLON {
  95522. /**
  95523. * This represents a FPS type of camera. This is only here for back compat purpose.
  95524. * Please use the UniversalCamera instead as both are identical.
  95525. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  95526. */
  95527. export class GamepadCamera extends UniversalCamera {
  95528. /**
  95529. * Instantiates a new Gamepad Camera
  95530. * This represents a FPS type of camera. This is only here for back compat purpose.
  95531. * Please use the UniversalCamera instead as both are identical.
  95532. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  95533. * @param name Define the name of the camera in the scene
  95534. * @param position Define the start position of the camera in the scene
  95535. * @param scene Define the scene the camera belongs to
  95536. */
  95537. constructor(name: string, position: Vector3, scene: Scene);
  95538. /**
  95539. * Gets the current object class name.
  95540. * @return the class name
  95541. */
  95542. getClassName(): string;
  95543. }
  95544. }
  95545. declare module BABYLON {
  95546. /** @hidden */
  95547. export var passPixelShader: {
  95548. name: string;
  95549. shader: string;
  95550. };
  95551. }
  95552. declare module BABYLON {
  95553. /** @hidden */
  95554. export var passCubePixelShader: {
  95555. name: string;
  95556. shader: string;
  95557. };
  95558. }
  95559. declare module BABYLON {
  95560. /**
  95561. * PassPostProcess which produces an output the same as it's input
  95562. */
  95563. export class PassPostProcess extends PostProcess {
  95564. /**
  95565. * Creates the PassPostProcess
  95566. * @param name The name of the effect.
  95567. * @param options The required width/height ratio to downsize to before computing the render pass.
  95568. * @param camera The camera to apply the render pass to.
  95569. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  95570. * @param engine The engine which the post process will be applied. (default: current engine)
  95571. * @param reusable If the post process can be reused on the same frame. (default: false)
  95572. * @param textureType The type of texture to be used when performing the post processing.
  95573. * @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)
  95574. */
  95575. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  95576. }
  95577. /**
  95578. * PassCubePostProcess which produces an output the same as it's input (which must be a cube texture)
  95579. */
  95580. export class PassCubePostProcess extends PostProcess {
  95581. private _face;
  95582. /**
  95583. * Gets or sets the cube face to display.
  95584. * * 0 is +X
  95585. * * 1 is -X
  95586. * * 2 is +Y
  95587. * * 3 is -Y
  95588. * * 4 is +Z
  95589. * * 5 is -Z
  95590. */
  95591. face: number;
  95592. /**
  95593. * Creates the PassCubePostProcess
  95594. * @param name The name of the effect.
  95595. * @param options The required width/height ratio to downsize to before computing the render pass.
  95596. * @param camera The camera to apply the render pass to.
  95597. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  95598. * @param engine The engine which the post process will be applied. (default: current engine)
  95599. * @param reusable If the post process can be reused on the same frame. (default: false)
  95600. * @param textureType The type of texture to be used when performing the post processing.
  95601. * @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)
  95602. */
  95603. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  95604. }
  95605. }
  95606. declare module BABYLON {
  95607. /** @hidden */
  95608. export var anaglyphPixelShader: {
  95609. name: string;
  95610. shader: string;
  95611. };
  95612. }
  95613. declare module BABYLON {
  95614. /**
  95615. * Postprocess used to generate anaglyphic rendering
  95616. */
  95617. export class AnaglyphPostProcess extends PostProcess {
  95618. private _passedProcess;
  95619. /**
  95620. * Creates a new AnaglyphPostProcess
  95621. * @param name defines postprocess name
  95622. * @param options defines creation options or target ratio scale
  95623. * @param rigCameras defines cameras using this postprocess
  95624. * @param samplingMode defines required sampling mode (BABYLON.Texture.NEAREST_SAMPLINGMODE by default)
  95625. * @param engine defines hosting engine
  95626. * @param reusable defines if the postprocess will be reused multiple times per frame
  95627. */
  95628. constructor(name: string, options: number | PostProcessOptions, rigCameras: Camera[], samplingMode?: number, engine?: Engine, reusable?: boolean);
  95629. }
  95630. }
  95631. declare module BABYLON {
  95632. /**
  95633. * Camera used to simulate anaglyphic rendering (based on ArcRotateCamera)
  95634. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  95635. */
  95636. export class AnaglyphArcRotateCamera extends ArcRotateCamera {
  95637. /**
  95638. * Creates a new AnaglyphArcRotateCamera
  95639. * @param name defines camera name
  95640. * @param alpha defines alpha angle (in radians)
  95641. * @param beta defines beta angle (in radians)
  95642. * @param radius defines radius
  95643. * @param target defines camera target
  95644. * @param interaxialDistance defines distance between each color axis
  95645. * @param scene defines the hosting scene
  95646. */
  95647. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, scene: Scene);
  95648. /**
  95649. * Gets camera class name
  95650. * @returns AnaglyphArcRotateCamera
  95651. */
  95652. getClassName(): string;
  95653. }
  95654. }
  95655. declare module BABYLON {
  95656. /**
  95657. * Camera used to simulate anaglyphic rendering (based on FreeCamera)
  95658. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  95659. */
  95660. export class AnaglyphFreeCamera extends FreeCamera {
  95661. /**
  95662. * Creates a new AnaglyphFreeCamera
  95663. * @param name defines camera name
  95664. * @param position defines initial position
  95665. * @param interaxialDistance defines distance between each color axis
  95666. * @param scene defines the hosting scene
  95667. */
  95668. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  95669. /**
  95670. * Gets camera class name
  95671. * @returns AnaglyphFreeCamera
  95672. */
  95673. getClassName(): string;
  95674. }
  95675. }
  95676. declare module BABYLON {
  95677. /**
  95678. * Camera used to simulate anaglyphic rendering (based on GamepadCamera)
  95679. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  95680. */
  95681. export class AnaglyphGamepadCamera extends GamepadCamera {
  95682. /**
  95683. * Creates a new AnaglyphGamepadCamera
  95684. * @param name defines camera name
  95685. * @param position defines initial position
  95686. * @param interaxialDistance defines distance between each color axis
  95687. * @param scene defines the hosting scene
  95688. */
  95689. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  95690. /**
  95691. * Gets camera class name
  95692. * @returns AnaglyphGamepadCamera
  95693. */
  95694. getClassName(): string;
  95695. }
  95696. }
  95697. declare module BABYLON {
  95698. /**
  95699. * Camera used to simulate anaglyphic rendering (based on UniversalCamera)
  95700. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  95701. */
  95702. export class AnaglyphUniversalCamera extends UniversalCamera {
  95703. /**
  95704. * Creates a new AnaglyphUniversalCamera
  95705. * @param name defines camera name
  95706. * @param position defines initial position
  95707. * @param interaxialDistance defines distance between each color axis
  95708. * @param scene defines the hosting scene
  95709. */
  95710. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  95711. /**
  95712. * Gets camera class name
  95713. * @returns AnaglyphUniversalCamera
  95714. */
  95715. getClassName(): string;
  95716. }
  95717. }
  95718. declare module BABYLON {
  95719. /** @hidden */
  95720. export var stereoscopicInterlacePixelShader: {
  95721. name: string;
  95722. shader: string;
  95723. };
  95724. }
  95725. declare module BABYLON {
  95726. /**
  95727. * StereoscopicInterlacePostProcess used to render stereo views from a rigged camera
  95728. */
  95729. export class StereoscopicInterlacePostProcess extends PostProcess {
  95730. private _stepSize;
  95731. private _passedProcess;
  95732. /**
  95733. * Initializes a StereoscopicInterlacePostProcess
  95734. * @param name The name of the effect.
  95735. * @param rigCameras The rig cameras to be appled to the post process
  95736. * @param isStereoscopicHoriz If the rendered results are horizontal or verticle
  95737. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  95738. * @param engine The engine which the post process will be applied. (default: current engine)
  95739. * @param reusable If the post process can be reused on the same frame. (default: false)
  95740. */
  95741. constructor(name: string, rigCameras: Camera[], isStereoscopicHoriz: boolean, samplingMode?: number, engine?: Engine, reusable?: boolean);
  95742. }
  95743. }
  95744. declare module BABYLON {
  95745. /**
  95746. * Camera used to simulate stereoscopic rendering (based on ArcRotateCamera)
  95747. * @see http://doc.babylonjs.com/features/cameras
  95748. */
  95749. export class StereoscopicArcRotateCamera extends ArcRotateCamera {
  95750. /**
  95751. * Creates a new StereoscopicArcRotateCamera
  95752. * @param name defines camera name
  95753. * @param alpha defines alpha angle (in radians)
  95754. * @param beta defines beta angle (in radians)
  95755. * @param radius defines radius
  95756. * @param target defines camera target
  95757. * @param interaxialDistance defines distance between each color axis
  95758. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  95759. * @param scene defines the hosting scene
  95760. */
  95761. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  95762. /**
  95763. * Gets camera class name
  95764. * @returns StereoscopicArcRotateCamera
  95765. */
  95766. getClassName(): string;
  95767. }
  95768. }
  95769. declare module BABYLON {
  95770. /**
  95771. * Camera used to simulate stereoscopic rendering (based on FreeCamera)
  95772. * @see http://doc.babylonjs.com/features/cameras
  95773. */
  95774. export class StereoscopicFreeCamera extends FreeCamera {
  95775. /**
  95776. * Creates a new StereoscopicFreeCamera
  95777. * @param name defines camera name
  95778. * @param position defines initial position
  95779. * @param interaxialDistance defines distance between each color axis
  95780. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  95781. * @param scene defines the hosting scene
  95782. */
  95783. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  95784. /**
  95785. * Gets camera class name
  95786. * @returns StereoscopicFreeCamera
  95787. */
  95788. getClassName(): string;
  95789. }
  95790. }
  95791. declare module BABYLON {
  95792. /**
  95793. * Camera used to simulate stereoscopic rendering (based on GamepadCamera)
  95794. * @see http://doc.babylonjs.com/features/cameras
  95795. */
  95796. export class StereoscopicGamepadCamera extends GamepadCamera {
  95797. /**
  95798. * Creates a new StereoscopicGamepadCamera
  95799. * @param name defines camera name
  95800. * @param position defines initial position
  95801. * @param interaxialDistance defines distance between each color axis
  95802. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  95803. * @param scene defines the hosting scene
  95804. */
  95805. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  95806. /**
  95807. * Gets camera class name
  95808. * @returns StereoscopicGamepadCamera
  95809. */
  95810. getClassName(): string;
  95811. }
  95812. }
  95813. declare module BABYLON {
  95814. /**
  95815. * Camera used to simulate stereoscopic rendering (based on UniversalCamera)
  95816. * @see http://doc.babylonjs.com/features/cameras
  95817. */
  95818. export class StereoscopicUniversalCamera extends UniversalCamera {
  95819. /**
  95820. * Creates a new StereoscopicUniversalCamera
  95821. * @param name defines camera name
  95822. * @param position defines initial position
  95823. * @param interaxialDistance defines distance between each color axis
  95824. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  95825. * @param scene defines the hosting scene
  95826. */
  95827. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  95828. /**
  95829. * Gets camera class name
  95830. * @returns StereoscopicUniversalCamera
  95831. */
  95832. getClassName(): string;
  95833. }
  95834. }
  95835. declare module BABYLON {
  95836. /**
  95837. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  95838. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  95839. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  95840. * @see http://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  95841. */
  95842. export class VirtualJoysticksCamera extends FreeCamera {
  95843. /**
  95844. * Intantiates a VirtualJoysticksCamera. It can be useful in First Person Shooter game for instance.
  95845. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  95846. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  95847. * @see http://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  95848. * @param name Define the name of the camera in the scene
  95849. * @param position Define the start position of the camera in the scene
  95850. * @param scene Define the scene the camera belongs to
  95851. */
  95852. constructor(name: string, position: Vector3, scene: Scene);
  95853. /**
  95854. * Gets the current object class name.
  95855. * @return the class name
  95856. */
  95857. getClassName(): string;
  95858. }
  95859. }
  95860. declare module BABYLON {
  95861. /**
  95862. * This represents all the required metrics to create a VR camera.
  95863. * @see http://doc.babylonjs.com/babylon101/cameras#device-orientation-camera
  95864. */
  95865. export class VRCameraMetrics {
  95866. /**
  95867. * Define the horizontal resolution off the screen.
  95868. */
  95869. hResolution: number;
  95870. /**
  95871. * Define the vertical resolution off the screen.
  95872. */
  95873. vResolution: number;
  95874. /**
  95875. * Define the horizontal screen size.
  95876. */
  95877. hScreenSize: number;
  95878. /**
  95879. * Define the vertical screen size.
  95880. */
  95881. vScreenSize: number;
  95882. /**
  95883. * Define the vertical screen center position.
  95884. */
  95885. vScreenCenter: number;
  95886. /**
  95887. * Define the distance of the eyes to the screen.
  95888. */
  95889. eyeToScreenDistance: number;
  95890. /**
  95891. * Define the distance between both lenses
  95892. */
  95893. lensSeparationDistance: number;
  95894. /**
  95895. * Define the distance between both viewer's eyes.
  95896. */
  95897. interpupillaryDistance: number;
  95898. /**
  95899. * Define the distortion factor of the VR postprocess.
  95900. * Please, touch with care.
  95901. */
  95902. distortionK: number[];
  95903. /**
  95904. * Define the chromatic aberration correction factors for the VR post process.
  95905. */
  95906. chromaAbCorrection: number[];
  95907. /**
  95908. * Define the scale factor of the post process.
  95909. * The smaller the better but the slower.
  95910. */
  95911. postProcessScaleFactor: number;
  95912. /**
  95913. * Define an offset for the lens center.
  95914. */
  95915. lensCenterOffset: number;
  95916. /**
  95917. * Define if the current vr camera should compensate the distortion of the lense or not.
  95918. */
  95919. compensateDistortion: boolean;
  95920. /**
  95921. * Gets the rendering aspect ratio based on the provided resolutions.
  95922. */
  95923. readonly aspectRatio: number;
  95924. /**
  95925. * Gets the aspect ratio based on the FOV, scale factors, and real screen sizes.
  95926. */
  95927. readonly aspectRatioFov: number;
  95928. /**
  95929. * @hidden
  95930. */
  95931. readonly leftHMatrix: Matrix;
  95932. /**
  95933. * @hidden
  95934. */
  95935. readonly rightHMatrix: Matrix;
  95936. /**
  95937. * @hidden
  95938. */
  95939. readonly leftPreViewMatrix: Matrix;
  95940. /**
  95941. * @hidden
  95942. */
  95943. readonly rightPreViewMatrix: Matrix;
  95944. /**
  95945. * Get the default VRMetrics based on the most generic setup.
  95946. * @returns the default vr metrics
  95947. */
  95948. static GetDefault(): VRCameraMetrics;
  95949. }
  95950. }
  95951. declare module BABYLON {
  95952. /** @hidden */
  95953. export var vrDistortionCorrectionPixelShader: {
  95954. name: string;
  95955. shader: string;
  95956. };
  95957. }
  95958. declare module BABYLON {
  95959. /**
  95960. * VRDistortionCorrectionPostProcess used for mobile VR
  95961. */
  95962. export class VRDistortionCorrectionPostProcess extends PostProcess {
  95963. private _isRightEye;
  95964. private _distortionFactors;
  95965. private _postProcessScaleFactor;
  95966. private _lensCenterOffset;
  95967. private _scaleIn;
  95968. private _scaleFactor;
  95969. private _lensCenter;
  95970. /**
  95971. * Initializes the VRDistortionCorrectionPostProcess
  95972. * @param name The name of the effect.
  95973. * @param camera The camera to apply the render pass to.
  95974. * @param isRightEye If this is for the right eye distortion
  95975. * @param vrMetrics All the required metrics for the VR camera
  95976. */
  95977. constructor(name: string, camera: Camera, isRightEye: boolean, vrMetrics: VRCameraMetrics);
  95978. }
  95979. }
  95980. declare module BABYLON {
  95981. /**
  95982. * Camera used to simulate VR rendering (based on ArcRotateCamera)
  95983. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  95984. */
  95985. export class VRDeviceOrientationArcRotateCamera extends ArcRotateCamera {
  95986. /**
  95987. * Creates a new VRDeviceOrientationArcRotateCamera
  95988. * @param name defines camera name
  95989. * @param alpha defines the camera rotation along the logitudinal axis
  95990. * @param beta defines the camera rotation along the latitudinal axis
  95991. * @param radius defines the camera distance from its target
  95992. * @param target defines the camera target
  95993. * @param scene defines the scene the camera belongs to
  95994. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  95995. * @param vrCameraMetrics defines the vr metrics associated to the camera
  95996. */
  95997. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  95998. /**
  95999. * Gets camera class name
  96000. * @returns VRDeviceOrientationArcRotateCamera
  96001. */
  96002. getClassName(): string;
  96003. }
  96004. }
  96005. declare module BABYLON {
  96006. /**
  96007. * Camera used to simulate VR rendering (based on FreeCamera)
  96008. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  96009. */
  96010. export class VRDeviceOrientationFreeCamera extends DeviceOrientationCamera {
  96011. /**
  96012. * Creates a new VRDeviceOrientationFreeCamera
  96013. * @param name defines camera name
  96014. * @param position defines the start position of the camera
  96015. * @param scene defines the scene the camera belongs to
  96016. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  96017. * @param vrCameraMetrics defines the vr metrics associated to the camera
  96018. */
  96019. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  96020. /**
  96021. * Gets camera class name
  96022. * @returns VRDeviceOrientationFreeCamera
  96023. */
  96024. getClassName(): string;
  96025. }
  96026. }
  96027. declare module BABYLON {
  96028. /**
  96029. * Camera used to simulate VR rendering (based on VRDeviceOrientationFreeCamera)
  96030. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  96031. */
  96032. export class VRDeviceOrientationGamepadCamera extends VRDeviceOrientationFreeCamera {
  96033. /**
  96034. * Creates a new VRDeviceOrientationGamepadCamera
  96035. * @param name defines camera name
  96036. * @param position defines the start position of the camera
  96037. * @param scene defines the scene the camera belongs to
  96038. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  96039. * @param vrCameraMetrics defines the vr metrics associated to the camera
  96040. */
  96041. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  96042. /**
  96043. * Gets camera class name
  96044. * @returns VRDeviceOrientationGamepadCamera
  96045. */
  96046. getClassName(): string;
  96047. }
  96048. }
  96049. declare module BABYLON {
  96050. /**
  96051. * Defines supported buttons for XBox360 compatible gamepads
  96052. */
  96053. export enum Xbox360Button {
  96054. /** A */
  96055. A = 0,
  96056. /** B */
  96057. B = 1,
  96058. /** X */
  96059. X = 2,
  96060. /** Y */
  96061. Y = 3,
  96062. /** Start */
  96063. Start = 4,
  96064. /** Back */
  96065. Back = 5,
  96066. /** Left button */
  96067. LB = 6,
  96068. /** Right button */
  96069. RB = 7,
  96070. /** Left stick */
  96071. LeftStick = 8,
  96072. /** Right stick */
  96073. RightStick = 9
  96074. }
  96075. /** Defines values for XBox360 DPad */
  96076. export enum Xbox360Dpad {
  96077. /** Up */
  96078. Up = 0,
  96079. /** Down */
  96080. Down = 1,
  96081. /** Left */
  96082. Left = 2,
  96083. /** Right */
  96084. Right = 3
  96085. }
  96086. /**
  96087. * Defines a XBox360 gamepad
  96088. */
  96089. export class Xbox360Pad extends Gamepad {
  96090. private _leftTrigger;
  96091. private _rightTrigger;
  96092. private _onlefttriggerchanged;
  96093. private _onrighttriggerchanged;
  96094. private _onbuttondown;
  96095. private _onbuttonup;
  96096. private _ondpaddown;
  96097. private _ondpadup;
  96098. /** Observable raised when a button is pressed */
  96099. onButtonDownObservable: Observable<Xbox360Button>;
  96100. /** Observable raised when a button is released */
  96101. onButtonUpObservable: Observable<Xbox360Button>;
  96102. /** Observable raised when a pad is pressed */
  96103. onPadDownObservable: Observable<Xbox360Dpad>;
  96104. /** Observable raised when a pad is released */
  96105. onPadUpObservable: Observable<Xbox360Dpad>;
  96106. private _buttonA;
  96107. private _buttonB;
  96108. private _buttonX;
  96109. private _buttonY;
  96110. private _buttonBack;
  96111. private _buttonStart;
  96112. private _buttonLB;
  96113. private _buttonRB;
  96114. private _buttonLeftStick;
  96115. private _buttonRightStick;
  96116. private _dPadUp;
  96117. private _dPadDown;
  96118. private _dPadLeft;
  96119. private _dPadRight;
  96120. private _isXboxOnePad;
  96121. /**
  96122. * Creates a new XBox360 gamepad object
  96123. * @param id defines the id of this gamepad
  96124. * @param index defines its index
  96125. * @param gamepad defines the internal HTML gamepad object
  96126. * @param xboxOne defines if it is a XBox One gamepad
  96127. */
  96128. constructor(id: string, index: number, gamepad: any, xboxOne?: boolean);
  96129. /**
  96130. * Defines the callback to call when left trigger is pressed
  96131. * @param callback defines the callback to use
  96132. */
  96133. onlefttriggerchanged(callback: (value: number) => void): void;
  96134. /**
  96135. * Defines the callback to call when right trigger is pressed
  96136. * @param callback defines the callback to use
  96137. */
  96138. onrighttriggerchanged(callback: (value: number) => void): void;
  96139. /**
  96140. * Gets the left trigger value
  96141. */
  96142. /**
  96143. * Sets the left trigger value
  96144. */
  96145. leftTrigger: number;
  96146. /**
  96147. * Gets the right trigger value
  96148. */
  96149. /**
  96150. * Sets the right trigger value
  96151. */
  96152. rightTrigger: number;
  96153. /**
  96154. * Defines the callback to call when a button is pressed
  96155. * @param callback defines the callback to use
  96156. */
  96157. onbuttondown(callback: (buttonPressed: Xbox360Button) => void): void;
  96158. /**
  96159. * Defines the callback to call when a button is released
  96160. * @param callback defines the callback to use
  96161. */
  96162. onbuttonup(callback: (buttonReleased: Xbox360Button) => void): void;
  96163. /**
  96164. * Defines the callback to call when a pad is pressed
  96165. * @param callback defines the callback to use
  96166. */
  96167. ondpaddown(callback: (dPadPressed: Xbox360Dpad) => void): void;
  96168. /**
  96169. * Defines the callback to call when a pad is released
  96170. * @param callback defines the callback to use
  96171. */
  96172. ondpadup(callback: (dPadReleased: Xbox360Dpad) => void): void;
  96173. private _setButtonValue;
  96174. private _setDPadValue;
  96175. /**
  96176. * Gets the value of the `A` button
  96177. */
  96178. /**
  96179. * Sets the value of the `A` button
  96180. */
  96181. buttonA: number;
  96182. /**
  96183. * Gets the value of the `B` button
  96184. */
  96185. /**
  96186. * Sets the value of the `B` button
  96187. */
  96188. buttonB: number;
  96189. /**
  96190. * Gets the value of the `X` button
  96191. */
  96192. /**
  96193. * Sets the value of the `X` button
  96194. */
  96195. buttonX: number;
  96196. /**
  96197. * Gets the value of the `Y` button
  96198. */
  96199. /**
  96200. * Sets the value of the `Y` button
  96201. */
  96202. buttonY: number;
  96203. /**
  96204. * Gets the value of the `Start` button
  96205. */
  96206. /**
  96207. * Sets the value of the `Start` button
  96208. */
  96209. buttonStart: number;
  96210. /**
  96211. * Gets the value of the `Back` button
  96212. */
  96213. /**
  96214. * Sets the value of the `Back` button
  96215. */
  96216. buttonBack: number;
  96217. /**
  96218. * Gets the value of the `Left` button
  96219. */
  96220. /**
  96221. * Sets the value of the `Left` button
  96222. */
  96223. buttonLB: number;
  96224. /**
  96225. * Gets the value of the `Right` button
  96226. */
  96227. /**
  96228. * Sets the value of the `Right` button
  96229. */
  96230. buttonRB: number;
  96231. /**
  96232. * Gets the value of the Left joystick
  96233. */
  96234. /**
  96235. * Sets the value of the Left joystick
  96236. */
  96237. buttonLeftStick: number;
  96238. /**
  96239. * Gets the value of the Right joystick
  96240. */
  96241. /**
  96242. * Sets the value of the Right joystick
  96243. */
  96244. buttonRightStick: number;
  96245. /**
  96246. * Gets the value of D-pad up
  96247. */
  96248. /**
  96249. * Sets the value of D-pad up
  96250. */
  96251. dPadUp: number;
  96252. /**
  96253. * Gets the value of D-pad down
  96254. */
  96255. /**
  96256. * Sets the value of D-pad down
  96257. */
  96258. dPadDown: number;
  96259. /**
  96260. * Gets the value of D-pad left
  96261. */
  96262. /**
  96263. * Sets the value of D-pad left
  96264. */
  96265. dPadLeft: number;
  96266. /**
  96267. * Gets the value of D-pad right
  96268. */
  96269. /**
  96270. * Sets the value of D-pad right
  96271. */
  96272. dPadRight: number;
  96273. /**
  96274. * Force the gamepad to synchronize with device values
  96275. */
  96276. update(): void;
  96277. /**
  96278. * Disposes the gamepad
  96279. */
  96280. dispose(): void;
  96281. }
  96282. }
  96283. declare module BABYLON {
  96284. /**
  96285. * Base class of materials working in push mode in babylon JS
  96286. * @hidden
  96287. */
  96288. export class PushMaterial extends Material {
  96289. protected _activeEffect: Effect;
  96290. protected _normalMatrix: Matrix;
  96291. /**
  96292. * Gets or sets a boolean indicating that the material is allowed to do shader hot swapping.
  96293. * This means that the material can keep using a previous shader while a new one is being compiled.
  96294. * This is mostly used when shader parallel compilation is supported (true by default)
  96295. */
  96296. allowShaderHotSwapping: boolean;
  96297. constructor(name: string, scene: Scene);
  96298. getEffect(): Effect;
  96299. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  96300. /**
  96301. * Binds the given world matrix to the active effect
  96302. *
  96303. * @param world the matrix to bind
  96304. */
  96305. bindOnlyWorldMatrix(world: Matrix): void;
  96306. /**
  96307. * Binds the given normal matrix to the active effect
  96308. *
  96309. * @param normalMatrix the matrix to bind
  96310. */
  96311. bindOnlyNormalMatrix(normalMatrix: Matrix): void;
  96312. bind(world: Matrix, mesh?: Mesh): void;
  96313. protected _afterBind(mesh: Mesh, effect?: Nullable<Effect>): void;
  96314. protected _mustRebind(scene: Scene, effect: Effect, visibility?: number): boolean;
  96315. }
  96316. }
  96317. declare module BABYLON {
  96318. /**
  96319. * This groups all the flags used to control the materials channel.
  96320. */
  96321. export class MaterialFlags {
  96322. private static _DiffuseTextureEnabled;
  96323. /**
  96324. * Are diffuse textures enabled in the application.
  96325. */
  96326. static DiffuseTextureEnabled: boolean;
  96327. private static _AmbientTextureEnabled;
  96328. /**
  96329. * Are ambient textures enabled in the application.
  96330. */
  96331. static AmbientTextureEnabled: boolean;
  96332. private static _OpacityTextureEnabled;
  96333. /**
  96334. * Are opacity textures enabled in the application.
  96335. */
  96336. static OpacityTextureEnabled: boolean;
  96337. private static _ReflectionTextureEnabled;
  96338. /**
  96339. * Are reflection textures enabled in the application.
  96340. */
  96341. static ReflectionTextureEnabled: boolean;
  96342. private static _EmissiveTextureEnabled;
  96343. /**
  96344. * Are emissive textures enabled in the application.
  96345. */
  96346. static EmissiveTextureEnabled: boolean;
  96347. private static _SpecularTextureEnabled;
  96348. /**
  96349. * Are specular textures enabled in the application.
  96350. */
  96351. static SpecularTextureEnabled: boolean;
  96352. private static _BumpTextureEnabled;
  96353. /**
  96354. * Are bump textures enabled in the application.
  96355. */
  96356. static BumpTextureEnabled: boolean;
  96357. private static _LightmapTextureEnabled;
  96358. /**
  96359. * Are lightmap textures enabled in the application.
  96360. */
  96361. static LightmapTextureEnabled: boolean;
  96362. private static _RefractionTextureEnabled;
  96363. /**
  96364. * Are refraction textures enabled in the application.
  96365. */
  96366. static RefractionTextureEnabled: boolean;
  96367. private static _ColorGradingTextureEnabled;
  96368. /**
  96369. * Are color grading textures enabled in the application.
  96370. */
  96371. static ColorGradingTextureEnabled: boolean;
  96372. private static _FresnelEnabled;
  96373. /**
  96374. * Are fresnels enabled in the application.
  96375. */
  96376. static FresnelEnabled: boolean;
  96377. private static _ClearCoatTextureEnabled;
  96378. /**
  96379. * Are clear coat textures enabled in the application.
  96380. */
  96381. static ClearCoatTextureEnabled: boolean;
  96382. private static _ClearCoatBumpTextureEnabled;
  96383. /**
  96384. * Are clear coat bump textures enabled in the application.
  96385. */
  96386. static ClearCoatBumpTextureEnabled: boolean;
  96387. private static _ClearCoatTintTextureEnabled;
  96388. /**
  96389. * Are clear coat tint textures enabled in the application.
  96390. */
  96391. static ClearCoatTintTextureEnabled: boolean;
  96392. private static _SheenTextureEnabled;
  96393. /**
  96394. * Are sheen textures enabled in the application.
  96395. */
  96396. static SheenTextureEnabled: boolean;
  96397. private static _AnisotropicTextureEnabled;
  96398. /**
  96399. * Are anisotropic textures enabled in the application.
  96400. */
  96401. static AnisotropicTextureEnabled: boolean;
  96402. }
  96403. }
  96404. declare module BABYLON {
  96405. /** @hidden */
  96406. export var defaultFragmentDeclaration: {
  96407. name: string;
  96408. shader: string;
  96409. };
  96410. }
  96411. declare module BABYLON {
  96412. /** @hidden */
  96413. export var defaultUboDeclaration: {
  96414. name: string;
  96415. shader: string;
  96416. };
  96417. }
  96418. declare module BABYLON {
  96419. /** @hidden */
  96420. export var lightFragmentDeclaration: {
  96421. name: string;
  96422. shader: string;
  96423. };
  96424. }
  96425. declare module BABYLON {
  96426. /** @hidden */
  96427. export var lightUboDeclaration: {
  96428. name: string;
  96429. shader: string;
  96430. };
  96431. }
  96432. declare module BABYLON {
  96433. /** @hidden */
  96434. export var lightsFragmentFunctions: {
  96435. name: string;
  96436. shader: string;
  96437. };
  96438. }
  96439. declare module BABYLON {
  96440. /** @hidden */
  96441. export var shadowsFragmentFunctions: {
  96442. name: string;
  96443. shader: string;
  96444. };
  96445. }
  96446. declare module BABYLON {
  96447. /** @hidden */
  96448. export var fresnelFunction: {
  96449. name: string;
  96450. shader: string;
  96451. };
  96452. }
  96453. declare module BABYLON {
  96454. /** @hidden */
  96455. export var reflectionFunction: {
  96456. name: string;
  96457. shader: string;
  96458. };
  96459. }
  96460. declare module BABYLON {
  96461. /** @hidden */
  96462. export var bumpFragmentFunctions: {
  96463. name: string;
  96464. shader: string;
  96465. };
  96466. }
  96467. declare module BABYLON {
  96468. /** @hidden */
  96469. export var logDepthDeclaration: {
  96470. name: string;
  96471. shader: string;
  96472. };
  96473. }
  96474. declare module BABYLON {
  96475. /** @hidden */
  96476. export var bumpFragment: {
  96477. name: string;
  96478. shader: string;
  96479. };
  96480. }
  96481. declare module BABYLON {
  96482. /** @hidden */
  96483. export var depthPrePass: {
  96484. name: string;
  96485. shader: string;
  96486. };
  96487. }
  96488. declare module BABYLON {
  96489. /** @hidden */
  96490. export var lightFragment: {
  96491. name: string;
  96492. shader: string;
  96493. };
  96494. }
  96495. declare module BABYLON {
  96496. /** @hidden */
  96497. export var logDepthFragment: {
  96498. name: string;
  96499. shader: string;
  96500. };
  96501. }
  96502. declare module BABYLON {
  96503. /** @hidden */
  96504. export var defaultPixelShader: {
  96505. name: string;
  96506. shader: string;
  96507. };
  96508. }
  96509. declare module BABYLON {
  96510. /** @hidden */
  96511. export var defaultVertexDeclaration: {
  96512. name: string;
  96513. shader: string;
  96514. };
  96515. }
  96516. declare module BABYLON {
  96517. /** @hidden */
  96518. export var bumpVertexDeclaration: {
  96519. name: string;
  96520. shader: string;
  96521. };
  96522. }
  96523. declare module BABYLON {
  96524. /** @hidden */
  96525. export var bumpVertex: {
  96526. name: string;
  96527. shader: string;
  96528. };
  96529. }
  96530. declare module BABYLON {
  96531. /** @hidden */
  96532. export var fogVertex: {
  96533. name: string;
  96534. shader: string;
  96535. };
  96536. }
  96537. declare module BABYLON {
  96538. /** @hidden */
  96539. export var shadowsVertex: {
  96540. name: string;
  96541. shader: string;
  96542. };
  96543. }
  96544. declare module BABYLON {
  96545. /** @hidden */
  96546. export var pointCloudVertex: {
  96547. name: string;
  96548. shader: string;
  96549. };
  96550. }
  96551. declare module BABYLON {
  96552. /** @hidden */
  96553. export var logDepthVertex: {
  96554. name: string;
  96555. shader: string;
  96556. };
  96557. }
  96558. declare module BABYLON {
  96559. /** @hidden */
  96560. export var defaultVertexShader: {
  96561. name: string;
  96562. shader: string;
  96563. };
  96564. }
  96565. declare module BABYLON {
  96566. /** @hidden */
  96567. export class StandardMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  96568. MAINUV1: boolean;
  96569. MAINUV2: boolean;
  96570. DIFFUSE: boolean;
  96571. DIFFUSEDIRECTUV: number;
  96572. AMBIENT: boolean;
  96573. AMBIENTDIRECTUV: number;
  96574. OPACITY: boolean;
  96575. OPACITYDIRECTUV: number;
  96576. OPACITYRGB: boolean;
  96577. REFLECTION: boolean;
  96578. EMISSIVE: boolean;
  96579. EMISSIVEDIRECTUV: number;
  96580. SPECULAR: boolean;
  96581. SPECULARDIRECTUV: number;
  96582. BUMP: boolean;
  96583. BUMPDIRECTUV: number;
  96584. PARALLAX: boolean;
  96585. PARALLAXOCCLUSION: boolean;
  96586. SPECULAROVERALPHA: boolean;
  96587. CLIPPLANE: boolean;
  96588. CLIPPLANE2: boolean;
  96589. CLIPPLANE3: boolean;
  96590. CLIPPLANE4: boolean;
  96591. ALPHATEST: boolean;
  96592. DEPTHPREPASS: boolean;
  96593. ALPHAFROMDIFFUSE: boolean;
  96594. POINTSIZE: boolean;
  96595. FOG: boolean;
  96596. SPECULARTERM: boolean;
  96597. DIFFUSEFRESNEL: boolean;
  96598. OPACITYFRESNEL: boolean;
  96599. REFLECTIONFRESNEL: boolean;
  96600. REFRACTIONFRESNEL: boolean;
  96601. EMISSIVEFRESNEL: boolean;
  96602. FRESNEL: boolean;
  96603. NORMAL: boolean;
  96604. UV1: boolean;
  96605. UV2: boolean;
  96606. VERTEXCOLOR: boolean;
  96607. VERTEXALPHA: boolean;
  96608. NUM_BONE_INFLUENCERS: number;
  96609. BonesPerMesh: number;
  96610. BONETEXTURE: boolean;
  96611. INSTANCES: boolean;
  96612. GLOSSINESS: boolean;
  96613. ROUGHNESS: boolean;
  96614. EMISSIVEASILLUMINATION: boolean;
  96615. LINKEMISSIVEWITHDIFFUSE: boolean;
  96616. REFLECTIONFRESNELFROMSPECULAR: boolean;
  96617. LIGHTMAP: boolean;
  96618. LIGHTMAPDIRECTUV: number;
  96619. OBJECTSPACE_NORMALMAP: boolean;
  96620. USELIGHTMAPASSHADOWMAP: boolean;
  96621. REFLECTIONMAP_3D: boolean;
  96622. REFLECTIONMAP_SPHERICAL: boolean;
  96623. REFLECTIONMAP_PLANAR: boolean;
  96624. REFLECTIONMAP_CUBIC: boolean;
  96625. USE_LOCAL_REFLECTIONMAP_CUBIC: boolean;
  96626. REFLECTIONMAP_PROJECTION: boolean;
  96627. REFLECTIONMAP_SKYBOX: boolean;
  96628. REFLECTIONMAP_SKYBOX_TRANSFORMED: boolean;
  96629. REFLECTIONMAP_EXPLICIT: boolean;
  96630. REFLECTIONMAP_EQUIRECTANGULAR: boolean;
  96631. REFLECTIONMAP_EQUIRECTANGULAR_FIXED: boolean;
  96632. REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED: boolean;
  96633. INVERTCUBICMAP: boolean;
  96634. LOGARITHMICDEPTH: boolean;
  96635. REFRACTION: boolean;
  96636. REFRACTIONMAP_3D: boolean;
  96637. REFLECTIONOVERALPHA: boolean;
  96638. TWOSIDEDLIGHTING: boolean;
  96639. SHADOWFLOAT: boolean;
  96640. MORPHTARGETS: boolean;
  96641. MORPHTARGETS_NORMAL: boolean;
  96642. MORPHTARGETS_TANGENT: boolean;
  96643. NUM_MORPH_INFLUENCERS: number;
  96644. NONUNIFORMSCALING: boolean;
  96645. PREMULTIPLYALPHA: boolean;
  96646. IMAGEPROCESSING: boolean;
  96647. VIGNETTE: boolean;
  96648. VIGNETTEBLENDMODEMULTIPLY: boolean;
  96649. VIGNETTEBLENDMODEOPAQUE: boolean;
  96650. TONEMAPPING: boolean;
  96651. TONEMAPPING_ACES: boolean;
  96652. CONTRAST: boolean;
  96653. COLORCURVES: boolean;
  96654. COLORGRADING: boolean;
  96655. COLORGRADING3D: boolean;
  96656. SAMPLER3DGREENDEPTH: boolean;
  96657. SAMPLER3DBGRMAP: boolean;
  96658. IMAGEPROCESSINGPOSTPROCESS: boolean;
  96659. /**
  96660. * If the reflection texture on this material is in linear color space
  96661. * @hidden
  96662. */
  96663. IS_REFLECTION_LINEAR: boolean;
  96664. /**
  96665. * If the refraction texture on this material is in linear color space
  96666. * @hidden
  96667. */
  96668. IS_REFRACTION_LINEAR: boolean;
  96669. EXPOSURE: boolean;
  96670. constructor();
  96671. setReflectionMode(modeToEnable: string): void;
  96672. }
  96673. /**
  96674. * This is the default material used in Babylon. It is the best trade off between quality
  96675. * and performances.
  96676. * @see http://doc.babylonjs.com/babylon101/materials
  96677. */
  96678. export class StandardMaterial extends PushMaterial {
  96679. private _diffuseTexture;
  96680. /**
  96681. * The basic texture of the material as viewed under a light.
  96682. */
  96683. diffuseTexture: Nullable<BaseTexture>;
  96684. private _ambientTexture;
  96685. /**
  96686. * AKA Occlusion Texture in other nomenclature, it helps adding baked shadows into your material.
  96687. */
  96688. ambientTexture: Nullable<BaseTexture>;
  96689. private _opacityTexture;
  96690. /**
  96691. * Define the transparency of the material from a texture.
  96692. * The final alpha value can be read either from the red channel (if texture.getAlphaFromRGB is false)
  96693. * or from the luminance or the current texel (if texture.getAlphaFromRGB is true)
  96694. */
  96695. opacityTexture: Nullable<BaseTexture>;
  96696. private _reflectionTexture;
  96697. /**
  96698. * Define the texture used to display the reflection.
  96699. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  96700. */
  96701. reflectionTexture: Nullable<BaseTexture>;
  96702. private _emissiveTexture;
  96703. /**
  96704. * Define texture of the material as if self lit.
  96705. * This will be mixed in the final result even in the absence of light.
  96706. */
  96707. emissiveTexture: Nullable<BaseTexture>;
  96708. private _specularTexture;
  96709. /**
  96710. * Define how the color and intensity of the highlight given by the light in the material.
  96711. */
  96712. specularTexture: Nullable<BaseTexture>;
  96713. private _bumpTexture;
  96714. /**
  96715. * Bump mapping is a technique to simulate bump and dents on a rendered surface.
  96716. * 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.
  96717. * @see http://doc.babylonjs.com/how_to/more_materials#bump-map
  96718. */
  96719. bumpTexture: Nullable<BaseTexture>;
  96720. private _lightmapTexture;
  96721. /**
  96722. * Complex lighting can be computationally expensive to compute at runtime.
  96723. * To save on computation, lightmaps may be used to store calculated lighting in a texture which will be applied to a given mesh.
  96724. * @see http://doc.babylonjs.com/babylon101/lights#lightmaps
  96725. */
  96726. lightmapTexture: Nullable<BaseTexture>;
  96727. private _refractionTexture;
  96728. /**
  96729. * Define the texture used to display the refraction.
  96730. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  96731. */
  96732. refractionTexture: Nullable<BaseTexture>;
  96733. /**
  96734. * The color of the material lit by the environmental background lighting.
  96735. * @see http://doc.babylonjs.com/babylon101/materials#ambient-color-example
  96736. */
  96737. ambientColor: Color3;
  96738. /**
  96739. * The basic color of the material as viewed under a light.
  96740. */
  96741. diffuseColor: Color3;
  96742. /**
  96743. * Define how the color and intensity of the highlight given by the light in the material.
  96744. */
  96745. specularColor: Color3;
  96746. /**
  96747. * Define the color of the material as if self lit.
  96748. * This will be mixed in the final result even in the absence of light.
  96749. */
  96750. emissiveColor: Color3;
  96751. /**
  96752. * Defines how sharp are the highlights in the material.
  96753. * The bigger the value the sharper giving a more glossy feeling to the result.
  96754. * Reversely, the smaller the value the blurrier giving a more rough feeling to the result.
  96755. */
  96756. specularPower: number;
  96757. private _useAlphaFromDiffuseTexture;
  96758. /**
  96759. * Does the transparency come from the diffuse texture alpha channel.
  96760. */
  96761. useAlphaFromDiffuseTexture: boolean;
  96762. private _useEmissiveAsIllumination;
  96763. /**
  96764. * If true, the emissive value is added into the end result, otherwise it is multiplied in.
  96765. */
  96766. useEmissiveAsIllumination: boolean;
  96767. private _linkEmissiveWithDiffuse;
  96768. /**
  96769. * If true, some kind of energy conservation will prevent the end result to be more than 1 by reducing
  96770. * the emissive level when the final color is close to one.
  96771. */
  96772. linkEmissiveWithDiffuse: boolean;
  96773. private _useSpecularOverAlpha;
  96774. /**
  96775. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  96776. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  96777. */
  96778. useSpecularOverAlpha: boolean;
  96779. private _useReflectionOverAlpha;
  96780. /**
  96781. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  96782. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  96783. */
  96784. useReflectionOverAlpha: boolean;
  96785. private _disableLighting;
  96786. /**
  96787. * Does lights from the scene impacts this material.
  96788. * It can be a nice trick for performance to disable lighting on a fully emissive material.
  96789. */
  96790. disableLighting: boolean;
  96791. private _useObjectSpaceNormalMap;
  96792. /**
  96793. * Allows using an object space normal map (instead of tangent space).
  96794. */
  96795. useObjectSpaceNormalMap: boolean;
  96796. private _useParallax;
  96797. /**
  96798. * Is parallax enabled or not.
  96799. * @see http://doc.babylonjs.com/how_to/using_parallax_mapping
  96800. */
  96801. useParallax: boolean;
  96802. private _useParallaxOcclusion;
  96803. /**
  96804. * Is parallax occlusion enabled or not.
  96805. * If true, the outcome is way more realistic than traditional Parallax but you can expect a performance hit that worthes consideration.
  96806. * @see http://doc.babylonjs.com/how_to/using_parallax_mapping
  96807. */
  96808. useParallaxOcclusion: boolean;
  96809. /**
  96810. * 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.
  96811. */
  96812. parallaxScaleBias: number;
  96813. private _roughness;
  96814. /**
  96815. * Helps to define how blurry the reflections should appears in the material.
  96816. */
  96817. roughness: number;
  96818. /**
  96819. * In case of refraction, define the value of the indice of refraction.
  96820. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  96821. */
  96822. indexOfRefraction: number;
  96823. /**
  96824. * Invert the refraction texture alongside the y axis.
  96825. * It can be useful with procedural textures or probe for instance.
  96826. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  96827. */
  96828. invertRefractionY: boolean;
  96829. /**
  96830. * Defines the alpha limits in alpha test mode.
  96831. */
  96832. alphaCutOff: number;
  96833. private _useLightmapAsShadowmap;
  96834. /**
  96835. * In case of light mapping, define whether the map contains light or shadow informations.
  96836. */
  96837. useLightmapAsShadowmap: boolean;
  96838. private _diffuseFresnelParameters;
  96839. /**
  96840. * Define the diffuse fresnel parameters of the material.
  96841. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  96842. */
  96843. diffuseFresnelParameters: FresnelParameters;
  96844. private _opacityFresnelParameters;
  96845. /**
  96846. * Define the opacity fresnel parameters of the material.
  96847. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  96848. */
  96849. opacityFresnelParameters: FresnelParameters;
  96850. private _reflectionFresnelParameters;
  96851. /**
  96852. * Define the reflection fresnel parameters of the material.
  96853. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  96854. */
  96855. reflectionFresnelParameters: FresnelParameters;
  96856. private _refractionFresnelParameters;
  96857. /**
  96858. * Define the refraction fresnel parameters of the material.
  96859. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  96860. */
  96861. refractionFresnelParameters: FresnelParameters;
  96862. private _emissiveFresnelParameters;
  96863. /**
  96864. * Define the emissive fresnel parameters of the material.
  96865. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  96866. */
  96867. emissiveFresnelParameters: FresnelParameters;
  96868. private _useReflectionFresnelFromSpecular;
  96869. /**
  96870. * If true automatically deducts the fresnels values from the material specularity.
  96871. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  96872. */
  96873. useReflectionFresnelFromSpecular: boolean;
  96874. private _useGlossinessFromSpecularMapAlpha;
  96875. /**
  96876. * Defines if the glossiness/roughness of the material should be read from the specular map alpha channel
  96877. */
  96878. useGlossinessFromSpecularMapAlpha: boolean;
  96879. private _maxSimultaneousLights;
  96880. /**
  96881. * Defines the maximum number of lights that can be used in the material
  96882. */
  96883. maxSimultaneousLights: number;
  96884. private _invertNormalMapX;
  96885. /**
  96886. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  96887. */
  96888. invertNormalMapX: boolean;
  96889. private _invertNormalMapY;
  96890. /**
  96891. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  96892. */
  96893. invertNormalMapY: boolean;
  96894. private _twoSidedLighting;
  96895. /**
  96896. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  96897. */
  96898. twoSidedLighting: boolean;
  96899. /**
  96900. * Default configuration related to image processing available in the standard Material.
  96901. */
  96902. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  96903. /**
  96904. * Gets the image processing configuration used either in this material.
  96905. */
  96906. /**
  96907. * Sets the Default image processing configuration used either in the this material.
  96908. *
  96909. * If sets to null, the scene one is in use.
  96910. */
  96911. imageProcessingConfiguration: ImageProcessingConfiguration;
  96912. /**
  96913. * Keep track of the image processing observer to allow dispose and replace.
  96914. */
  96915. private _imageProcessingObserver;
  96916. /**
  96917. * Attaches a new image processing configuration to the Standard Material.
  96918. * @param configuration
  96919. */
  96920. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  96921. /**
  96922. * Gets wether the color curves effect is enabled.
  96923. */
  96924. /**
  96925. * Sets wether the color curves effect is enabled.
  96926. */
  96927. cameraColorCurvesEnabled: boolean;
  96928. /**
  96929. * Gets wether the color grading effect is enabled.
  96930. */
  96931. /**
  96932. * Gets wether the color grading effect is enabled.
  96933. */
  96934. cameraColorGradingEnabled: boolean;
  96935. /**
  96936. * Gets wether tonemapping is enabled or not.
  96937. */
  96938. /**
  96939. * Sets wether tonemapping is enabled or not
  96940. */
  96941. cameraToneMappingEnabled: boolean;
  96942. /**
  96943. * The camera exposure used on this material.
  96944. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  96945. * This corresponds to a photographic exposure.
  96946. */
  96947. /**
  96948. * The camera exposure used on this material.
  96949. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  96950. * This corresponds to a photographic exposure.
  96951. */
  96952. cameraExposure: number;
  96953. /**
  96954. * Gets The camera contrast used on this material.
  96955. */
  96956. /**
  96957. * Sets The camera contrast used on this material.
  96958. */
  96959. cameraContrast: number;
  96960. /**
  96961. * Gets the Color Grading 2D Lookup Texture.
  96962. */
  96963. /**
  96964. * Sets the Color Grading 2D Lookup Texture.
  96965. */
  96966. cameraColorGradingTexture: Nullable<BaseTexture>;
  96967. /**
  96968. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  96969. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  96970. * 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;
  96971. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  96972. */
  96973. /**
  96974. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  96975. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  96976. * 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;
  96977. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  96978. */
  96979. cameraColorCurves: Nullable<ColorCurves>;
  96980. /**
  96981. * Custom callback helping to override the default shader used in the material.
  96982. */
  96983. customShaderNameResolve: (shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: StandardMaterialDefines) => string;
  96984. protected _renderTargets: SmartArray<RenderTargetTexture>;
  96985. protected _worldViewProjectionMatrix: Matrix;
  96986. protected _globalAmbientColor: Color3;
  96987. protected _useLogarithmicDepth: boolean;
  96988. /**
  96989. * Instantiates a new standard material.
  96990. * This is the default material used in Babylon. It is the best trade off between quality
  96991. * and performances.
  96992. * @see http://doc.babylonjs.com/babylon101/materials
  96993. * @param name Define the name of the material in the scene
  96994. * @param scene Define the scene the material belong to
  96995. */
  96996. constructor(name: string, scene: Scene);
  96997. /**
  96998. * Gets a boolean indicating that current material needs to register RTT
  96999. */
  97000. readonly hasRenderTargetTextures: boolean;
  97001. /**
  97002. * Gets the current class name of the material e.g. "StandardMaterial"
  97003. * Mainly use in serialization.
  97004. * @returns the class name
  97005. */
  97006. getClassName(): string;
  97007. /**
  97008. * In case the depth buffer does not allow enough depth precision for your scene (might be the case in large scenes)
  97009. * You can try switching to logarithmic depth.
  97010. * @see http://doc.babylonjs.com/how_to/using_logarithmic_depth_buffer
  97011. */
  97012. useLogarithmicDepth: boolean;
  97013. /**
  97014. * Specifies if the material will require alpha blending
  97015. * @returns a boolean specifying if alpha blending is needed
  97016. */
  97017. needAlphaBlending(): boolean;
  97018. /**
  97019. * Specifies if this material should be rendered in alpha test mode
  97020. * @returns a boolean specifying if an alpha test is needed.
  97021. */
  97022. needAlphaTesting(): boolean;
  97023. protected _shouldUseAlphaFromDiffuseTexture(): boolean;
  97024. /**
  97025. * Get the texture used for alpha test purpose.
  97026. * @returns the diffuse texture in case of the standard material.
  97027. */
  97028. getAlphaTestTexture(): Nullable<BaseTexture>;
  97029. /**
  97030. * Get if the submesh is ready to be used and all its information available.
  97031. * Child classes can use it to update shaders
  97032. * @param mesh defines the mesh to check
  97033. * @param subMesh defines which submesh to check
  97034. * @param useInstances specifies that instances should be used
  97035. * @returns a boolean indicating that the submesh is ready or not
  97036. */
  97037. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  97038. /**
  97039. * Builds the material UBO layouts.
  97040. * Used internally during the effect preparation.
  97041. */
  97042. buildUniformLayout(): void;
  97043. /**
  97044. * Unbinds the material from the mesh
  97045. */
  97046. unbind(): void;
  97047. /**
  97048. * Binds the submesh to this material by preparing the effect and shader to draw
  97049. * @param world defines the world transformation matrix
  97050. * @param mesh defines the mesh containing the submesh
  97051. * @param subMesh defines the submesh to bind the material to
  97052. */
  97053. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  97054. /**
  97055. * Get the list of animatables in the material.
  97056. * @returns the list of animatables object used in the material
  97057. */
  97058. getAnimatables(): IAnimatable[];
  97059. /**
  97060. * Gets the active textures from the material
  97061. * @returns an array of textures
  97062. */
  97063. getActiveTextures(): BaseTexture[];
  97064. /**
  97065. * Specifies if the material uses a texture
  97066. * @param texture defines the texture to check against the material
  97067. * @returns a boolean specifying if the material uses the texture
  97068. */
  97069. hasTexture(texture: BaseTexture): boolean;
  97070. /**
  97071. * Disposes the material
  97072. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  97073. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  97074. */
  97075. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  97076. /**
  97077. * Makes a duplicate of the material, and gives it a new name
  97078. * @param name defines the new name for the duplicated material
  97079. * @returns the cloned material
  97080. */
  97081. clone(name: string): StandardMaterial;
  97082. /**
  97083. * Serializes this material in a JSON representation
  97084. * @returns the serialized material object
  97085. */
  97086. serialize(): any;
  97087. /**
  97088. * Creates a standard material from parsed material data
  97089. * @param source defines the JSON representation of the material
  97090. * @param scene defines the hosting scene
  97091. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  97092. * @returns a new standard material
  97093. */
  97094. static Parse(source: any, scene: Scene, rootUrl: string): StandardMaterial;
  97095. /**
  97096. * Are diffuse textures enabled in the application.
  97097. */
  97098. static DiffuseTextureEnabled: boolean;
  97099. /**
  97100. * Are ambient textures enabled in the application.
  97101. */
  97102. static AmbientTextureEnabled: boolean;
  97103. /**
  97104. * Are opacity textures enabled in the application.
  97105. */
  97106. static OpacityTextureEnabled: boolean;
  97107. /**
  97108. * Are reflection textures enabled in the application.
  97109. */
  97110. static ReflectionTextureEnabled: boolean;
  97111. /**
  97112. * Are emissive textures enabled in the application.
  97113. */
  97114. static EmissiveTextureEnabled: boolean;
  97115. /**
  97116. * Are specular textures enabled in the application.
  97117. */
  97118. static SpecularTextureEnabled: boolean;
  97119. /**
  97120. * Are bump textures enabled in the application.
  97121. */
  97122. static BumpTextureEnabled: boolean;
  97123. /**
  97124. * Are lightmap textures enabled in the application.
  97125. */
  97126. static LightmapTextureEnabled: boolean;
  97127. /**
  97128. * Are refraction textures enabled in the application.
  97129. */
  97130. static RefractionTextureEnabled: boolean;
  97131. /**
  97132. * Are color grading textures enabled in the application.
  97133. */
  97134. static ColorGradingTextureEnabled: boolean;
  97135. /**
  97136. * Are fresnels enabled in the application.
  97137. */
  97138. static FresnelEnabled: boolean;
  97139. }
  97140. }
  97141. declare module BABYLON {
  97142. /**
  97143. * A class extending Texture allowing drawing on a texture
  97144. * @see http://doc.babylonjs.com/how_to/dynamictexture
  97145. */
  97146. export class DynamicTexture extends Texture {
  97147. private _generateMipMaps;
  97148. private _canvas;
  97149. private _context;
  97150. private _engine;
  97151. /**
  97152. * Creates a DynamicTexture
  97153. * @param name defines the name of the texture
  97154. * @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
  97155. * @param scene defines the scene where you want the texture
  97156. * @param generateMipMaps defines the use of MinMaps or not (default is false)
  97157. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  97158. * @param format defines the texture format to use (default is Engine.TEXTUREFORMAT_RGBA)
  97159. */
  97160. constructor(name: string, options: any, scene: Scene | null | undefined, generateMipMaps: boolean, samplingMode?: number, format?: number);
  97161. /**
  97162. * Get the current class name of the texture useful for serialization or dynamic coding.
  97163. * @returns "DynamicTexture"
  97164. */
  97165. getClassName(): string;
  97166. /**
  97167. * Gets the current state of canRescale
  97168. */
  97169. readonly canRescale: boolean;
  97170. private _recreate;
  97171. /**
  97172. * Scales the texture
  97173. * @param ratio the scale factor to apply to both width and height
  97174. */
  97175. scale(ratio: number): void;
  97176. /**
  97177. * Resizes the texture
  97178. * @param width the new width
  97179. * @param height the new height
  97180. */
  97181. scaleTo(width: number, height: number): void;
  97182. /**
  97183. * Gets the context of the canvas used by the texture
  97184. * @returns the canvas context of the dynamic texture
  97185. */
  97186. getContext(): CanvasRenderingContext2D;
  97187. /**
  97188. * Clears the texture
  97189. */
  97190. clear(): void;
  97191. /**
  97192. * Updates the texture
  97193. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  97194. * @param premulAlpha defines if alpha is stored as premultiplied (default is false)
  97195. */
  97196. update(invertY?: boolean, premulAlpha?: boolean): void;
  97197. /**
  97198. * Draws text onto the texture
  97199. * @param text defines the text to be drawn
  97200. * @param x defines the placement of the text from the left
  97201. * @param y defines the placement of the text from the top when invertY is true and from the bottom when false
  97202. * @param font defines the font to be used with font-style, font-size, font-name
  97203. * @param color defines the color used for the text
  97204. * @param clearColor defines the color for the canvas, use null to not overwrite canvas
  97205. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  97206. * @param update defines whether texture is immediately update (default is true)
  97207. */
  97208. drawText(text: string, x: number, y: number, font: string, color: string, clearColor: string, invertY?: boolean, update?: boolean): void;
  97209. /**
  97210. * Clones the texture
  97211. * @returns the clone of the texture.
  97212. */
  97213. clone(): DynamicTexture;
  97214. /**
  97215. * Serializes the dynamic texture. The scene should be ready before the dynamic texture is serialized
  97216. * @returns a serialized dynamic texture object
  97217. */
  97218. serialize(): any;
  97219. /** @hidden */
  97220. _rebuild(): void;
  97221. }
  97222. }
  97223. declare module BABYLON {
  97224. /** @hidden */
  97225. export var imageProcessingPixelShader: {
  97226. name: string;
  97227. shader: string;
  97228. };
  97229. }
  97230. declare module BABYLON {
  97231. /**
  97232. * ImageProcessingPostProcess
  97233. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#imageprocessing
  97234. */
  97235. export class ImageProcessingPostProcess extends PostProcess {
  97236. /**
  97237. * Default configuration related to image processing available in the PBR Material.
  97238. */
  97239. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  97240. /**
  97241. * Gets the image processing configuration used either in this material.
  97242. */
  97243. /**
  97244. * Sets the Default image processing configuration used either in the this material.
  97245. *
  97246. * If sets to null, the scene one is in use.
  97247. */
  97248. imageProcessingConfiguration: ImageProcessingConfiguration;
  97249. /**
  97250. * Keep track of the image processing observer to allow dispose and replace.
  97251. */
  97252. private _imageProcessingObserver;
  97253. /**
  97254. * Attaches a new image processing configuration to the PBR Material.
  97255. * @param configuration
  97256. */
  97257. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>, doNotBuild?: boolean): void;
  97258. /**
  97259. * Gets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  97260. */
  97261. /**
  97262. * Sets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  97263. */
  97264. colorCurves: Nullable<ColorCurves>;
  97265. /**
  97266. * Gets wether the color curves effect is enabled.
  97267. */
  97268. /**
  97269. * Sets wether the color curves effect is enabled.
  97270. */
  97271. colorCurvesEnabled: boolean;
  97272. /**
  97273. * Gets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  97274. */
  97275. /**
  97276. * Sets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  97277. */
  97278. colorGradingTexture: Nullable<BaseTexture>;
  97279. /**
  97280. * Gets wether the color grading effect is enabled.
  97281. */
  97282. /**
  97283. * Gets wether the color grading effect is enabled.
  97284. */
  97285. colorGradingEnabled: boolean;
  97286. /**
  97287. * Gets exposure used in the effect.
  97288. */
  97289. /**
  97290. * Sets exposure used in the effect.
  97291. */
  97292. exposure: number;
  97293. /**
  97294. * Gets wether tonemapping is enabled or not.
  97295. */
  97296. /**
  97297. * Sets wether tonemapping is enabled or not
  97298. */
  97299. toneMappingEnabled: boolean;
  97300. /**
  97301. * Gets the type of tone mapping effect.
  97302. */
  97303. /**
  97304. * Sets the type of tone mapping effect.
  97305. */
  97306. toneMappingType: number;
  97307. /**
  97308. * Gets contrast used in the effect.
  97309. */
  97310. /**
  97311. * Sets contrast used in the effect.
  97312. */
  97313. contrast: number;
  97314. /**
  97315. * Gets Vignette stretch size.
  97316. */
  97317. /**
  97318. * Sets Vignette stretch size.
  97319. */
  97320. vignetteStretch: number;
  97321. /**
  97322. * Gets Vignette centre X Offset.
  97323. */
  97324. /**
  97325. * Sets Vignette centre X Offset.
  97326. */
  97327. vignetteCentreX: number;
  97328. /**
  97329. * Gets Vignette centre Y Offset.
  97330. */
  97331. /**
  97332. * Sets Vignette centre Y Offset.
  97333. */
  97334. vignetteCentreY: number;
  97335. /**
  97336. * Gets Vignette weight or intensity of the vignette effect.
  97337. */
  97338. /**
  97339. * Sets Vignette weight or intensity of the vignette effect.
  97340. */
  97341. vignetteWeight: number;
  97342. /**
  97343. * Gets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  97344. * if vignetteEnabled is set to true.
  97345. */
  97346. /**
  97347. * Sets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  97348. * if vignetteEnabled is set to true.
  97349. */
  97350. vignetteColor: Color4;
  97351. /**
  97352. * Gets Camera field of view used by the Vignette effect.
  97353. */
  97354. /**
  97355. * Sets Camera field of view used by the Vignette effect.
  97356. */
  97357. vignetteCameraFov: number;
  97358. /**
  97359. * Gets the vignette blend mode allowing different kind of effect.
  97360. */
  97361. /**
  97362. * Sets the vignette blend mode allowing different kind of effect.
  97363. */
  97364. vignetteBlendMode: number;
  97365. /**
  97366. * Gets wether the vignette effect is enabled.
  97367. */
  97368. /**
  97369. * Sets wether the vignette effect is enabled.
  97370. */
  97371. vignetteEnabled: boolean;
  97372. private _fromLinearSpace;
  97373. /**
  97374. * Gets wether the input of the processing is in Gamma or Linear Space.
  97375. */
  97376. /**
  97377. * Sets wether the input of the processing is in Gamma or Linear Space.
  97378. */
  97379. fromLinearSpace: boolean;
  97380. /**
  97381. * Defines cache preventing GC.
  97382. */
  97383. private _defines;
  97384. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, imageProcessingConfiguration?: ImageProcessingConfiguration);
  97385. /**
  97386. * "ImageProcessingPostProcess"
  97387. * @returns "ImageProcessingPostProcess"
  97388. */
  97389. getClassName(): string;
  97390. protected _updateParameters(): void;
  97391. dispose(camera?: Camera): void;
  97392. }
  97393. }
  97394. declare module BABYLON {
  97395. /**
  97396. * Class containing static functions to help procedurally build meshes
  97397. */
  97398. export class GroundBuilder {
  97399. /**
  97400. * Creates a ground mesh
  97401. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  97402. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  97403. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  97404. * @param name defines the name of the mesh
  97405. * @param options defines the options used to create the mesh
  97406. * @param scene defines the hosting scene
  97407. * @returns the ground mesh
  97408. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  97409. */
  97410. static CreateGround(name: string, options: {
  97411. width?: number;
  97412. height?: number;
  97413. subdivisions?: number;
  97414. subdivisionsX?: number;
  97415. subdivisionsY?: number;
  97416. updatable?: boolean;
  97417. }, scene: any): Mesh;
  97418. /**
  97419. * Creates a tiled ground mesh
  97420. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  97421. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  97422. * * 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
  97423. * * 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
  97424. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  97425. * @param name defines the name of the mesh
  97426. * @param options defines the options used to create the mesh
  97427. * @param scene defines the hosting scene
  97428. * @returns the tiled ground mesh
  97429. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  97430. */
  97431. static CreateTiledGround(name: string, options: {
  97432. xmin: number;
  97433. zmin: number;
  97434. xmax: number;
  97435. zmax: number;
  97436. subdivisions?: {
  97437. w: number;
  97438. h: number;
  97439. };
  97440. precision?: {
  97441. w: number;
  97442. h: number;
  97443. };
  97444. updatable?: boolean;
  97445. }, scene: Scene): Mesh;
  97446. /**
  97447. * Creates a ground mesh from a height map
  97448. * * The parameter `url` sets the URL of the height map image resource.
  97449. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  97450. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  97451. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  97452. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  97453. * * 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.
  97454. * * 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).
  97455. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  97456. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  97457. * @param name defines the name of the mesh
  97458. * @param url defines the url to the height map
  97459. * @param options defines the options used to create the mesh
  97460. * @param scene defines the hosting scene
  97461. * @returns the ground mesh
  97462. * @see https://doc.babylonjs.com/babylon101/height_map
  97463. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  97464. */
  97465. static CreateGroundFromHeightMap(name: string, url: string, options: {
  97466. width?: number;
  97467. height?: number;
  97468. subdivisions?: number;
  97469. minHeight?: number;
  97470. maxHeight?: number;
  97471. colorFilter?: Color3;
  97472. alphaFilter?: number;
  97473. updatable?: boolean;
  97474. onReady?: (mesh: GroundMesh) => void;
  97475. }, scene: Scene): GroundMesh;
  97476. }
  97477. }
  97478. declare module BABYLON {
  97479. /**
  97480. * Class containing static functions to help procedurally build meshes
  97481. */
  97482. export class TorusBuilder {
  97483. /**
  97484. * Creates a torus mesh
  97485. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  97486. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  97487. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  97488. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  97489. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  97490. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  97491. * @param name defines the name of the mesh
  97492. * @param options defines the options used to create the mesh
  97493. * @param scene defines the hosting scene
  97494. * @returns the torus mesh
  97495. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  97496. */
  97497. static CreateTorus(name: string, options: {
  97498. diameter?: number;
  97499. thickness?: number;
  97500. tessellation?: number;
  97501. updatable?: boolean;
  97502. sideOrientation?: number;
  97503. frontUVs?: Vector4;
  97504. backUVs?: Vector4;
  97505. }, scene: any): Mesh;
  97506. }
  97507. }
  97508. declare module BABYLON {
  97509. /**
  97510. * Class containing static functions to help procedurally build meshes
  97511. */
  97512. export class CylinderBuilder {
  97513. /**
  97514. * Creates a cylinder or a cone mesh
  97515. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  97516. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  97517. * * 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.
  97518. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  97519. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  97520. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  97521. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  97522. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  97523. * * 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).
  97524. * * 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
  97525. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  97526. * * 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
  97527. * * 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.
  97528. * * If `enclose` is false, a ring surface is one element.
  97529. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  97530. * * 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
  97531. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  97532. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  97533. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  97534. * @param name defines the name of the mesh
  97535. * @param options defines the options used to create the mesh
  97536. * @param scene defines the hosting scene
  97537. * @returns the cylinder mesh
  97538. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  97539. */
  97540. static CreateCylinder(name: string, options: {
  97541. height?: number;
  97542. diameterTop?: number;
  97543. diameterBottom?: number;
  97544. diameter?: number;
  97545. tessellation?: number;
  97546. subdivisions?: number;
  97547. arc?: number;
  97548. faceColors?: Color4[];
  97549. faceUV?: Vector4[];
  97550. updatable?: boolean;
  97551. hasRings?: boolean;
  97552. enclose?: boolean;
  97553. sideOrientation?: number;
  97554. frontUVs?: Vector4;
  97555. backUVs?: Vector4;
  97556. }, scene: any): Mesh;
  97557. }
  97558. }
  97559. declare module BABYLON {
  97560. /**
  97561. * Manager for handling gamepads
  97562. */
  97563. export class GamepadManager {
  97564. private _scene?;
  97565. private _babylonGamepads;
  97566. private _oneGamepadConnected;
  97567. /** @hidden */
  97568. _isMonitoring: boolean;
  97569. private _gamepadEventSupported;
  97570. private _gamepadSupport;
  97571. /**
  97572. * observable to be triggered when the gamepad controller has been connected
  97573. */
  97574. onGamepadConnectedObservable: Observable<Gamepad>;
  97575. /**
  97576. * observable to be triggered when the gamepad controller has been disconnected
  97577. */
  97578. onGamepadDisconnectedObservable: Observable<Gamepad>;
  97579. private _onGamepadConnectedEvent;
  97580. private _onGamepadDisconnectedEvent;
  97581. /**
  97582. * Initializes the gamepad manager
  97583. * @param _scene BabylonJS scene
  97584. */
  97585. constructor(_scene?: Scene | undefined);
  97586. /**
  97587. * The gamepads in the game pad manager
  97588. */
  97589. readonly gamepads: Gamepad[];
  97590. /**
  97591. * Get the gamepad controllers based on type
  97592. * @param type The type of gamepad controller
  97593. * @returns Nullable gamepad
  97594. */
  97595. getGamepadByType(type?: number): Nullable<Gamepad>;
  97596. /**
  97597. * Disposes the gamepad manager
  97598. */
  97599. dispose(): void;
  97600. private _addNewGamepad;
  97601. private _startMonitoringGamepads;
  97602. private _stopMonitoringGamepads;
  97603. /** @hidden */
  97604. _checkGamepadsStatus(): void;
  97605. private _updateGamepadObjects;
  97606. }
  97607. }
  97608. declare module BABYLON {
  97609. interface Scene {
  97610. /** @hidden */
  97611. _gamepadManager: Nullable<GamepadManager>;
  97612. /**
  97613. * Gets the gamepad manager associated with the scene
  97614. * @see http://doc.babylonjs.com/how_to/how_to_use_gamepads
  97615. */
  97616. gamepadManager: GamepadManager;
  97617. }
  97618. /**
  97619. * Interface representing a free camera inputs manager
  97620. */
  97621. interface FreeCameraInputsManager {
  97622. /**
  97623. * Adds gamepad input support to the FreeCameraInputsManager.
  97624. * @returns the FreeCameraInputsManager
  97625. */
  97626. addGamepad(): FreeCameraInputsManager;
  97627. }
  97628. /**
  97629. * Interface representing an arc rotate camera inputs manager
  97630. */
  97631. interface ArcRotateCameraInputsManager {
  97632. /**
  97633. * Adds gamepad input support to the ArcRotateCamera InputManager.
  97634. * @returns the camera inputs manager
  97635. */
  97636. addGamepad(): ArcRotateCameraInputsManager;
  97637. }
  97638. /**
  97639. * Defines the gamepad scene component responsible to manage gamepads in a given scene
  97640. */
  97641. export class GamepadSystemSceneComponent implements ISceneComponent {
  97642. /**
  97643. * The component name helpfull to identify the component in the list of scene components.
  97644. */
  97645. readonly name: string;
  97646. /**
  97647. * The scene the component belongs to.
  97648. */
  97649. scene: Scene;
  97650. /**
  97651. * Creates a new instance of the component for the given scene
  97652. * @param scene Defines the scene to register the component in
  97653. */
  97654. constructor(scene: Scene);
  97655. /**
  97656. * Registers the component in a given scene
  97657. */
  97658. register(): void;
  97659. /**
  97660. * Rebuilds the elements related to this component in case of
  97661. * context lost for instance.
  97662. */
  97663. rebuild(): void;
  97664. /**
  97665. * Disposes the component and the associated ressources
  97666. */
  97667. dispose(): void;
  97668. private _beforeCameraUpdate;
  97669. }
  97670. }
  97671. declare module BABYLON {
  97672. /**
  97673. * Options to modify the vr teleportation behavior.
  97674. */
  97675. export interface VRTeleportationOptions {
  97676. /**
  97677. * The name of the mesh which should be used as the teleportation floor. (default: null)
  97678. */
  97679. floorMeshName?: string;
  97680. /**
  97681. * A list of meshes to be used as the teleportation floor. (default: empty)
  97682. */
  97683. floorMeshes?: Mesh[];
  97684. }
  97685. /**
  97686. * Options to modify the vr experience helper's behavior.
  97687. */
  97688. export interface VRExperienceHelperOptions extends WebVROptions {
  97689. /**
  97690. * Create a DeviceOrientationCamera to be used as your out of vr camera. (default: true)
  97691. */
  97692. createDeviceOrientationCamera?: boolean;
  97693. /**
  97694. * Create a VRDeviceOrientationFreeCamera to be used for VR when no external HMD is found. (default: true)
  97695. */
  97696. createFallbackVRDeviceOrientationFreeCamera?: boolean;
  97697. /**
  97698. * Uses the main button on the controller to toggle the laser casted. (default: true)
  97699. */
  97700. laserToggle?: boolean;
  97701. /**
  97702. * A list of meshes to be used as the teleportation floor. If specified, teleportation will be enabled (default: undefined)
  97703. */
  97704. floorMeshes?: Mesh[];
  97705. /**
  97706. * Distortion metrics for the fallback vrDeviceOrientationCamera (default: VRCameraMetrics.Default)
  97707. */
  97708. vrDeviceOrientationCameraMetrics?: VRCameraMetrics;
  97709. }
  97710. /**
  97711. * Event containing information after VR has been entered
  97712. */
  97713. export class OnAfterEnteringVRObservableEvent {
  97714. /**
  97715. * If entering vr was successful
  97716. */
  97717. success: boolean;
  97718. }
  97719. /**
  97720. * Helps to quickly add VR support to an existing scene.
  97721. * See http://doc.babylonjs.com/how_to/webvr_helper
  97722. */
  97723. export class VRExperienceHelper {
  97724. /** Options to modify the vr experience helper's behavior. */
  97725. webVROptions: VRExperienceHelperOptions;
  97726. private _scene;
  97727. private _position;
  97728. private _btnVR;
  97729. private _btnVRDisplayed;
  97730. private _webVRsupported;
  97731. private _webVRready;
  97732. private _webVRrequesting;
  97733. private _webVRpresenting;
  97734. private _hasEnteredVR;
  97735. private _fullscreenVRpresenting;
  97736. private _canvas;
  97737. private _webVRCamera;
  97738. private _vrDeviceOrientationCamera;
  97739. private _deviceOrientationCamera;
  97740. private _existingCamera;
  97741. private _onKeyDown;
  97742. private _onVrDisplayPresentChange;
  97743. private _onVRDisplayChanged;
  97744. private _onVRRequestPresentStart;
  97745. private _onVRRequestPresentComplete;
  97746. /**
  97747. * Observable raised right before entering VR.
  97748. */
  97749. onEnteringVRObservable: Observable<VRExperienceHelper>;
  97750. /**
  97751. * Observable raised when entering VR has completed.
  97752. */
  97753. onAfterEnteringVRObservable: Observable<OnAfterEnteringVRObservableEvent>;
  97754. /**
  97755. * Observable raised when exiting VR.
  97756. */
  97757. onExitingVRObservable: Observable<VRExperienceHelper>;
  97758. /**
  97759. * Observable raised when controller mesh is loaded.
  97760. */
  97761. onControllerMeshLoadedObservable: Observable<WebVRController>;
  97762. /** Return this.onEnteringVRObservable
  97763. * Note: This one is for backward compatibility. Please use onEnteringVRObservable directly
  97764. */
  97765. readonly onEnteringVR: Observable<VRExperienceHelper>;
  97766. /** Return this.onExitingVRObservable
  97767. * Note: This one is for backward compatibility. Please use onExitingVRObservable directly
  97768. */
  97769. readonly onExitingVR: Observable<VRExperienceHelper>;
  97770. /** Return this.onControllerMeshLoadedObservable
  97771. * Note: This one is for backward compatibility. Please use onControllerMeshLoadedObservable directly
  97772. */
  97773. readonly onControllerMeshLoaded: Observable<WebVRController>;
  97774. private _rayLength;
  97775. private _useCustomVRButton;
  97776. private _teleportationRequested;
  97777. private _teleportActive;
  97778. private _floorMeshName;
  97779. private _floorMeshesCollection;
  97780. private _rotationAllowed;
  97781. private _teleportBackwardsVector;
  97782. private _teleportationTarget;
  97783. private _isDefaultTeleportationTarget;
  97784. private _postProcessMove;
  97785. private _teleportationFillColor;
  97786. private _teleportationBorderColor;
  97787. private _rotationAngle;
  97788. private _haloCenter;
  97789. private _cameraGazer;
  97790. private _padSensibilityUp;
  97791. private _padSensibilityDown;
  97792. private _leftController;
  97793. private _rightController;
  97794. /**
  97795. * Observable raised when a new mesh is selected based on meshSelectionPredicate
  97796. */
  97797. onNewMeshSelected: Observable<AbstractMesh>;
  97798. /**
  97799. * Observable raised when a new mesh is picked based on meshSelectionPredicate
  97800. */
  97801. onNewMeshPicked: Observable<PickingInfo>;
  97802. private _circleEase;
  97803. /**
  97804. * Observable raised before camera teleportation
  97805. */
  97806. onBeforeCameraTeleport: Observable<Vector3>;
  97807. /**
  97808. * Observable raised after camera teleportation
  97809. */
  97810. onAfterCameraTeleport: Observable<Vector3>;
  97811. /**
  97812. * Observable raised when current selected mesh gets unselected
  97813. */
  97814. onSelectedMeshUnselected: Observable<AbstractMesh>;
  97815. private _raySelectionPredicate;
  97816. /**
  97817. * To be optionaly changed by user to define custom ray selection
  97818. */
  97819. raySelectionPredicate: (mesh: AbstractMesh) => boolean;
  97820. /**
  97821. * To be optionaly changed by user to define custom selection logic (after ray selection)
  97822. */
  97823. meshSelectionPredicate: (mesh: AbstractMesh) => boolean;
  97824. /**
  97825. * Set teleportation enabled. If set to false camera teleportation will be disabled but camera rotation will be kept.
  97826. */
  97827. teleportationEnabled: boolean;
  97828. private _defaultHeight;
  97829. private _teleportationInitialized;
  97830. private _interactionsEnabled;
  97831. private _interactionsRequested;
  97832. private _displayGaze;
  97833. private _displayLaserPointer;
  97834. /**
  97835. * The mesh used to display where the user is going to teleport.
  97836. */
  97837. /**
  97838. * Sets the mesh to be used to display where the user is going to teleport.
  97839. */
  97840. teleportationTarget: Mesh;
  97841. /**
  97842. * 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
  97843. * when set bakeCurrentTransformIntoVertices will be called on the mesh.
  97844. * See http://doc.babylonjs.com/resources/baking_transformations
  97845. */
  97846. gazeTrackerMesh: Mesh;
  97847. /**
  97848. * If the gaze trackers scale should be updated to be constant size when pointing at near/far meshes
  97849. */
  97850. updateGazeTrackerScale: boolean;
  97851. /**
  97852. * If the gaze trackers color should be updated when selecting meshes
  97853. */
  97854. updateGazeTrackerColor: boolean;
  97855. /**
  97856. * The gaze tracking mesh corresponding to the left controller
  97857. */
  97858. readonly leftControllerGazeTrackerMesh: Nullable<Mesh>;
  97859. /**
  97860. * The gaze tracking mesh corresponding to the right controller
  97861. */
  97862. readonly rightControllerGazeTrackerMesh: Nullable<Mesh>;
  97863. /**
  97864. * If the ray of the gaze should be displayed.
  97865. */
  97866. /**
  97867. * Sets if the ray of the gaze should be displayed.
  97868. */
  97869. displayGaze: boolean;
  97870. /**
  97871. * If the ray of the LaserPointer should be displayed.
  97872. */
  97873. /**
  97874. * Sets if the ray of the LaserPointer should be displayed.
  97875. */
  97876. displayLaserPointer: boolean;
  97877. /**
  97878. * The deviceOrientationCamera used as the camera when not in VR.
  97879. */
  97880. readonly deviceOrientationCamera: Nullable<DeviceOrientationCamera>;
  97881. /**
  97882. * Based on the current WebVR support, returns the current VR camera used.
  97883. */
  97884. readonly currentVRCamera: Nullable<Camera>;
  97885. /**
  97886. * The webVRCamera which is used when in VR.
  97887. */
  97888. readonly webVRCamera: WebVRFreeCamera;
  97889. /**
  97890. * The deviceOrientationCamera that is used as a fallback when vr device is not connected.
  97891. */
  97892. readonly vrDeviceOrientationCamera: Nullable<VRDeviceOrientationFreeCamera>;
  97893. private readonly _teleportationRequestInitiated;
  97894. /**
  97895. * Defines wether or not Pointer lock should be requested when switching to
  97896. * full screen.
  97897. */
  97898. requestPointerLockOnFullScreen: boolean;
  97899. /**
  97900. * Instantiates a VRExperienceHelper.
  97901. * Helps to quickly add VR support to an existing scene.
  97902. * @param scene The scene the VRExperienceHelper belongs to.
  97903. * @param webVROptions Options to modify the vr experience helper's behavior.
  97904. */
  97905. constructor(scene: Scene,
  97906. /** Options to modify the vr experience helper's behavior. */
  97907. webVROptions?: VRExperienceHelperOptions);
  97908. private _onDefaultMeshLoaded;
  97909. private _onResize;
  97910. private _onFullscreenChange;
  97911. /**
  97912. * Gets a value indicating if we are currently in VR mode.
  97913. */
  97914. readonly isInVRMode: boolean;
  97915. private onVrDisplayPresentChange;
  97916. private onVRDisplayChanged;
  97917. private moveButtonToBottomRight;
  97918. private displayVRButton;
  97919. private updateButtonVisibility;
  97920. private _cachedAngularSensibility;
  97921. /**
  97922. * Attempt to enter VR. If a headset is connected and ready, will request present on that.
  97923. * Otherwise, will use the fullscreen API.
  97924. */
  97925. enterVR(): void;
  97926. /**
  97927. * Attempt to exit VR, or fullscreen.
  97928. */
  97929. exitVR(): void;
  97930. /**
  97931. * The position of the vr experience helper.
  97932. */
  97933. /**
  97934. * Sets the position of the vr experience helper.
  97935. */
  97936. position: Vector3;
  97937. /**
  97938. * Enables controllers and user interactions such as selecting and object or clicking on an object.
  97939. */
  97940. enableInteractions(): void;
  97941. private readonly _noControllerIsActive;
  97942. private beforeRender;
  97943. private _isTeleportationFloor;
  97944. /**
  97945. * Adds a floor mesh to be used for teleportation.
  97946. * @param floorMesh the mesh to be used for teleportation.
  97947. */
  97948. addFloorMesh(floorMesh: Mesh): void;
  97949. /**
  97950. * Removes a floor mesh from being used for teleportation.
  97951. * @param floorMesh the mesh to be removed.
  97952. */
  97953. removeFloorMesh(floorMesh: Mesh): void;
  97954. /**
  97955. * Enables interactions and teleportation using the VR controllers and gaze.
  97956. * @param vrTeleportationOptions options to modify teleportation behavior.
  97957. */
  97958. enableTeleportation(vrTeleportationOptions?: VRTeleportationOptions): void;
  97959. private _onNewGamepadConnected;
  97960. private _tryEnableInteractionOnController;
  97961. private _onNewGamepadDisconnected;
  97962. private _enableInteractionOnController;
  97963. private _checkTeleportWithRay;
  97964. private _checkRotate;
  97965. private _checkTeleportBackwards;
  97966. private _enableTeleportationOnController;
  97967. private _createTeleportationCircles;
  97968. private _displayTeleportationTarget;
  97969. private _hideTeleportationTarget;
  97970. private _rotateCamera;
  97971. private _moveTeleportationSelectorTo;
  97972. private _workingVector;
  97973. private _workingQuaternion;
  97974. private _workingMatrix;
  97975. /**
  97976. * Teleports the users feet to the desired location
  97977. * @param location The location where the user's feet should be placed
  97978. */
  97979. teleportCamera(location: Vector3): void;
  97980. private _convertNormalToDirectionOfRay;
  97981. private _castRayAndSelectObject;
  97982. private _notifySelectedMeshUnselected;
  97983. /**
  97984. * Sets the color of the laser ray from the vr controllers.
  97985. * @param color new color for the ray.
  97986. */
  97987. changeLaserColor(color: Color3): void;
  97988. /**
  97989. * Sets the color of the ray from the vr headsets gaze.
  97990. * @param color new color for the ray.
  97991. */
  97992. changeGazeColor(color: Color3): void;
  97993. /**
  97994. * Exits VR and disposes of the vr experience helper
  97995. */
  97996. dispose(): void;
  97997. /**
  97998. * Gets the name of the VRExperienceHelper class
  97999. * @returns "VRExperienceHelper"
  98000. */
  98001. getClassName(): string;
  98002. }
  98003. }
  98004. declare module BABYLON {
  98005. /**
  98006. * Manages an XRSession
  98007. * @see https://doc.babylonjs.com/how_to/webxr
  98008. */
  98009. export class WebXRSessionManager implements IDisposable {
  98010. private scene;
  98011. /**
  98012. * Fires every time a new xrFrame arrives which can be used to update the camera
  98013. */
  98014. onXRFrameObservable: Observable<any>;
  98015. /**
  98016. * Fires when the xr session is ended either by the device or manually done
  98017. */
  98018. onXRSessionEnded: Observable<any>;
  98019. /** @hidden */
  98020. _xrSession: XRSession;
  98021. /** @hidden */
  98022. _frameOfReference: XRFrameOfReference;
  98023. /** @hidden */
  98024. _sessionRenderTargetTexture: Nullable<RenderTargetTexture>;
  98025. /** @hidden */
  98026. _currentXRFrame: Nullable<XRFrame>;
  98027. private _xrNavigator;
  98028. private _xrDevice;
  98029. private _tmpMatrix;
  98030. /**
  98031. * Constructs a WebXRSessionManager, this must be initialized within a user action before usage
  98032. * @param scene The scene which the session should be created for
  98033. */
  98034. constructor(scene: Scene);
  98035. /**
  98036. * Initializes the manager
  98037. * After initialization enterXR can be called to start an XR session
  98038. * @returns Promise which resolves after it is initialized
  98039. */
  98040. initializeAsync(): Promise<void>;
  98041. /**
  98042. * Enters XR with the desired XR session options, this must be done with a user action (eg. button click event)
  98043. * @param sessionCreationOptions xr options to create the session with
  98044. * @param frameOfReferenceType option to configure how the xr pose is expressed
  98045. * @returns Promise which resolves after it enters XR
  98046. */
  98047. enterXRAsync(sessionCreationOptions: XRSessionCreationOptions, frameOfReferenceType: string): Promise<void>;
  98048. /**
  98049. * Stops the xrSession and restores the renderloop
  98050. * @returns Promise which resolves after it exits XR
  98051. */
  98052. exitXRAsync(): Promise<void>;
  98053. /**
  98054. * Fires a ray and returns the closest hit in the xr sessions enviornment, useful to place objects in AR
  98055. * @param ray ray to cast into the environment
  98056. * @returns Promise which resolves with a collision point in the environment if it exists
  98057. */
  98058. environmentPointHitTestAsync(ray: Ray): Promise<Nullable<Vector3>>;
  98059. /**
  98060. * Checks if a session would be supported for the creation options specified
  98061. * @param options creation options to check if they are supported
  98062. * @returns true if supported
  98063. */
  98064. supportsSessionAsync(options: XRSessionCreationOptions): Promise<boolean>;
  98065. /**
  98066. * @hidden
  98067. * Converts the render layer of xrSession to a render target
  98068. * @param session session to create render target for
  98069. * @param scene scene the new render target should be created for
  98070. */
  98071. static _CreateRenderTargetTextureFromSession(session: XRSession, scene: Scene): RenderTargetTexture;
  98072. /**
  98073. * Disposes of the session manager
  98074. */
  98075. dispose(): void;
  98076. }
  98077. }
  98078. declare module BABYLON {
  98079. /**
  98080. * WebXR Camera which holds the views for the xrSession
  98081. * @see https://doc.babylonjs.com/how_to/webxr
  98082. */
  98083. export class WebXRCamera extends FreeCamera {
  98084. private static _TmpMatrix;
  98085. /**
  98086. * Creates a new webXRCamera, this should only be set at the camera after it has been updated by the xrSessionManager
  98087. * @param name the name of the camera
  98088. * @param scene the scene to add the camera to
  98089. */
  98090. constructor(name: string, scene: Scene);
  98091. private _updateNumberOfRigCameras;
  98092. /** @hidden */
  98093. _updateForDualEyeDebugging(pupilDistance?: number): void;
  98094. /**
  98095. * Updates the cameras position from the current pose information of the XR session
  98096. * @param xrSessionManager the session containing pose information
  98097. * @returns true if the camera has been updated, false if the session did not contain pose or frame data
  98098. */
  98099. updateFromXRSessionManager(xrSessionManager: WebXRSessionManager): boolean;
  98100. }
  98101. }
  98102. declare module BABYLON {
  98103. /**
  98104. * States of the webXR experience
  98105. */
  98106. export enum WebXRState {
  98107. /**
  98108. * Transitioning to being in XR mode
  98109. */
  98110. ENTERING_XR = 0,
  98111. /**
  98112. * Transitioning to non XR mode
  98113. */
  98114. EXITING_XR = 1,
  98115. /**
  98116. * In XR mode and presenting
  98117. */
  98118. IN_XR = 2,
  98119. /**
  98120. * Not entered XR mode
  98121. */
  98122. NOT_IN_XR = 3
  98123. }
  98124. /**
  98125. * Helper class used to enable XR
  98126. * @see https://doc.babylonjs.com/how_to/webxr
  98127. */
  98128. export class WebXRExperienceHelper implements IDisposable {
  98129. private scene;
  98130. /**
  98131. * 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
  98132. */
  98133. container: AbstractMesh;
  98134. /**
  98135. * Camera used to render xr content
  98136. */
  98137. camera: WebXRCamera;
  98138. /**
  98139. * The current state of the XR experience (eg. transitioning, in XR or not in XR)
  98140. */
  98141. state: WebXRState;
  98142. private _setState;
  98143. private static _TmpVector;
  98144. /**
  98145. * Fires when the state of the experience helper has changed
  98146. */
  98147. onStateChangedObservable: Observable<WebXRState>;
  98148. /** @hidden */
  98149. _sessionManager: WebXRSessionManager;
  98150. private _nonVRCamera;
  98151. private _originalSceneAutoClear;
  98152. private _supported;
  98153. /**
  98154. * Creates the experience helper
  98155. * @param scene the scene to attach the experience helper to
  98156. * @returns a promise for the experience helper
  98157. */
  98158. static CreateAsync(scene: Scene): Promise<WebXRExperienceHelper>;
  98159. /**
  98160. * Creates a WebXRExperienceHelper
  98161. * @param scene The scene the helper should be created in
  98162. */
  98163. private constructor();
  98164. /**
  98165. * Exits XR mode and returns the scene to its original state
  98166. * @returns promise that resolves after xr mode has exited
  98167. */
  98168. exitXRAsync(): Promise<void>;
  98169. /**
  98170. * Enters XR mode (This must be done within a user interaction in most browsers eg. button click)
  98171. * @param sessionCreationOptions options for the XR session
  98172. * @param frameOfReference frame of reference of the XR session
  98173. * @returns promise that resolves after xr mode has entered
  98174. */
  98175. enterXRAsync(sessionCreationOptions: XRSessionCreationOptions, frameOfReference: string): Promise<void>;
  98176. /**
  98177. * Fires a ray and returns the closest hit in the xr sessions enviornment, useful to place objects in AR
  98178. * @param ray ray to cast into the environment
  98179. * @returns Promise which resolves with a collision point in the environment if it exists
  98180. */
  98181. environmentPointHitTestAsync(ray: Ray): Promise<Nullable<Vector3>>;
  98182. /**
  98183. * Updates the global position of the camera by moving the camera's container
  98184. * This should be used instead of modifying the camera's position as it will be overwritten by an xrSessions's update frame
  98185. * @param position The desired global position of the camera
  98186. */
  98187. setPositionOfCameraUsingContainer(position: Vector3): void;
  98188. /**
  98189. * Rotates the xr camera by rotating the camera's container around the camera's position
  98190. * This should be used instead of modifying the camera's rotation as it will be overwritten by an xrSessions's update frame
  98191. * @param rotation the desired quaternion rotation to apply to the camera
  98192. */
  98193. rotateCameraByQuaternionUsingContainer(rotation: Quaternion): void;
  98194. /**
  98195. * Checks if the creation options are supported by the xr session
  98196. * @param options creation options
  98197. * @returns true if supported
  98198. */
  98199. supportsSessionAsync(options: XRSessionCreationOptions): Promise<boolean>;
  98200. /**
  98201. * Disposes of the experience helper
  98202. */
  98203. dispose(): void;
  98204. }
  98205. }
  98206. declare module BABYLON {
  98207. /**
  98208. * Button which can be used to enter a different mode of XR
  98209. */
  98210. export class WebXREnterExitUIButton {
  98211. /** button element */
  98212. element: HTMLElement;
  98213. /** XR initialization options for the button */
  98214. initializationOptions: XRSessionCreationOptions;
  98215. /**
  98216. * Creates a WebXREnterExitUIButton
  98217. * @param element button element
  98218. * @param initializationOptions XR initialization options for the button
  98219. */
  98220. constructor(
  98221. /** button element */
  98222. element: HTMLElement,
  98223. /** XR initialization options for the button */
  98224. initializationOptions: XRSessionCreationOptions);
  98225. /**
  98226. * Overwritable function which can be used to update the button's visuals when the state changes
  98227. * @param activeButton the current active button in the UI
  98228. */
  98229. update(activeButton: Nullable<WebXREnterExitUIButton>): void;
  98230. }
  98231. /**
  98232. * Options to create the webXR UI
  98233. */
  98234. export class WebXREnterExitUIOptions {
  98235. /**
  98236. * Context to enter xr with
  98237. */
  98238. outputCanvasContext?: Nullable<WebGLRenderingContext>;
  98239. /**
  98240. * User provided buttons to enable/disable WebXR. The system will provide default if not set
  98241. */
  98242. customButtons?: Array<WebXREnterExitUIButton>;
  98243. }
  98244. /**
  98245. * UI to allow the user to enter/exit XR mode
  98246. */
  98247. export class WebXREnterExitUI implements IDisposable {
  98248. private scene;
  98249. private _overlay;
  98250. private _buttons;
  98251. private _activeButton;
  98252. /**
  98253. * Fired every time the active button is changed.
  98254. *
  98255. * When xr is entered via a button that launches xr that button will be the callback parameter
  98256. *
  98257. * When exiting xr the callback parameter will be null)
  98258. */
  98259. activeButtonChangedObservable: Observable<Nullable<WebXREnterExitUIButton>>;
  98260. /**
  98261. * Creates UI to allow the user to enter/exit XR mode
  98262. * @param scene the scene to add the ui to
  98263. * @param helper the xr experience helper to enter/exit xr with
  98264. * @param options options to configure the UI
  98265. * @returns the created ui
  98266. */
  98267. static CreateAsync(scene: Scene, helper: WebXRExperienceHelper, options: WebXREnterExitUIOptions): Promise<WebXREnterExitUI>;
  98268. private constructor();
  98269. private _updateButtons;
  98270. /**
  98271. * Disposes of the object
  98272. */
  98273. dispose(): void;
  98274. }
  98275. }
  98276. declare module BABYLON {
  98277. /**
  98278. * Represents an XR input
  98279. */
  98280. export class WebXRController {
  98281. /**
  98282. * 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
  98283. */
  98284. grip?: AbstractMesh;
  98285. /**
  98286. * Pointer which can be used to select objects or attach a visible laser to
  98287. */
  98288. pointer: AbstractMesh;
  98289. /**
  98290. * Creates the controller
  98291. * @see https://doc.babylonjs.com/how_to/webxr
  98292. * @param scene the scene which the controller should be associated to
  98293. */
  98294. constructor(scene: Scene);
  98295. /**
  98296. * Disposes of the object
  98297. */
  98298. dispose(): void;
  98299. }
  98300. /**
  98301. * XR input used to track XR inputs such as controllers/rays
  98302. */
  98303. export class WebXRInput implements IDisposable {
  98304. private helper;
  98305. /**
  98306. * XR controllers being tracked
  98307. */
  98308. controllers: Array<WebXRController>;
  98309. private _tmpMatrix;
  98310. private _frameObserver;
  98311. /**
  98312. * Initializes the WebXRInput
  98313. * @param helper experience helper which the input should be created for
  98314. */
  98315. constructor(helper: WebXRExperienceHelper);
  98316. /**
  98317. * Disposes of the object
  98318. */
  98319. dispose(): void;
  98320. }
  98321. }
  98322. declare module BABYLON {
  98323. /**
  98324. * Creates a canvas that is added/removed from the webpage when entering/exiting XR
  98325. */
  98326. export class WebXRManagedOutputCanvas implements IDisposable {
  98327. private _canvas;
  98328. /**
  98329. * xrpresent context of the canvas which can be used to display/mirror xr content
  98330. */
  98331. canvasContext: Nullable<WebGLRenderingContext>;
  98332. /**
  98333. * Initializes the canvas to be added/removed upon entering/exiting xr
  98334. * @param helper the xr experience helper used to trigger adding/removing of the canvas
  98335. * @param canvas The canvas to be added/removed (If not specified a full screen canvas will be created)
  98336. */
  98337. constructor(helper: WebXRExperienceHelper, canvas?: HTMLCanvasElement);
  98338. /**
  98339. * Disposes of the object
  98340. */
  98341. dispose(): void;
  98342. private _setManagedOutputCanvas;
  98343. private _addCanvas;
  98344. private _removeCanvas;
  98345. }
  98346. }
  98347. declare module BABYLON {
  98348. /**
  98349. * Contains an array of blocks representing the octree
  98350. */
  98351. export interface IOctreeContainer<T> {
  98352. /**
  98353. * Blocks within the octree
  98354. */
  98355. blocks: Array<OctreeBlock<T>>;
  98356. }
  98357. /**
  98358. * Class used to store a cell in an octree
  98359. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  98360. */
  98361. export class OctreeBlock<T> {
  98362. /**
  98363. * Gets the content of the current block
  98364. */
  98365. entries: T[];
  98366. /**
  98367. * Gets the list of block children
  98368. */
  98369. blocks: Array<OctreeBlock<T>>;
  98370. private _depth;
  98371. private _maxDepth;
  98372. private _capacity;
  98373. private _minPoint;
  98374. private _maxPoint;
  98375. private _boundingVectors;
  98376. private _creationFunc;
  98377. /**
  98378. * Creates a new block
  98379. * @param minPoint defines the minimum vector (in world space) of the block's bounding box
  98380. * @param maxPoint defines the maximum vector (in world space) of the block's bounding box
  98381. * @param capacity defines the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  98382. * @param depth defines the current depth of this block in the octree
  98383. * @param maxDepth defines the maximal depth allowed (beyond this value, the capacity is ignored)
  98384. * @param creationFunc defines a callback to call when an element is added to the block
  98385. */
  98386. constructor(minPoint: Vector3, maxPoint: Vector3, capacity: number, depth: number, maxDepth: number, creationFunc: (entry: T, block: OctreeBlock<T>) => void);
  98387. /**
  98388. * Gets the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  98389. */
  98390. readonly capacity: number;
  98391. /**
  98392. * Gets the minimum vector (in world space) of the block's bounding box
  98393. */
  98394. readonly minPoint: Vector3;
  98395. /**
  98396. * Gets the maximum vector (in world space) of the block's bounding box
  98397. */
  98398. readonly maxPoint: Vector3;
  98399. /**
  98400. * Add a new element to this block
  98401. * @param entry defines the element to add
  98402. */
  98403. addEntry(entry: T): void;
  98404. /**
  98405. * Remove an element from this block
  98406. * @param entry defines the element to remove
  98407. */
  98408. removeEntry(entry: T): void;
  98409. /**
  98410. * Add an array of elements to this block
  98411. * @param entries defines the array of elements to add
  98412. */
  98413. addEntries(entries: T[]): void;
  98414. /**
  98415. * Test if the current block intersects the furstum planes and if yes, then add its content to the selection array
  98416. * @param frustumPlanes defines the frustum planes to test
  98417. * @param selection defines the array to store current content if selection is positive
  98418. * @param allowDuplicate defines if the selection array can contains duplicated entries
  98419. */
  98420. select(frustumPlanes: Plane[], selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  98421. /**
  98422. * Test if the current block intersect with the given bounding sphere and if yes, then add its content to the selection array
  98423. * @param sphereCenter defines the bounding sphere center
  98424. * @param sphereRadius defines the bounding sphere radius
  98425. * @param selection defines the array to store current content if selection is positive
  98426. * @param allowDuplicate defines if the selection array can contains duplicated entries
  98427. */
  98428. intersects(sphereCenter: Vector3, sphereRadius: number, selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  98429. /**
  98430. * Test if the current block intersect with the given ray and if yes, then add its content to the selection array
  98431. * @param ray defines the ray to test with
  98432. * @param selection defines the array to store current content if selection is positive
  98433. */
  98434. intersectsRay(ray: Ray, selection: SmartArrayNoDuplicate<T>): void;
  98435. /**
  98436. * Subdivide the content into child blocks (this block will then be empty)
  98437. */
  98438. createInnerBlocks(): void;
  98439. /**
  98440. * @hidden
  98441. */
  98442. 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;
  98443. }
  98444. }
  98445. declare module BABYLON {
  98446. /**
  98447. * Octrees are a really powerful data structure that can quickly select entities based on space coordinates.
  98448. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  98449. */
  98450. export class Octree<T> {
  98451. /** 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.) */
  98452. maxDepth: number;
  98453. /**
  98454. * Blocks within the octree containing objects
  98455. */
  98456. blocks: Array<OctreeBlock<T>>;
  98457. /**
  98458. * Content stored in the octree
  98459. */
  98460. dynamicContent: T[];
  98461. private _maxBlockCapacity;
  98462. private _selectionContent;
  98463. private _creationFunc;
  98464. /**
  98465. * Creates a octree
  98466. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  98467. * @param creationFunc function to be used to instatiate the octree
  98468. * @param maxBlockCapacity defines the maximum number of meshes you want on your octree's leaves (default: 64)
  98469. * @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.)
  98470. */
  98471. constructor(creationFunc: (entry: T, block: OctreeBlock<T>) => void, maxBlockCapacity?: number,
  98472. /** 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.) */
  98473. maxDepth?: number);
  98474. /**
  98475. * Updates the octree by adding blocks for the passed in meshes within the min and max world parameters
  98476. * @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);
  98477. * @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);
  98478. * @param entries meshes to be added to the octree blocks
  98479. */
  98480. update(worldMin: Vector3, worldMax: Vector3, entries: T[]): void;
  98481. /**
  98482. * Adds a mesh to the octree
  98483. * @param entry Mesh to add to the octree
  98484. */
  98485. addMesh(entry: T): void;
  98486. /**
  98487. * Remove an element from the octree
  98488. * @param entry defines the element to remove
  98489. */
  98490. removeMesh(entry: T): void;
  98491. /**
  98492. * Selects an array of meshes within the frustum
  98493. * @param frustumPlanes The frustum planes to use which will select all meshes within it
  98494. * @param allowDuplicate If duplicate objects are allowed in the resulting object array
  98495. * @returns array of meshes within the frustum
  98496. */
  98497. select(frustumPlanes: Plane[], allowDuplicate?: boolean): SmartArray<T>;
  98498. /**
  98499. * Test if the octree intersect with the given bounding sphere and if yes, then add its content to the selection array
  98500. * @param sphereCenter defines the bounding sphere center
  98501. * @param sphereRadius defines the bounding sphere radius
  98502. * @param allowDuplicate defines if the selection array can contains duplicated entries
  98503. * @returns an array of objects that intersect the sphere
  98504. */
  98505. intersects(sphereCenter: Vector3, sphereRadius: number, allowDuplicate?: boolean): SmartArray<T>;
  98506. /**
  98507. * Test if the octree intersect with the given ray and if yes, then add its content to resulting array
  98508. * @param ray defines the ray to test with
  98509. * @returns array of intersected objects
  98510. */
  98511. intersectsRay(ray: Ray): SmartArray<T>;
  98512. /**
  98513. * Adds a mesh into the octree block if it intersects the block
  98514. */
  98515. static CreationFuncForMeshes: (entry: AbstractMesh, block: OctreeBlock<AbstractMesh>) => void;
  98516. /**
  98517. * Adds a submesh into the octree block if it intersects the block
  98518. */
  98519. static CreationFuncForSubMeshes: (entry: SubMesh, block: OctreeBlock<SubMesh>) => void;
  98520. }
  98521. }
  98522. declare module BABYLON {
  98523. interface Scene {
  98524. /**
  98525. * @hidden
  98526. * Backing Filed
  98527. */
  98528. _selectionOctree: Octree<AbstractMesh>;
  98529. /**
  98530. * Gets the octree used to boost mesh selection (picking)
  98531. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  98532. */
  98533. selectionOctree: Octree<AbstractMesh>;
  98534. /**
  98535. * Creates or updates the octree used to boost selection (picking)
  98536. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  98537. * @param maxCapacity defines the maximum capacity per leaf
  98538. * @param maxDepth defines the maximum depth of the octree
  98539. * @returns an octree of AbstractMesh
  98540. */
  98541. createOrUpdateSelectionOctree(maxCapacity?: number, maxDepth?: number): Octree<AbstractMesh>;
  98542. }
  98543. interface AbstractMesh {
  98544. /**
  98545. * @hidden
  98546. * Backing Field
  98547. */
  98548. _submeshesOctree: Octree<SubMesh>;
  98549. /**
  98550. * This function will create an octree to help to select the right submeshes for rendering, picking and collision computations.
  98551. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  98552. * @param maxCapacity defines the maximum size of each block (64 by default)
  98553. * @param maxDepth defines the maximum depth to use (no more than 2 levels by default)
  98554. * @returns the new octree
  98555. * @see https://www.babylonjs-playground.com/#NA4OQ#12
  98556. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  98557. */
  98558. createOrUpdateSubmeshesOctree(maxCapacity?: number, maxDepth?: number): Octree<SubMesh>;
  98559. }
  98560. /**
  98561. * Defines the octree scene component responsible to manage any octrees
  98562. * in a given scene.
  98563. */
  98564. export class OctreeSceneComponent {
  98565. /**
  98566. * The component name helpfull to identify the component in the list of scene components.
  98567. */
  98568. readonly name: string;
  98569. /**
  98570. * The scene the component belongs to.
  98571. */
  98572. scene: Scene;
  98573. /**
  98574. * Indicates if the meshes have been checked to make sure they are isEnabled()
  98575. */
  98576. readonly checksIsEnabled: boolean;
  98577. /**
  98578. * Creates a new instance of the component for the given scene
  98579. * @param scene Defines the scene to register the component in
  98580. */
  98581. constructor(scene: Scene);
  98582. /**
  98583. * Registers the component in a given scene
  98584. */
  98585. register(): void;
  98586. /**
  98587. * Return the list of active meshes
  98588. * @returns the list of active meshes
  98589. */
  98590. getActiveMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  98591. /**
  98592. * Return the list of active sub meshes
  98593. * @param mesh The mesh to get the candidates sub meshes from
  98594. * @returns the list of active sub meshes
  98595. */
  98596. getActiveSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  98597. private _tempRay;
  98598. /**
  98599. * Return the list of sub meshes intersecting with a given local ray
  98600. * @param mesh defines the mesh to find the submesh for
  98601. * @param localRay defines the ray in local space
  98602. * @returns the list of intersecting sub meshes
  98603. */
  98604. getIntersectingSubMeshCandidates(mesh: AbstractMesh, localRay: Ray): ISmartArrayLike<SubMesh>;
  98605. /**
  98606. * Return the list of sub meshes colliding with a collider
  98607. * @param mesh defines the mesh to find the submesh for
  98608. * @param collider defines the collider to evaluate the collision against
  98609. * @returns the list of colliding sub meshes
  98610. */
  98611. getCollidingSubMeshCandidates(mesh: AbstractMesh, collider: Collider): ISmartArrayLike<SubMesh>;
  98612. /**
  98613. * Rebuilds the elements related to this component in case of
  98614. * context lost for instance.
  98615. */
  98616. rebuild(): void;
  98617. /**
  98618. * Disposes the component and the associated ressources.
  98619. */
  98620. dispose(): void;
  98621. }
  98622. }
  98623. declare module BABYLON {
  98624. /**
  98625. * Class containing static functions to help procedurally build meshes
  98626. */
  98627. export class LinesBuilder {
  98628. /**
  98629. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  98630. * * 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
  98631. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  98632. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  98633. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  98634. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  98635. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  98636. * * 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
  98637. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  98638. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  98639. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  98640. * @param name defines the name of the new line system
  98641. * @param options defines the options used to create the line system
  98642. * @param scene defines the hosting scene
  98643. * @returns a new line system mesh
  98644. */
  98645. static CreateLineSystem(name: string, options: {
  98646. lines: Vector3[][];
  98647. updatable?: boolean;
  98648. instance?: Nullable<LinesMesh>;
  98649. colors?: Nullable<Color4[][]>;
  98650. useVertexAlpha?: boolean;
  98651. }, scene: Nullable<Scene>): LinesMesh;
  98652. /**
  98653. * Creates a line mesh
  98654. * 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
  98655. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  98656. * * The parameter `points` is an array successive Vector3
  98657. * * 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
  98658. * * The optional parameter `colors` is an array of successive Color4, one per line point
  98659. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  98660. * * When updating an instance, remember that only point positions can change, not the number of points
  98661. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  98662. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  98663. * @param name defines the name of the new line system
  98664. * @param options defines the options used to create the line system
  98665. * @param scene defines the hosting scene
  98666. * @returns a new line mesh
  98667. */
  98668. static CreateLines(name: string, options: {
  98669. points: Vector3[];
  98670. updatable?: boolean;
  98671. instance?: Nullable<LinesMesh>;
  98672. colors?: Color4[];
  98673. useVertexAlpha?: boolean;
  98674. }, scene?: Nullable<Scene>): LinesMesh;
  98675. /**
  98676. * Creates a dashed line mesh
  98677. * * 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
  98678. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  98679. * * The parameter `points` is an array successive Vector3
  98680. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  98681. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  98682. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  98683. * * 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
  98684. * * When updating an instance, remember that only point positions can change, not the number of points
  98685. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  98686. * @param name defines the name of the mesh
  98687. * @param options defines the options used to create the mesh
  98688. * @param scene defines the hosting scene
  98689. * @returns the dashed line mesh
  98690. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  98691. */
  98692. static CreateDashedLines(name: string, options: {
  98693. points: Vector3[];
  98694. dashSize?: number;
  98695. gapSize?: number;
  98696. dashNb?: number;
  98697. updatable?: boolean;
  98698. instance?: LinesMesh;
  98699. }, scene?: Nullable<Scene>): LinesMesh;
  98700. }
  98701. }
  98702. declare module BABYLON {
  98703. /**
  98704. * Renders a layer on top of an existing scene
  98705. */
  98706. export class UtilityLayerRenderer implements IDisposable {
  98707. /** the original scene that will be rendered on top of */
  98708. originalScene: Scene;
  98709. private _pointerCaptures;
  98710. private _lastPointerEvents;
  98711. private static _DefaultUtilityLayer;
  98712. private static _DefaultKeepDepthUtilityLayer;
  98713. /**
  98714. * If the picking should be done on the utility layer prior to the actual scene (Default: true)
  98715. */
  98716. pickUtilitySceneFirst: boolean;
  98717. /**
  98718. * 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)
  98719. */
  98720. static readonly DefaultUtilityLayer: UtilityLayerRenderer;
  98721. /**
  98722. * 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)
  98723. */
  98724. static readonly DefaultKeepDepthUtilityLayer: UtilityLayerRenderer;
  98725. /**
  98726. * The scene that is rendered on top of the original scene
  98727. */
  98728. utilityLayerScene: Scene;
  98729. /**
  98730. * If the utility layer should automatically be rendered on top of existing scene
  98731. */
  98732. shouldRender: boolean;
  98733. /**
  98734. * If set to true, only pointer down onPointerObservable events will be blocked when picking is occluded by original scene
  98735. */
  98736. onlyCheckPointerDownEvents: boolean;
  98737. /**
  98738. * If set to false, only pointerUp, pointerDown and pointerMove will be sent to the utilityLayerScene (false by default)
  98739. */
  98740. processAllEvents: boolean;
  98741. /**
  98742. * Observable raised when the pointer move from the utility layer scene to the main scene
  98743. */
  98744. onPointerOutObservable: Observable<number>;
  98745. /** Gets or sets a predicate that will be used to indicate utility meshes present in the main scene */
  98746. mainSceneTrackerPredicate: (mesh: Nullable<AbstractMesh>) => boolean;
  98747. private _afterRenderObserver;
  98748. private _sceneDisposeObserver;
  98749. private _originalPointerObserver;
  98750. /**
  98751. * Instantiates a UtilityLayerRenderer
  98752. * @param originalScene the original scene that will be rendered on top of
  98753. * @param handleEvents boolean indicating if the utility layer should handle events
  98754. */
  98755. constructor(
  98756. /** the original scene that will be rendered on top of */
  98757. originalScene: Scene, handleEvents?: boolean);
  98758. private _notifyObservers;
  98759. /**
  98760. * Renders the utility layers scene on top of the original scene
  98761. */
  98762. render(): void;
  98763. /**
  98764. * Disposes of the renderer
  98765. */
  98766. dispose(): void;
  98767. private _updateCamera;
  98768. }
  98769. }
  98770. declare module BABYLON {
  98771. /**
  98772. * Renders gizmos on top of an existing scene which provide controls for position, rotation, etc.
  98773. */
  98774. export class Gizmo implements IDisposable {
  98775. /** The utility layer the gizmo will be added to */
  98776. gizmoLayer: UtilityLayerRenderer;
  98777. /**
  98778. * The root mesh of the gizmo
  98779. */
  98780. _rootMesh: Mesh;
  98781. private _attachedMesh;
  98782. /**
  98783. * Ratio for the scale of the gizmo (Default: 1)
  98784. */
  98785. scaleRatio: number;
  98786. private _tmpMatrix;
  98787. /**
  98788. * If a custom mesh has been set (Default: false)
  98789. */
  98790. protected _customMeshSet: boolean;
  98791. /**
  98792. * Mesh that the gizmo will be attached to. (eg. on a drag gizmo the mesh that will be dragged)
  98793. * * When set, interactions will be enabled
  98794. */
  98795. attachedMesh: Nullable<AbstractMesh>;
  98796. /**
  98797. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  98798. * @param mesh The mesh to replace the default mesh of the gizmo
  98799. */
  98800. setCustomMesh(mesh: Mesh): void;
  98801. /**
  98802. * If set the gizmo's rotation will be updated to match the attached mesh each frame (Default: true)
  98803. */
  98804. updateGizmoRotationToMatchAttachedMesh: boolean;
  98805. /**
  98806. * If set the gizmo's position will be updated to match the attached mesh each frame (Default: true)
  98807. */
  98808. updateGizmoPositionToMatchAttachedMesh: boolean;
  98809. /**
  98810. * When set, the gizmo will always appear the same size no matter where the camera is (default: false)
  98811. */
  98812. protected _updateScale: boolean;
  98813. protected _interactionsEnabled: boolean;
  98814. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  98815. private _beforeRenderObserver;
  98816. /**
  98817. * Creates a gizmo
  98818. * @param gizmoLayer The utility layer the gizmo will be added to
  98819. */
  98820. constructor(
  98821. /** The utility layer the gizmo will be added to */
  98822. gizmoLayer?: UtilityLayerRenderer);
  98823. private _tempVector;
  98824. /**
  98825. * @hidden
  98826. * Updates the gizmo to match the attached mesh's position/rotation
  98827. */
  98828. protected _update(): void;
  98829. /**
  98830. * Disposes of the gizmo
  98831. */
  98832. dispose(): void;
  98833. }
  98834. }
  98835. declare module BABYLON {
  98836. /**
  98837. * Single axis drag gizmo
  98838. */
  98839. export class AxisDragGizmo extends Gizmo {
  98840. /**
  98841. * Drag behavior responsible for the gizmos dragging interactions
  98842. */
  98843. dragBehavior: PointerDragBehavior;
  98844. private _pointerObserver;
  98845. /**
  98846. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  98847. */
  98848. snapDistance: number;
  98849. /**
  98850. * Event that fires each time the gizmo snaps to a new location.
  98851. * * snapDistance is the the change in distance
  98852. */
  98853. onSnapObservable: Observable<{
  98854. snapDistance: number;
  98855. }>;
  98856. /** @hidden */
  98857. static _CreateArrow(scene: Scene, material: StandardMaterial): TransformNode;
  98858. /** @hidden */
  98859. static _CreateArrowInstance(scene: Scene, arrow: TransformNode): TransformNode;
  98860. /**
  98861. * Creates an AxisDragGizmo
  98862. * @param gizmoLayer The utility layer the gizmo will be added to
  98863. * @param dragAxis The axis which the gizmo will be able to drag on
  98864. * @param color The color of the gizmo
  98865. */
  98866. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer);
  98867. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  98868. /**
  98869. * Disposes of the gizmo
  98870. */
  98871. dispose(): void;
  98872. }
  98873. }
  98874. declare module BABYLON.Debug {
  98875. /**
  98876. * The Axes viewer will show 3 axes in a specific point in space
  98877. */
  98878. export class AxesViewer {
  98879. private _xAxis;
  98880. private _yAxis;
  98881. private _zAxis;
  98882. private _scaleLinesFactor;
  98883. private _instanced;
  98884. /**
  98885. * Gets the hosting scene
  98886. */
  98887. scene: Scene;
  98888. /**
  98889. * Gets or sets a number used to scale line length
  98890. */
  98891. scaleLines: number;
  98892. /** Gets the node hierarchy used to render x-axis */
  98893. readonly xAxis: TransformNode;
  98894. /** Gets the node hierarchy used to render y-axis */
  98895. readonly yAxis: TransformNode;
  98896. /** Gets the node hierarchy used to render z-axis */
  98897. readonly zAxis: TransformNode;
  98898. /**
  98899. * Creates a new AxesViewer
  98900. * @param scene defines the hosting scene
  98901. * @param scaleLines defines a number used to scale line length (1 by default)
  98902. * @param renderingGroupId defines a number used to set the renderingGroupId of the meshes (2 by default)
  98903. * @param xAxis defines the node hierarchy used to render the x-axis
  98904. * @param yAxis defines the node hierarchy used to render the y-axis
  98905. * @param zAxis defines the node hierarchy used to render the z-axis
  98906. */
  98907. constructor(scene: Scene, scaleLines?: number, renderingGroupId?: Nullable<number>, xAxis?: TransformNode, yAxis?: TransformNode, zAxis?: TransformNode);
  98908. /**
  98909. * Force the viewer to update
  98910. * @param position defines the position of the viewer
  98911. * @param xaxis defines the x axis of the viewer
  98912. * @param yaxis defines the y axis of the viewer
  98913. * @param zaxis defines the z axis of the viewer
  98914. */
  98915. update(position: Vector3, xaxis: Vector3, yaxis: Vector3, zaxis: Vector3): void;
  98916. /**
  98917. * Creates an instance of this axes viewer.
  98918. * @returns a new axes viewer with instanced meshes
  98919. */
  98920. createInstance(): AxesViewer;
  98921. /** Releases resources */
  98922. dispose(): void;
  98923. private static _SetRenderingGroupId;
  98924. }
  98925. }
  98926. declare module BABYLON.Debug {
  98927. /**
  98928. * The BoneAxesViewer will attach 3 axes to a specific bone of a specific mesh
  98929. * @see demo here: https://www.babylonjs-playground.com/#0DE8F4#8
  98930. */
  98931. export class BoneAxesViewer extends AxesViewer {
  98932. /**
  98933. * Gets or sets the target mesh where to display the axes viewer
  98934. */
  98935. mesh: Nullable<Mesh>;
  98936. /**
  98937. * Gets or sets the target bone where to display the axes viewer
  98938. */
  98939. bone: Nullable<Bone>;
  98940. /** Gets current position */
  98941. pos: Vector3;
  98942. /** Gets direction of X axis */
  98943. xaxis: Vector3;
  98944. /** Gets direction of Y axis */
  98945. yaxis: Vector3;
  98946. /** Gets direction of Z axis */
  98947. zaxis: Vector3;
  98948. /**
  98949. * Creates a new BoneAxesViewer
  98950. * @param scene defines the hosting scene
  98951. * @param bone defines the target bone
  98952. * @param mesh defines the target mesh
  98953. * @param scaleLines defines a scaling factor for line length (1 by default)
  98954. */
  98955. constructor(scene: Scene, bone: Bone, mesh: Mesh, scaleLines?: number);
  98956. /**
  98957. * Force the viewer to update
  98958. */
  98959. update(): void;
  98960. /** Releases resources */
  98961. dispose(): void;
  98962. }
  98963. }
  98964. declare module BABYLON {
  98965. /**
  98966. * Interface used to define scene explorer extensibility option
  98967. */
  98968. export interface IExplorerExtensibilityOption {
  98969. /**
  98970. * Define the option label
  98971. */
  98972. label: string;
  98973. /**
  98974. * Defines the action to execute on click
  98975. */
  98976. action: (entity: any) => void;
  98977. }
  98978. /**
  98979. * Defines a group of actions associated with a predicate to use when extending the Inspector scene explorer
  98980. */
  98981. export interface IExplorerExtensibilityGroup {
  98982. /**
  98983. * Defines a predicate to test if a given type mut be extended
  98984. */
  98985. predicate: (entity: any) => boolean;
  98986. /**
  98987. * Gets the list of options added to a type
  98988. */
  98989. entries: IExplorerExtensibilityOption[];
  98990. }
  98991. /**
  98992. * Interface used to define the options to use to create the Inspector
  98993. */
  98994. export interface IInspectorOptions {
  98995. /**
  98996. * Display in overlay mode (default: false)
  98997. */
  98998. overlay?: boolean;
  98999. /**
  99000. * HTML element to use as root (the parent of the rendering canvas will be used as default value)
  99001. */
  99002. globalRoot?: HTMLElement;
  99003. /**
  99004. * Display the Scene explorer
  99005. */
  99006. showExplorer?: boolean;
  99007. /**
  99008. * Display the property inspector
  99009. */
  99010. showInspector?: boolean;
  99011. /**
  99012. * Display in embed mode (both panes on the right)
  99013. */
  99014. embedMode?: boolean;
  99015. /**
  99016. * let the Inspector handles resize of the canvas when panes are resized (default to true)
  99017. */
  99018. handleResize?: boolean;
  99019. /**
  99020. * Allow the panes to popup (default: true)
  99021. */
  99022. enablePopup?: boolean;
  99023. /**
  99024. * Allow the panes to be closed by users (default: true)
  99025. */
  99026. enableClose?: boolean;
  99027. /**
  99028. * Optional list of extensibility entries
  99029. */
  99030. explorerExtensibility?: IExplorerExtensibilityGroup[];
  99031. /**
  99032. * Optional URL to get the inspector script from (by default it uses the babylonjs CDN).
  99033. */
  99034. inspectorURL?: string;
  99035. }
  99036. interface Scene {
  99037. /**
  99038. * @hidden
  99039. * Backing field
  99040. */
  99041. _debugLayer: DebugLayer;
  99042. /**
  99043. * Gets the debug layer (aka Inspector) associated with the scene
  99044. * @see http://doc.babylonjs.com/features/playground_debuglayer
  99045. */
  99046. debugLayer: DebugLayer;
  99047. }
  99048. /**
  99049. * The debug layer (aka Inspector) is the go to tool in order to better understand
  99050. * what is happening in your scene
  99051. * @see http://doc.babylonjs.com/features/playground_debuglayer
  99052. */
  99053. export class DebugLayer {
  99054. /**
  99055. * Define the url to get the inspector script from.
  99056. * By default it uses the babylonjs CDN.
  99057. * @ignoreNaming
  99058. */
  99059. static InspectorURL: string;
  99060. private _scene;
  99061. private BJSINSPECTOR;
  99062. /**
  99063. * Observable triggered when a property is changed through the inspector.
  99064. */
  99065. onPropertyChangedObservable: Observable<{
  99066. object: any;
  99067. property: string;
  99068. value: any;
  99069. initialValue: any;
  99070. }>;
  99071. /**
  99072. * Instantiates a new debug layer.
  99073. * The debug layer (aka Inspector) is the go to tool in order to better understand
  99074. * what is happening in your scene
  99075. * @see http://doc.babylonjs.com/features/playground_debuglayer
  99076. * @param scene Defines the scene to inspect
  99077. */
  99078. constructor(scene: Scene);
  99079. /** Creates the inspector window. */
  99080. private _createInspector;
  99081. /**
  99082. * Select a specific entity in the scene explorer and highlight a specific block in that entity property grid
  99083. * @param entity defines the entity to select
  99084. * @param lineContainerTitle defines the specific block to highlight
  99085. */
  99086. select(entity: any, lineContainerTitle?: string): void;
  99087. /** Get the inspector from bundle or global */
  99088. private _getGlobalInspector;
  99089. /**
  99090. * Get if the inspector is visible or not.
  99091. * @returns true if visible otherwise, false
  99092. */
  99093. isVisible(): boolean;
  99094. /**
  99095. * Hide the inspector and close its window.
  99096. */
  99097. hide(): void;
  99098. /**
  99099. * Launch the debugLayer.
  99100. * @param config Define the configuration of the inspector
  99101. * @return a promise fulfilled when the debug layer is visible
  99102. */
  99103. show(config?: IInspectorOptions): Promise<DebugLayer>;
  99104. }
  99105. }
  99106. declare module BABYLON {
  99107. /**
  99108. * Class containing static functions to help procedurally build meshes
  99109. */
  99110. export class BoxBuilder {
  99111. /**
  99112. * Creates a box mesh
  99113. * * The parameter `size` sets the size (float) of each box side (default 1)
  99114. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  99115. * * 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)
  99116. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  99117. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  99118. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  99119. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  99120. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  99121. * @param name defines the name of the mesh
  99122. * @param options defines the options used to create the mesh
  99123. * @param scene defines the hosting scene
  99124. * @returns the box mesh
  99125. */
  99126. static CreateBox(name: string, options: {
  99127. size?: number;
  99128. width?: number;
  99129. height?: number;
  99130. depth?: number;
  99131. faceUV?: Vector4[];
  99132. faceColors?: Color4[];
  99133. sideOrientation?: number;
  99134. frontUVs?: Vector4;
  99135. backUVs?: Vector4;
  99136. updatable?: boolean;
  99137. }, scene?: Nullable<Scene>): Mesh;
  99138. }
  99139. }
  99140. declare module BABYLON {
  99141. /**
  99142. * Class containing static functions to help procedurally build meshes
  99143. */
  99144. export class SphereBuilder {
  99145. /**
  99146. * Creates a sphere mesh
  99147. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  99148. * * 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`)
  99149. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  99150. * * 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
  99151. * * 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)
  99152. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  99153. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  99154. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  99155. * @param name defines the name of the mesh
  99156. * @param options defines the options used to create the mesh
  99157. * @param scene defines the hosting scene
  99158. * @returns the sphere mesh
  99159. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  99160. */
  99161. static CreateSphere(name: string, options: {
  99162. segments?: number;
  99163. diameter?: number;
  99164. diameterX?: number;
  99165. diameterY?: number;
  99166. diameterZ?: number;
  99167. arc?: number;
  99168. slice?: number;
  99169. sideOrientation?: number;
  99170. frontUVs?: Vector4;
  99171. backUVs?: Vector4;
  99172. updatable?: boolean;
  99173. }, scene: any): Mesh;
  99174. }
  99175. }
  99176. declare module BABYLON.Debug {
  99177. /**
  99178. * Used to show the physics impostor around the specific mesh
  99179. */
  99180. export class PhysicsViewer {
  99181. /** @hidden */
  99182. protected _impostors: Array<Nullable<PhysicsImpostor>>;
  99183. /** @hidden */
  99184. protected _meshes: Array<Nullable<AbstractMesh>>;
  99185. /** @hidden */
  99186. protected _scene: Nullable<Scene>;
  99187. /** @hidden */
  99188. protected _numMeshes: number;
  99189. /** @hidden */
  99190. protected _physicsEnginePlugin: Nullable<IPhysicsEnginePlugin>;
  99191. private _renderFunction;
  99192. private _utilityLayer;
  99193. private _debugBoxMesh;
  99194. private _debugSphereMesh;
  99195. private _debugMaterial;
  99196. /**
  99197. * Creates a new PhysicsViewer
  99198. * @param scene defines the hosting scene
  99199. */
  99200. constructor(scene: Scene);
  99201. /** @hidden */
  99202. protected _updateDebugMeshes(): void;
  99203. /**
  99204. * Renders a specified physic impostor
  99205. * @param impostor defines the impostor to render
  99206. * @returns the new debug mesh used to render the impostor
  99207. */
  99208. showImpostor(impostor: PhysicsImpostor): Nullable<AbstractMesh>;
  99209. /**
  99210. * Hides a specified physic impostor
  99211. * @param impostor defines the impostor to hide
  99212. */
  99213. hideImpostor(impostor: Nullable<PhysicsImpostor>): void;
  99214. private _getDebugMaterial;
  99215. private _getDebugBoxMesh;
  99216. private _getDebugSphereMesh;
  99217. private _getDebugMesh;
  99218. /** Releases all resources */
  99219. dispose(): void;
  99220. }
  99221. }
  99222. declare module BABYLON {
  99223. /**
  99224. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  99225. * in order to better appreciate the issue one might have.
  99226. * @see http://doc.babylonjs.com/babylon101/raycasts#debugging
  99227. */
  99228. export class RayHelper {
  99229. /**
  99230. * Defines the ray we are currently tryin to visualize.
  99231. */
  99232. ray: Nullable<Ray>;
  99233. private _renderPoints;
  99234. private _renderLine;
  99235. private _renderFunction;
  99236. private _scene;
  99237. private _updateToMeshFunction;
  99238. private _attachedToMesh;
  99239. private _meshSpaceDirection;
  99240. private _meshSpaceOrigin;
  99241. /**
  99242. * Helper function to create a colored helper in a scene in one line.
  99243. * @param ray Defines the ray we are currently tryin to visualize
  99244. * @param scene Defines the scene the ray is used in
  99245. * @param color Defines the color we want to see the ray in
  99246. * @returns The newly created ray helper.
  99247. */
  99248. static CreateAndShow(ray: Ray, scene: Scene, color: Color3): RayHelper;
  99249. /**
  99250. * Instantiate a new ray helper.
  99251. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  99252. * in order to better appreciate the issue one might have.
  99253. * @see http://doc.babylonjs.com/babylon101/raycasts#debugging
  99254. * @param ray Defines the ray we are currently tryin to visualize
  99255. */
  99256. constructor(ray: Ray);
  99257. /**
  99258. * Shows the ray we are willing to debug.
  99259. * @param scene Defines the scene the ray needs to be rendered in
  99260. * @param color Defines the color the ray needs to be rendered in
  99261. */
  99262. show(scene: Scene, color?: Color3): void;
  99263. /**
  99264. * Hides the ray we are debugging.
  99265. */
  99266. hide(): void;
  99267. private _render;
  99268. /**
  99269. * Attach a ray helper to a mesh so that we can easily see its orientation for instance or information like its normals.
  99270. * @param mesh Defines the mesh we want the helper attached to
  99271. * @param meshSpaceDirection Defines the direction of the Ray in mesh space (local space of the mesh node)
  99272. * @param meshSpaceOrigin Defines the origin of the Ray in mesh space (local space of the mesh node)
  99273. * @param length Defines the length of the ray
  99274. */
  99275. attachToMesh(mesh: AbstractMesh, meshSpaceDirection?: Vector3, meshSpaceOrigin?: Vector3, length?: number): void;
  99276. /**
  99277. * Detach the ray helper from the mesh it has previously been attached to.
  99278. */
  99279. detachFromMesh(): void;
  99280. private _updateToMesh;
  99281. /**
  99282. * Dispose the helper and release its associated resources.
  99283. */
  99284. dispose(): void;
  99285. }
  99286. }
  99287. declare module BABYLON.Debug {
  99288. /**
  99289. * Class used to render a debug view of a given skeleton
  99290. * @see http://www.babylonjs-playground.com/#1BZJVJ#8
  99291. */
  99292. export class SkeletonViewer {
  99293. /** defines the skeleton to render */
  99294. skeleton: Skeleton;
  99295. /** defines the mesh attached to the skeleton */
  99296. mesh: AbstractMesh;
  99297. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  99298. autoUpdateBonesMatrices: boolean;
  99299. /** defines the rendering group id to use with the viewer */
  99300. renderingGroupId: number;
  99301. /** Gets or sets the color used to render the skeleton */
  99302. color: Color3;
  99303. private _scene;
  99304. private _debugLines;
  99305. private _debugMesh;
  99306. private _isEnabled;
  99307. private _renderFunction;
  99308. private _utilityLayer;
  99309. /**
  99310. * Returns the mesh used to render the bones
  99311. */
  99312. readonly debugMesh: Nullable<LinesMesh>;
  99313. /**
  99314. * Creates a new SkeletonViewer
  99315. * @param skeleton defines the skeleton to render
  99316. * @param mesh defines the mesh attached to the skeleton
  99317. * @param scene defines the hosting scene
  99318. * @param autoUpdateBonesMatrices defines a boolean indicating if bones matrices must be forced to update before rendering (true by default)
  99319. * @param renderingGroupId defines the rendering group id to use with the viewer
  99320. */
  99321. constructor(
  99322. /** defines the skeleton to render */
  99323. skeleton: Skeleton,
  99324. /** defines the mesh attached to the skeleton */
  99325. mesh: AbstractMesh, scene: Scene,
  99326. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  99327. autoUpdateBonesMatrices?: boolean,
  99328. /** defines the rendering group id to use with the viewer */
  99329. renderingGroupId?: number);
  99330. /** Gets or sets a boolean indicating if the viewer is enabled */
  99331. isEnabled: boolean;
  99332. private _getBonePosition;
  99333. private _getLinesForBonesWithLength;
  99334. private _getLinesForBonesNoLength;
  99335. /** Update the viewer to sync with current skeleton state */
  99336. update(): void;
  99337. /** Release associated resources */
  99338. dispose(): void;
  99339. }
  99340. }
  99341. declare module BABYLON {
  99342. /**
  99343. * Options to create the null engine
  99344. */
  99345. export class NullEngineOptions {
  99346. /**
  99347. * Render width (Default: 512)
  99348. */
  99349. renderWidth: number;
  99350. /**
  99351. * Render height (Default: 256)
  99352. */
  99353. renderHeight: number;
  99354. /**
  99355. * Texture size (Default: 512)
  99356. */
  99357. textureSize: number;
  99358. /**
  99359. * If delta time between frames should be constant
  99360. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  99361. */
  99362. deterministicLockstep: boolean;
  99363. /**
  99364. * Maximum about of steps between frames (Default: 4)
  99365. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  99366. */
  99367. lockstepMaxSteps: number;
  99368. }
  99369. /**
  99370. * The null engine class provides support for headless version of babylon.js.
  99371. * This can be used in server side scenario or for testing purposes
  99372. */
  99373. export class NullEngine extends Engine {
  99374. private _options;
  99375. /**
  99376. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  99377. */
  99378. isDeterministicLockStep(): boolean;
  99379. /** @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep */
  99380. getLockstepMaxSteps(): number;
  99381. /**
  99382. * Sets hardware scaling, used to save performance if needed
  99383. * @see https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  99384. */
  99385. getHardwareScalingLevel(): number;
  99386. constructor(options?: NullEngineOptions);
  99387. createVertexBuffer(vertices: FloatArray): WebGLBuffer;
  99388. createIndexBuffer(indices: IndicesArray): WebGLBuffer;
  99389. clear(color: Color4, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  99390. getRenderWidth(useScreen?: boolean): number;
  99391. getRenderHeight(useScreen?: boolean): number;
  99392. setViewport(viewport: Viewport, requiredWidth?: number, requiredHeight?: number): void;
  99393. createShaderProgram(vertexCode: string, fragmentCode: string, defines: string, context?: WebGLRenderingContext): WebGLProgram;
  99394. getUniforms(shaderProgram: WebGLProgram, uniformsNames: string[]): WebGLUniformLocation[];
  99395. getAttributes(shaderProgram: WebGLProgram, attributesNames: string[]): number[];
  99396. bindSamplers(effect: Effect): void;
  99397. enableEffect(effect: Effect): void;
  99398. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  99399. setIntArray(uniform: WebGLUniformLocation, array: Int32Array): void;
  99400. setIntArray2(uniform: WebGLUniformLocation, array: Int32Array): void;
  99401. setIntArray3(uniform: WebGLUniformLocation, array: Int32Array): void;
  99402. setIntArray4(uniform: WebGLUniformLocation, array: Int32Array): void;
  99403. setFloatArray(uniform: WebGLUniformLocation, array: Float32Array): void;
  99404. setFloatArray2(uniform: WebGLUniformLocation, array: Float32Array): void;
  99405. setFloatArray3(uniform: WebGLUniformLocation, array: Float32Array): void;
  99406. setFloatArray4(uniform: WebGLUniformLocation, array: Float32Array): void;
  99407. setArray(uniform: WebGLUniformLocation, array: number[]): void;
  99408. setArray2(uniform: WebGLUniformLocation, array: number[]): void;
  99409. setArray3(uniform: WebGLUniformLocation, array: number[]): void;
  99410. setArray4(uniform: WebGLUniformLocation, array: number[]): void;
  99411. setMatrices(uniform: WebGLUniformLocation, matrices: Float32Array): void;
  99412. setMatrix(uniform: WebGLUniformLocation, matrix: Matrix): void;
  99413. setMatrix3x3(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  99414. setMatrix2x2(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  99415. setFloat(uniform: WebGLUniformLocation, value: number): void;
  99416. setFloat2(uniform: WebGLUniformLocation, x: number, y: number): void;
  99417. setFloat3(uniform: WebGLUniformLocation, x: number, y: number, z: number): void;
  99418. setBool(uniform: WebGLUniformLocation, bool: number): void;
  99419. setFloat4(uniform: WebGLUniformLocation, x: number, y: number, z: number, w: number): void;
  99420. setColor3(uniform: WebGLUniformLocation, color3: Color3): void;
  99421. setColor4(uniform: WebGLUniformLocation, color3: Color3, alpha: number): void;
  99422. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  99423. bindBuffers(vertexBuffers: {
  99424. [key: string]: VertexBuffer;
  99425. }, indexBuffer: WebGLBuffer, effect: Effect): void;
  99426. wipeCaches(bruteForce?: boolean): void;
  99427. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  99428. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  99429. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  99430. /** @hidden */
  99431. _createTexture(): WebGLTexture;
  99432. /** @hidden */
  99433. _releaseTexture(texture: InternalTexture): void;
  99434. 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;
  99435. createRenderTargetTexture(size: any, options: boolean | RenderTargetCreationOptions): InternalTexture;
  99436. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  99437. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean): void;
  99438. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  99439. createDynamicVertexBuffer(vertices: FloatArray): WebGLBuffer;
  99440. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement, invertY: boolean, premulAlpha?: boolean, format?: number): void;
  99441. areAllEffectsReady(): boolean;
  99442. /**
  99443. * @hidden
  99444. * Get the current error code of the webGL context
  99445. * @returns the error code
  99446. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  99447. */
  99448. getError(): number;
  99449. /** @hidden */
  99450. _getUnpackAlignement(): number;
  99451. /** @hidden */
  99452. _unpackFlipY(value: boolean): void;
  99453. updateDynamicIndexBuffer(indexBuffer: WebGLBuffer, indices: IndicesArray, offset?: number): void;
  99454. /**
  99455. * Updates a dynamic vertex buffer.
  99456. * @param vertexBuffer the vertex buffer to update
  99457. * @param data the data used to update the vertex buffer
  99458. * @param byteOffset the byte offset of the data (optional)
  99459. * @param byteLength the byte length of the data (optional)
  99460. */
  99461. updateDynamicVertexBuffer(vertexBuffer: WebGLBuffer, vertices: FloatArray, byteOffset?: number, byteLength?: number): void;
  99462. _bindTextureDirectly(target: number, texture: InternalTexture): boolean;
  99463. /** @hidden */
  99464. _bindTexture(channel: number, texture: InternalTexture): void;
  99465. /** @hidden */
  99466. _releaseBuffer(buffer: WebGLBuffer): boolean;
  99467. releaseEffects(): void;
  99468. displayLoadingUI(): void;
  99469. hideLoadingUI(): void;
  99470. /** @hidden */
  99471. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  99472. /** @hidden */
  99473. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  99474. /** @hidden */
  99475. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  99476. /** @hidden */
  99477. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  99478. }
  99479. }
  99480. declare module BABYLON {
  99481. /** @hidden */
  99482. export class _OcclusionDataStorage {
  99483. /** @hidden */
  99484. occlusionInternalRetryCounter: number;
  99485. /** @hidden */
  99486. isOcclusionQueryInProgress: boolean;
  99487. /** @hidden */
  99488. isOccluded: boolean;
  99489. /** @hidden */
  99490. occlusionRetryCount: number;
  99491. /** @hidden */
  99492. occlusionType: number;
  99493. /** @hidden */
  99494. occlusionQueryAlgorithmType: number;
  99495. }
  99496. interface Engine {
  99497. /**
  99498. * Create a new webGL query (you must be sure that queries are supported by checking getCaps() function)
  99499. * @return the new query
  99500. */
  99501. createQuery(): WebGLQuery;
  99502. /**
  99503. * Delete and release a webGL query
  99504. * @param query defines the query to delete
  99505. * @return the current engine
  99506. */
  99507. deleteQuery(query: WebGLQuery): Engine;
  99508. /**
  99509. * Check if a given query has resolved and got its value
  99510. * @param query defines the query to check
  99511. * @returns true if the query got its value
  99512. */
  99513. isQueryResultAvailable(query: WebGLQuery): boolean;
  99514. /**
  99515. * Gets the value of a given query
  99516. * @param query defines the query to check
  99517. * @returns the value of the query
  99518. */
  99519. getQueryResult(query: WebGLQuery): number;
  99520. /**
  99521. * Initiates an occlusion query
  99522. * @param algorithmType defines the algorithm to use
  99523. * @param query defines the query to use
  99524. * @returns the current engine
  99525. * @see http://doc.babylonjs.com/features/occlusionquery
  99526. */
  99527. beginOcclusionQuery(algorithmType: number, query: WebGLQuery): Engine;
  99528. /**
  99529. * Ends an occlusion query
  99530. * @see http://doc.babylonjs.com/features/occlusionquery
  99531. * @param algorithmType defines the algorithm to use
  99532. * @returns the current engine
  99533. */
  99534. endOcclusionQuery(algorithmType: number): Engine;
  99535. /**
  99536. * Starts a time query (used to measure time spent by the GPU on a specific frame)
  99537. * Please note that only one query can be issued at a time
  99538. * @returns a time token used to track the time span
  99539. */
  99540. startTimeQuery(): Nullable<_TimeToken>;
  99541. /**
  99542. * Ends a time query
  99543. * @param token defines the token used to measure the time span
  99544. * @returns the time spent (in ns)
  99545. */
  99546. endTimeQuery(token: _TimeToken): int;
  99547. /** @hidden */
  99548. _currentNonTimestampToken: Nullable<_TimeToken>;
  99549. /** @hidden */
  99550. _createTimeQuery(): WebGLQuery;
  99551. /** @hidden */
  99552. _deleteTimeQuery(query: WebGLQuery): void;
  99553. /** @hidden */
  99554. _getGlAlgorithmType(algorithmType: number): number;
  99555. /** @hidden */
  99556. _getTimeQueryResult(query: WebGLQuery): any;
  99557. /** @hidden */
  99558. _getTimeQueryAvailability(query: WebGLQuery): any;
  99559. }
  99560. interface AbstractMesh {
  99561. /**
  99562. * Backing filed
  99563. * @hidden
  99564. */
  99565. __occlusionDataStorage: _OcclusionDataStorage;
  99566. /**
  99567. * Access property
  99568. * @hidden
  99569. */
  99570. _occlusionDataStorage: _OcclusionDataStorage;
  99571. /**
  99572. * 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.
  99573. * The default value is -1 which means don't break the query and wait till the result
  99574. * @see http://doc.babylonjs.com/features/occlusionquery
  99575. */
  99576. occlusionRetryCount: number;
  99577. /**
  99578. * 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:
  99579. * * OCCLUSION_TYPE_NONE (Default Value): this option means no occlusion query whith the Mesh.
  99580. * * OCCLUSION_TYPE_OPTIMISTIC: this option is means use occlusion query and if occlusionRetryCount is reached and the query is broken show the mesh.
  99581. * * 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.
  99582. * @see http://doc.babylonjs.com/features/occlusionquery
  99583. */
  99584. occlusionType: number;
  99585. /**
  99586. * This property determines the type of occlusion query algorithm to run in WebGl, you can use:
  99587. * * AbstractMesh.OCCLUSION_ALGORITHM_TYPE_ACCURATE which is mapped to GL_ANY_SAMPLES_PASSED.
  99588. * * 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.
  99589. * @see http://doc.babylonjs.com/features/occlusionquery
  99590. */
  99591. occlusionQueryAlgorithmType: number;
  99592. /**
  99593. * 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
  99594. * @see http://doc.babylonjs.com/features/occlusionquery
  99595. */
  99596. isOccluded: boolean;
  99597. /**
  99598. * Flag to check the progress status of the query
  99599. * @see http://doc.babylonjs.com/features/occlusionquery
  99600. */
  99601. isOcclusionQueryInProgress: boolean;
  99602. }
  99603. }
  99604. declare module BABYLON {
  99605. /** @hidden */
  99606. export var _forceTransformFeedbackToBundle: boolean;
  99607. interface Engine {
  99608. /**
  99609. * Creates a webGL transform feedback object
  99610. * Please makes sure to check webGLVersion property to check if you are running webGL 2+
  99611. * @returns the webGL transform feedback object
  99612. */
  99613. createTransformFeedback(): WebGLTransformFeedback;
  99614. /**
  99615. * Delete a webGL transform feedback object
  99616. * @param value defines the webGL transform feedback object to delete
  99617. */
  99618. deleteTransformFeedback(value: WebGLTransformFeedback): void;
  99619. /**
  99620. * Bind a webGL transform feedback object to the webgl context
  99621. * @param value defines the webGL transform feedback object to bind
  99622. */
  99623. bindTransformFeedback(value: Nullable<WebGLTransformFeedback>): void;
  99624. /**
  99625. * Begins a transform feedback operation
  99626. * @param usePoints defines if points or triangles must be used
  99627. */
  99628. beginTransformFeedback(usePoints: boolean): void;
  99629. /**
  99630. * Ends a transform feedback operation
  99631. */
  99632. endTransformFeedback(): void;
  99633. /**
  99634. * Specify the varyings to use with transform feedback
  99635. * @param program defines the associated webGL program
  99636. * @param value defines the list of strings representing the varying names
  99637. */
  99638. setTranformFeedbackVaryings(program: WebGLProgram, value: string[]): void;
  99639. /**
  99640. * Bind a webGL buffer for a transform feedback operation
  99641. * @param value defines the webGL buffer to bind
  99642. */
  99643. bindTransformFeedbackBuffer(value: Nullable<WebGLBuffer>): void;
  99644. }
  99645. }
  99646. declare module BABYLON {
  99647. /**
  99648. * Gather the list of clipboard event types as constants.
  99649. */
  99650. export class ClipboardEventTypes {
  99651. /**
  99652. * The clipboard event is fired when a copy command is active (pressed).
  99653. */
  99654. static readonly COPY: number;
  99655. /**
  99656. * The clipboard event is fired when a cut command is active (pressed).
  99657. */
  99658. static readonly CUT: number;
  99659. /**
  99660. * The clipboard event is fired when a paste command is active (pressed).
  99661. */
  99662. static readonly PASTE: number;
  99663. }
  99664. /**
  99665. * This class is used to store clipboard related info for the onClipboardObservable event.
  99666. */
  99667. export class ClipboardInfo {
  99668. /**
  99669. * Defines the type of event (BABYLON.ClipboardEventTypes)
  99670. */
  99671. type: number;
  99672. /**
  99673. * Defines the related dom event
  99674. */
  99675. event: ClipboardEvent;
  99676. /**
  99677. *Creates an instance of ClipboardInfo.
  99678. * @param type Defines the type of event (BABYLON.ClipboardEventTypes)
  99679. * @param event Defines the related dom event
  99680. */
  99681. constructor(
  99682. /**
  99683. * Defines the type of event (BABYLON.ClipboardEventTypes)
  99684. */
  99685. type: number,
  99686. /**
  99687. * Defines the related dom event
  99688. */
  99689. event: ClipboardEvent);
  99690. /**
  99691. * Get the clipboard event's type from the keycode.
  99692. * @param keyCode Defines the keyCode for the current keyboard event.
  99693. * @return {number}
  99694. */
  99695. static GetTypeFromCharacter(keyCode: number): number;
  99696. }
  99697. }
  99698. declare module BABYLON {
  99699. /**
  99700. * Class used to represent data loading progression
  99701. */
  99702. export class SceneLoaderProgressEvent {
  99703. /** defines if data length to load can be evaluated */
  99704. readonly lengthComputable: boolean;
  99705. /** defines the loaded data length */
  99706. readonly loaded: number;
  99707. /** defines the data length to load */
  99708. readonly total: number;
  99709. /**
  99710. * Create a new progress event
  99711. * @param lengthComputable defines if data length to load can be evaluated
  99712. * @param loaded defines the loaded data length
  99713. * @param total defines the data length to load
  99714. */
  99715. constructor(
  99716. /** defines if data length to load can be evaluated */
  99717. lengthComputable: boolean,
  99718. /** defines the loaded data length */
  99719. loaded: number,
  99720. /** defines the data length to load */
  99721. total: number);
  99722. /**
  99723. * Creates a new SceneLoaderProgressEvent from a ProgressEvent
  99724. * @param event defines the source event
  99725. * @returns a new SceneLoaderProgressEvent
  99726. */
  99727. static FromProgressEvent(event: ProgressEvent): SceneLoaderProgressEvent;
  99728. }
  99729. /**
  99730. * Interface used by SceneLoader plugins to define supported file extensions
  99731. */
  99732. export interface ISceneLoaderPluginExtensions {
  99733. /**
  99734. * Defines the list of supported extensions
  99735. */
  99736. [extension: string]: {
  99737. isBinary: boolean;
  99738. };
  99739. }
  99740. /**
  99741. * Interface used by SceneLoader plugin factory
  99742. */
  99743. export interface ISceneLoaderPluginFactory {
  99744. /**
  99745. * Defines the name of the factory
  99746. */
  99747. name: string;
  99748. /**
  99749. * Function called to create a new plugin
  99750. * @return the new plugin
  99751. */
  99752. createPlugin(): ISceneLoaderPlugin | ISceneLoaderPluginAsync;
  99753. /**
  99754. * Boolean indicating if the plugin can direct load specific data
  99755. */
  99756. canDirectLoad?: (data: string) => boolean;
  99757. }
  99758. /**
  99759. * Interface used to define a SceneLoader plugin
  99760. */
  99761. export interface ISceneLoaderPlugin {
  99762. /**
  99763. * The friendly name of this plugin.
  99764. */
  99765. name: string;
  99766. /**
  99767. * The file extensions supported by this plugin.
  99768. */
  99769. extensions: string | ISceneLoaderPluginExtensions;
  99770. /**
  99771. * Import meshes into a scene.
  99772. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  99773. * @param scene The scene to import into
  99774. * @param data The data to import
  99775. * @param rootUrl The root url for scene and resources
  99776. * @param meshes The meshes array to import into
  99777. * @param particleSystems The particle systems array to import into
  99778. * @param skeletons The skeletons array to import into
  99779. * @param onError The callback when import fails
  99780. * @returns True if successful or false otherwise
  99781. */
  99782. importMesh(meshesNames: any, scene: Scene, data: any, rootUrl: string, meshes: AbstractMesh[], particleSystems: IParticleSystem[], skeletons: Skeleton[], onError?: (message: string, exception?: any) => void): boolean;
  99783. /**
  99784. * Load into a scene.
  99785. * @param scene The scene to load into
  99786. * @param data The data to import
  99787. * @param rootUrl The root url for scene and resources
  99788. * @param onError The callback when import fails
  99789. * @returns true if successful or false otherwise
  99790. */
  99791. load(scene: Scene, data: string, rootUrl: string, onError?: (message: string, exception?: any) => void): boolean;
  99792. /**
  99793. * The callback that returns true if the data can be directly loaded.
  99794. */
  99795. canDirectLoad?: (data: string) => boolean;
  99796. /**
  99797. * The callback that allows custom handling of the root url based on the response url.
  99798. */
  99799. rewriteRootURL?: (rootUrl: string, responseURL?: string) => string;
  99800. /**
  99801. * Load into an asset container.
  99802. * @param scene The scene to load into
  99803. * @param data The data to import
  99804. * @param rootUrl The root url for scene and resources
  99805. * @param onError The callback when import fails
  99806. * @returns The loaded asset container
  99807. */
  99808. loadAssetContainer(scene: Scene, data: string, rootUrl: string, onError?: (message: string, exception?: any) => void): AssetContainer;
  99809. }
  99810. /**
  99811. * Interface used to define an async SceneLoader plugin
  99812. */
  99813. export interface ISceneLoaderPluginAsync {
  99814. /**
  99815. * The friendly name of this plugin.
  99816. */
  99817. name: string;
  99818. /**
  99819. * The file extensions supported by this plugin.
  99820. */
  99821. extensions: string | ISceneLoaderPluginExtensions;
  99822. /**
  99823. * Import meshes into a scene.
  99824. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  99825. * @param scene The scene to import into
  99826. * @param data The data to import
  99827. * @param rootUrl The root url for scene and resources
  99828. * @param onProgress The callback when the load progresses
  99829. * @param fileName Defines the name of the file to load
  99830. * @returns The loaded meshes, particle systems, skeletons, and animation groups
  99831. */
  99832. importMeshAsync(meshesNames: any, scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<{
  99833. meshes: AbstractMesh[];
  99834. particleSystems: IParticleSystem[];
  99835. skeletons: Skeleton[];
  99836. animationGroups: AnimationGroup[];
  99837. }>;
  99838. /**
  99839. * Load into a scene.
  99840. * @param scene The scene to load into
  99841. * @param data The data to import
  99842. * @param rootUrl The root url for scene and resources
  99843. * @param onProgress The callback when the load progresses
  99844. * @param fileName Defines the name of the file to load
  99845. * @returns Nothing
  99846. */
  99847. loadAsync(scene: Scene, data: string, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<void>;
  99848. /**
  99849. * The callback that returns true if the data can be directly loaded.
  99850. */
  99851. canDirectLoad?: (data: string) => boolean;
  99852. /**
  99853. * The callback that allows custom handling of the root url based on the response url.
  99854. */
  99855. rewriteRootURL?: (rootUrl: string, responseURL?: string) => string;
  99856. /**
  99857. * Load into an asset container.
  99858. * @param scene The scene to load into
  99859. * @param data The data to import
  99860. * @param rootUrl The root url for scene and resources
  99861. * @param onProgress The callback when the load progresses
  99862. * @param fileName Defines the name of the file to load
  99863. * @returns The loaded asset container
  99864. */
  99865. loadAssetContainerAsync(scene: Scene, data: string, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<AssetContainer>;
  99866. }
  99867. /**
  99868. * Class used to load scene from various file formats using registered plugins
  99869. * @see http://doc.babylonjs.com/how_to/load_from_any_file_type
  99870. */
  99871. export class SceneLoader {
  99872. /**
  99873. * No logging while loading
  99874. */
  99875. static readonly NO_LOGGING: number;
  99876. /**
  99877. * Minimal logging while loading
  99878. */
  99879. static readonly MINIMAL_LOGGING: number;
  99880. /**
  99881. * Summary logging while loading
  99882. */
  99883. static readonly SUMMARY_LOGGING: number;
  99884. /**
  99885. * Detailled logging while loading
  99886. */
  99887. static readonly DETAILED_LOGGING: number;
  99888. /**
  99889. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  99890. */
  99891. static ForceFullSceneLoadingForIncremental: boolean;
  99892. /**
  99893. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  99894. */
  99895. static ShowLoadingScreen: boolean;
  99896. /**
  99897. * Defines the current logging level (while loading the scene)
  99898. * @ignorenaming
  99899. */
  99900. static loggingLevel: number;
  99901. /**
  99902. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  99903. */
  99904. static CleanBoneMatrixWeights: boolean;
  99905. /**
  99906. * Event raised when a plugin is used to load a scene
  99907. */
  99908. static OnPluginActivatedObservable: Observable<ISceneLoaderPlugin | ISceneLoaderPluginAsync>;
  99909. private static _registeredPlugins;
  99910. private static _getDefaultPlugin;
  99911. private static _getPluginForExtension;
  99912. private static _getPluginForDirectLoad;
  99913. private static _getPluginForFilename;
  99914. private static _getDirectLoad;
  99915. private static _loadData;
  99916. private static _getFileInfo;
  99917. /**
  99918. * Gets a plugin that can load the given extension
  99919. * @param extension defines the extension to load
  99920. * @returns a plugin or null if none works
  99921. */
  99922. static GetPluginForExtension(extension: string): ISceneLoaderPlugin | ISceneLoaderPluginAsync | ISceneLoaderPluginFactory;
  99923. /**
  99924. * Gets a boolean indicating that the given extension can be loaded
  99925. * @param extension defines the extension to load
  99926. * @returns true if the extension is supported
  99927. */
  99928. static IsPluginForExtensionAvailable(extension: string): boolean;
  99929. /**
  99930. * Adds a new plugin to the list of registered plugins
  99931. * @param plugin defines the plugin to add
  99932. */
  99933. static RegisterPlugin(plugin: ISceneLoaderPlugin | ISceneLoaderPluginAsync): void;
  99934. /**
  99935. * Import meshes into a scene
  99936. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  99937. * @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)
  99938. * @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)
  99939. * @param scene the instance of BABYLON.Scene to append to
  99940. * @param onSuccess a callback with a list of imported meshes, particleSystems, and skeletons when import succeeds
  99941. * @param onProgress a callback with a progress event for each file being loaded
  99942. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  99943. * @param pluginExtension the extension used to determine the plugin
  99944. * @returns The loaded plugin
  99945. */
  99946. 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>;
  99947. /**
  99948. * Import meshes into a scene
  99949. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  99950. * @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)
  99951. * @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)
  99952. * @param scene the instance of BABYLON.Scene to append to
  99953. * @param onProgress a callback with a progress event for each file being loaded
  99954. * @param pluginExtension the extension used to determine the plugin
  99955. * @returns The loaded list of imported meshes, particle systems, skeletons, and animation groups
  99956. */
  99957. static ImportMeshAsync(meshNames: any, rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<{
  99958. meshes: AbstractMesh[];
  99959. particleSystems: IParticleSystem[];
  99960. skeletons: Skeleton[];
  99961. animationGroups: AnimationGroup[];
  99962. }>;
  99963. /**
  99964. * Load a scene
  99965. * @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)
  99966. * @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)
  99967. * @param engine is the instance of BABYLON.Engine to use to create the scene
  99968. * @param onSuccess a callback with the scene when import succeeds
  99969. * @param onProgress a callback with a progress event for each file being loaded
  99970. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  99971. * @param pluginExtension the extension used to determine the plugin
  99972. * @returns The loaded plugin
  99973. */
  99974. 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>;
  99975. /**
  99976. * Load a scene
  99977. * @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)
  99978. * @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)
  99979. * @param engine is the instance of BABYLON.Engine to use to create the scene
  99980. * @param onProgress a callback with a progress event for each file being loaded
  99981. * @param pluginExtension the extension used to determine the plugin
  99982. * @returns The loaded scene
  99983. */
  99984. static LoadAsync(rootUrl: string, sceneFilename?: string | File, engine?: Nullable<Engine>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  99985. /**
  99986. * Append a scene
  99987. * @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)
  99988. * @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)
  99989. * @param scene is the instance of BABYLON.Scene to append to
  99990. * @param onSuccess a callback with the scene when import succeeds
  99991. * @param onProgress a callback with a progress event for each file being loaded
  99992. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  99993. * @param pluginExtension the extension used to determine the plugin
  99994. * @returns The loaded plugin
  99995. */
  99996. 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>;
  99997. /**
  99998. * Append a scene
  99999. * @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)
  100000. * @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)
  100001. * @param scene is the instance of BABYLON.Scene to append to
  100002. * @param onProgress a callback with a progress event for each file being loaded
  100003. * @param pluginExtension the extension used to determine the plugin
  100004. * @returns The given scene
  100005. */
  100006. static AppendAsync(rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  100007. /**
  100008. * Load a scene into an asset container
  100009. * @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)
  100010. * @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)
  100011. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  100012. * @param onSuccess a callback with the scene when import succeeds
  100013. * @param onProgress a callback with a progress event for each file being loaded
  100014. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  100015. * @param pluginExtension the extension used to determine the plugin
  100016. * @returns The loaded plugin
  100017. */
  100018. 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>;
  100019. /**
  100020. * Load a scene into an asset container
  100021. * @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)
  100022. * @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)
  100023. * @param scene is the instance of Scene to append to
  100024. * @param onProgress a callback with a progress event for each file being loaded
  100025. * @param pluginExtension the extension used to determine the plugin
  100026. * @returns The loaded asset container
  100027. */
  100028. static LoadAssetContainerAsync(rootUrl: string, sceneFilename?: string, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<AssetContainer>;
  100029. }
  100030. }
  100031. declare module BABYLON {
  100032. /**
  100033. * Google Daydream controller
  100034. */
  100035. export class DaydreamController extends WebVRController {
  100036. /**
  100037. * Base Url for the controller model.
  100038. */
  100039. static MODEL_BASE_URL: string;
  100040. /**
  100041. * File name for the controller model.
  100042. */
  100043. static MODEL_FILENAME: string;
  100044. /**
  100045. * Gamepad Id prefix used to identify Daydream Controller.
  100046. */
  100047. static readonly GAMEPAD_ID_PREFIX: string;
  100048. /**
  100049. * Creates a new DaydreamController from a gamepad
  100050. * @param vrGamepad the gamepad that the controller should be created from
  100051. */
  100052. constructor(vrGamepad: any);
  100053. /**
  100054. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  100055. * @param scene scene in which to add meshes
  100056. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  100057. */
  100058. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  100059. /**
  100060. * Called once for each button that changed state since the last frame
  100061. * @param buttonIdx Which button index changed
  100062. * @param state New state of the button
  100063. * @param changes Which properties on the state changed since last frame
  100064. */
  100065. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  100066. }
  100067. }
  100068. declare module BABYLON {
  100069. /**
  100070. * Gear VR Controller
  100071. */
  100072. export class GearVRController extends WebVRController {
  100073. /**
  100074. * Base Url for the controller model.
  100075. */
  100076. static MODEL_BASE_URL: string;
  100077. /**
  100078. * File name for the controller model.
  100079. */
  100080. static MODEL_FILENAME: string;
  100081. /**
  100082. * Gamepad Id prefix used to identify this controller.
  100083. */
  100084. static readonly GAMEPAD_ID_PREFIX: string;
  100085. private readonly _buttonIndexToObservableNameMap;
  100086. /**
  100087. * Creates a new GearVRController from a gamepad
  100088. * @param vrGamepad the gamepad that the controller should be created from
  100089. */
  100090. constructor(vrGamepad: any);
  100091. /**
  100092. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  100093. * @param scene scene in which to add meshes
  100094. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  100095. */
  100096. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  100097. /**
  100098. * Called once for each button that changed state since the last frame
  100099. * @param buttonIdx Which button index changed
  100100. * @param state New state of the button
  100101. * @param changes Which properties on the state changed since last frame
  100102. */
  100103. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  100104. }
  100105. }
  100106. declare module BABYLON {
  100107. /**
  100108. * Generic Controller
  100109. */
  100110. export class GenericController extends WebVRController {
  100111. /**
  100112. * Base Url for the controller model.
  100113. */
  100114. static readonly MODEL_BASE_URL: string;
  100115. /**
  100116. * File name for the controller model.
  100117. */
  100118. static readonly MODEL_FILENAME: string;
  100119. /**
  100120. * Creates a new GenericController from a gamepad
  100121. * @param vrGamepad the gamepad that the controller should be created from
  100122. */
  100123. constructor(vrGamepad: any);
  100124. /**
  100125. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  100126. * @param scene scene in which to add meshes
  100127. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  100128. */
  100129. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  100130. /**
  100131. * Called once for each button that changed state since the last frame
  100132. * @param buttonIdx Which button index changed
  100133. * @param state New state of the button
  100134. * @param changes Which properties on the state changed since last frame
  100135. */
  100136. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  100137. }
  100138. }
  100139. declare module BABYLON {
  100140. /**
  100141. * Oculus Touch Controller
  100142. */
  100143. export class OculusTouchController extends WebVRController {
  100144. /**
  100145. * Base Url for the controller model.
  100146. */
  100147. static MODEL_BASE_URL: string;
  100148. /**
  100149. * File name for the left controller model.
  100150. */
  100151. static MODEL_LEFT_FILENAME: string;
  100152. /**
  100153. * File name for the right controller model.
  100154. */
  100155. static MODEL_RIGHT_FILENAME: string;
  100156. /**
  100157. * Fired when the secondary trigger on this controller is modified
  100158. */
  100159. onSecondaryTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  100160. /**
  100161. * Fired when the thumb rest on this controller is modified
  100162. */
  100163. onThumbRestChangedObservable: Observable<ExtendedGamepadButton>;
  100164. /**
  100165. * Creates a new OculusTouchController from a gamepad
  100166. * @param vrGamepad the gamepad that the controller should be created from
  100167. */
  100168. constructor(vrGamepad: any);
  100169. /**
  100170. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  100171. * @param scene scene in which to add meshes
  100172. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  100173. */
  100174. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  100175. /**
  100176. * Fired when the A button on this controller is modified
  100177. */
  100178. readonly onAButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  100179. /**
  100180. * Fired when the B button on this controller is modified
  100181. */
  100182. readonly onBButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  100183. /**
  100184. * Fired when the X button on this controller is modified
  100185. */
  100186. readonly onXButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  100187. /**
  100188. * Fired when the Y button on this controller is modified
  100189. */
  100190. readonly onYButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  100191. /**
  100192. * Called once for each button that changed state since the last frame
  100193. * 0) thumb stick (touch, press, value = pressed (0,1)). value is in this.leftStick
  100194. * 1) index trigger (touch (?), press (only when value > 0.1), value 0 to 1)
  100195. * 2) secondary trigger (same)
  100196. * 3) A (right) X (left), touch, pressed = value
  100197. * 4) B / Y
  100198. * 5) thumb rest
  100199. * @param buttonIdx Which button index changed
  100200. * @param state New state of the button
  100201. * @param changes Which properties on the state changed since last frame
  100202. */
  100203. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  100204. }
  100205. }
  100206. declare module BABYLON {
  100207. /**
  100208. * Vive Controller
  100209. */
  100210. export class ViveController extends WebVRController {
  100211. /**
  100212. * Base Url for the controller model.
  100213. */
  100214. static MODEL_BASE_URL: string;
  100215. /**
  100216. * File name for the controller model.
  100217. */
  100218. static MODEL_FILENAME: string;
  100219. /**
  100220. * Creates a new ViveController from a gamepad
  100221. * @param vrGamepad the gamepad that the controller should be created from
  100222. */
  100223. constructor(vrGamepad: any);
  100224. /**
  100225. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  100226. * @param scene scene in which to add meshes
  100227. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  100228. */
  100229. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  100230. /**
  100231. * Fired when the left button on this controller is modified
  100232. */
  100233. readonly onLeftButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  100234. /**
  100235. * Fired when the right button on this controller is modified
  100236. */
  100237. readonly onRightButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  100238. /**
  100239. * Fired when the menu button on this controller is modified
  100240. */
  100241. readonly onMenuButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  100242. /**
  100243. * Called once for each button that changed state since the last frame
  100244. * Vive mapping:
  100245. * 0: touchpad
  100246. * 1: trigger
  100247. * 2: left AND right buttons
  100248. * 3: menu button
  100249. * @param buttonIdx Which button index changed
  100250. * @param state New state of the button
  100251. * @param changes Which properties on the state changed since last frame
  100252. */
  100253. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  100254. }
  100255. }
  100256. declare module BABYLON {
  100257. /**
  100258. * Defines the WindowsMotionController object that the state of the windows motion controller
  100259. */
  100260. export class WindowsMotionController extends WebVRController {
  100261. /**
  100262. * The base url used to load the left and right controller models
  100263. */
  100264. static MODEL_BASE_URL: string;
  100265. /**
  100266. * The name of the left controller model file
  100267. */
  100268. static MODEL_LEFT_FILENAME: string;
  100269. /**
  100270. * The name of the right controller model file
  100271. */
  100272. static MODEL_RIGHT_FILENAME: string;
  100273. /**
  100274. * The controller name prefix for this controller type
  100275. */
  100276. static readonly GAMEPAD_ID_PREFIX: string;
  100277. /**
  100278. * The controller id pattern for this controller type
  100279. */
  100280. private static readonly GAMEPAD_ID_PATTERN;
  100281. private _loadedMeshInfo;
  100282. private readonly _mapping;
  100283. /**
  100284. * Fired when the trackpad on this controller is clicked
  100285. */
  100286. onTrackpadChangedObservable: Observable<ExtendedGamepadButton>;
  100287. /**
  100288. * Fired when the trackpad on this controller is modified
  100289. */
  100290. onTrackpadValuesChangedObservable: Observable<StickValues>;
  100291. /**
  100292. * The current x and y values of this controller's trackpad
  100293. */
  100294. trackpad: StickValues;
  100295. /**
  100296. * Creates a new WindowsMotionController from a gamepad
  100297. * @param vrGamepad the gamepad that the controller should be created from
  100298. */
  100299. constructor(vrGamepad: any);
  100300. /**
  100301. * Fired when the trigger on this controller is modified
  100302. */
  100303. readonly onTriggerButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  100304. /**
  100305. * Fired when the menu button on this controller is modified
  100306. */
  100307. readonly onMenuButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  100308. /**
  100309. * Fired when the grip button on this controller is modified
  100310. */
  100311. readonly onGripButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  100312. /**
  100313. * Fired when the thumbstick button on this controller is modified
  100314. */
  100315. readonly onThumbstickButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  100316. /**
  100317. * Fired when the touchpad button on this controller is modified
  100318. */
  100319. readonly onTouchpadButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  100320. /**
  100321. * Fired when the touchpad values on this controller are modified
  100322. */
  100323. readonly onTouchpadValuesChangedObservable: Observable<StickValues>;
  100324. private _updateTrackpad;
  100325. /**
  100326. * Called once per frame by the engine.
  100327. */
  100328. update(): void;
  100329. /**
  100330. * Called once for each button that changed state since the last frame
  100331. * @param buttonIdx Which button index changed
  100332. * @param state New state of the button
  100333. * @param changes Which properties on the state changed since last frame
  100334. */
  100335. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  100336. /**
  100337. * Moves the buttons on the controller mesh based on their current state
  100338. * @param buttonName the name of the button to move
  100339. * @param buttonValue the value of the button which determines the buttons new position
  100340. */
  100341. protected _lerpButtonTransform(buttonName: string, buttonValue: number): void;
  100342. /**
  100343. * Moves the axis on the controller mesh based on its current state
  100344. * @param axis the index of the axis
  100345. * @param axisValue the value of the axis which determines the meshes new position
  100346. * @hidden
  100347. */
  100348. protected _lerpAxisTransform(axis: number, axisValue: number): void;
  100349. /**
  100350. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  100351. * @param scene scene in which to add meshes
  100352. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  100353. */
  100354. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void, forceDefault?: boolean): void;
  100355. /**
  100356. * Takes a list of meshes (as loaded from the glTF file) and finds the root node, as well as nodes that
  100357. * can be transformed by button presses and axes values, based on this._mapping.
  100358. *
  100359. * @param scene scene in which the meshes exist
  100360. * @param meshes list of meshes that make up the controller model to process
  100361. * @return structured view of the given meshes, with mapping of buttons and axes to meshes that can be transformed.
  100362. */
  100363. private processModel;
  100364. private createMeshInfo;
  100365. /**
  100366. * Gets the ray of the controller in the direction the controller is pointing
  100367. * @param length the length the resulting ray should be
  100368. * @returns a ray in the direction the controller is pointing
  100369. */
  100370. getForwardRay(length?: number): Ray;
  100371. /**
  100372. * Disposes of the controller
  100373. */
  100374. dispose(): void;
  100375. }
  100376. }
  100377. declare module BABYLON {
  100378. /**
  100379. * Single axis scale gizmo
  100380. */
  100381. export class AxisScaleGizmo extends Gizmo {
  100382. private _coloredMaterial;
  100383. /**
  100384. * Drag behavior responsible for the gizmos dragging interactions
  100385. */
  100386. dragBehavior: PointerDragBehavior;
  100387. private _pointerObserver;
  100388. /**
  100389. * Scale distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  100390. */
  100391. snapDistance: number;
  100392. /**
  100393. * Event that fires each time the gizmo snaps to a new location.
  100394. * * snapDistance is the the change in distance
  100395. */
  100396. onSnapObservable: Observable<{
  100397. snapDistance: number;
  100398. }>;
  100399. /**
  100400. * If the scaling operation should be done on all axis (default: false)
  100401. */
  100402. uniformScaling: boolean;
  100403. /**
  100404. * Creates an AxisScaleGizmo
  100405. * @param gizmoLayer The utility layer the gizmo will be added to
  100406. * @param dragAxis The axis which the gizmo will be able to scale on
  100407. * @param color The color of the gizmo
  100408. */
  100409. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer);
  100410. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  100411. /**
  100412. * Disposes of the gizmo
  100413. */
  100414. dispose(): void;
  100415. /**
  100416. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  100417. * @param mesh The mesh to replace the default mesh of the gizmo
  100418. * @param useGizmoMaterial If the gizmo's default material should be used (default: false)
  100419. */
  100420. setCustomMesh(mesh: Mesh, useGizmoMaterial?: boolean): void;
  100421. }
  100422. }
  100423. declare module BABYLON {
  100424. /**
  100425. * Bounding box gizmo
  100426. */
  100427. export class BoundingBoxGizmo extends Gizmo {
  100428. private _lineBoundingBox;
  100429. private _rotateSpheresParent;
  100430. private _scaleBoxesParent;
  100431. private _boundingDimensions;
  100432. private _renderObserver;
  100433. private _pointerObserver;
  100434. private _scaleDragSpeed;
  100435. private _tmpQuaternion;
  100436. private _tmpVector;
  100437. private _tmpRotationMatrix;
  100438. /**
  100439. * 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)
  100440. */
  100441. ignoreChildren: boolean;
  100442. /**
  100443. * 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)
  100444. */
  100445. includeChildPredicate: Nullable<(abstractMesh: AbstractMesh) => boolean>;
  100446. /**
  100447. * The size of the rotation spheres attached to the bounding box (Default: 0.1)
  100448. */
  100449. rotationSphereSize: number;
  100450. /**
  100451. * The size of the scale boxes attached to the bounding box (Default: 0.1)
  100452. */
  100453. scaleBoxSize: number;
  100454. /**
  100455. * 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)
  100456. */
  100457. fixedDragMeshScreenSize: boolean;
  100458. /**
  100459. * The distance away from the object which the draggable meshes should appear world sized when fixedDragMeshScreenSize is set to true (default: 10)
  100460. */
  100461. fixedDragMeshScreenSizeDistanceFactor: number;
  100462. /**
  100463. * Fired when a rotation sphere or scale box is dragged
  100464. */
  100465. onDragStartObservable: Observable<{}>;
  100466. /**
  100467. * Fired when a scale box is dragged
  100468. */
  100469. onScaleBoxDragObservable: Observable<{}>;
  100470. /**
  100471. * Fired when a scale box drag is ended
  100472. */
  100473. onScaleBoxDragEndObservable: Observable<{}>;
  100474. /**
  100475. * Fired when a rotation sphere is dragged
  100476. */
  100477. onRotationSphereDragObservable: Observable<{}>;
  100478. /**
  100479. * Fired when a rotation sphere drag is ended
  100480. */
  100481. onRotationSphereDragEndObservable: Observable<{}>;
  100482. /**
  100483. * 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)
  100484. */
  100485. scalePivot: Nullable<Vector3>;
  100486. private _anchorMesh;
  100487. private _existingMeshScale;
  100488. private _dragMesh;
  100489. private pointerDragBehavior;
  100490. private coloredMaterial;
  100491. private hoverColoredMaterial;
  100492. /**
  100493. * Sets the color of the bounding box gizmo
  100494. * @param color the color to set
  100495. */
  100496. setColor(color: Color3): void;
  100497. /**
  100498. * Creates an BoundingBoxGizmo
  100499. * @param gizmoLayer The utility layer the gizmo will be added to
  100500. * @param color The color of the gizmo
  100501. */
  100502. constructor(color?: Color3, gizmoLayer?: UtilityLayerRenderer);
  100503. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  100504. private _selectNode;
  100505. /**
  100506. * Updates the bounding box information for the Gizmo
  100507. */
  100508. updateBoundingBox(): void;
  100509. private _updateRotationSpheres;
  100510. private _updateScaleBoxes;
  100511. /**
  100512. * Enables rotation on the specified axis and disables rotation on the others
  100513. * @param axis The list of axis that should be enabled (eg. "xy" or "xyz")
  100514. */
  100515. setEnabledRotationAxis(axis: string): void;
  100516. /**
  100517. * Enables/disables scaling
  100518. * @param enable if scaling should be enabled
  100519. */
  100520. setEnabledScaling(enable: boolean): void;
  100521. private _updateDummy;
  100522. /**
  100523. * Enables a pointer drag behavior on the bounding box of the gizmo
  100524. */
  100525. enableDragBehavior(): void;
  100526. /**
  100527. * Disposes of the gizmo
  100528. */
  100529. dispose(): void;
  100530. /**
  100531. * 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)
  100532. * @param mesh the mesh to wrap in the bounding box mesh and make not pickable
  100533. * @returns the bounding box mesh with the passed in mesh as a child
  100534. */
  100535. static MakeNotPickableAndWrapInBoundingBox(mesh: Mesh): Mesh;
  100536. /**
  100537. * CustomMeshes are not supported by this gizmo
  100538. * @param mesh The mesh to replace the default mesh of the gizmo
  100539. */
  100540. setCustomMesh(mesh: Mesh): void;
  100541. }
  100542. }
  100543. declare module BABYLON {
  100544. /**
  100545. * Single plane rotation gizmo
  100546. */
  100547. export class PlaneRotationGizmo extends Gizmo {
  100548. /**
  100549. * Drag behavior responsible for the gizmos dragging interactions
  100550. */
  100551. dragBehavior: PointerDragBehavior;
  100552. private _pointerObserver;
  100553. /**
  100554. * Rotation distance in radians that the gizmo will snap to (Default: 0)
  100555. */
  100556. snapDistance: number;
  100557. /**
  100558. * Event that fires each time the gizmo snaps to a new location.
  100559. * * snapDistance is the the change in distance
  100560. */
  100561. onSnapObservable: Observable<{
  100562. snapDistance: number;
  100563. }>;
  100564. /**
  100565. * Creates a PlaneRotationGizmo
  100566. * @param gizmoLayer The utility layer the gizmo will be added to
  100567. * @param planeNormal The normal of the plane which the gizmo will be able to rotate on
  100568. * @param color The color of the gizmo
  100569. * @param tessellation Amount of tessellation to be used when creating rotation circles
  100570. */
  100571. constructor(planeNormal: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, tessellation?: number);
  100572. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  100573. /**
  100574. * Disposes of the gizmo
  100575. */
  100576. dispose(): void;
  100577. }
  100578. }
  100579. declare module BABYLON {
  100580. /**
  100581. * Gizmo that enables rotating a mesh along 3 axis
  100582. */
  100583. export class RotationGizmo extends Gizmo {
  100584. /**
  100585. * Internal gizmo used for interactions on the x axis
  100586. */
  100587. xGizmo: PlaneRotationGizmo;
  100588. /**
  100589. * Internal gizmo used for interactions on the y axis
  100590. */
  100591. yGizmo: PlaneRotationGizmo;
  100592. /**
  100593. * Internal gizmo used for interactions on the z axis
  100594. */
  100595. zGizmo: PlaneRotationGizmo;
  100596. /** Fires an event when any of it's sub gizmos are dragged */
  100597. onDragStartObservable: Observable<{}>;
  100598. /** Fires an event when any of it's sub gizmos are released from dragging */
  100599. onDragEndObservable: Observable<{}>;
  100600. attachedMesh: Nullable<AbstractMesh>;
  100601. /**
  100602. * Creates a RotationGizmo
  100603. * @param gizmoLayer The utility layer the gizmo will be added to
  100604. * @param tessellation Amount of tessellation to be used when creating rotation circles
  100605. */
  100606. constructor(gizmoLayer?: UtilityLayerRenderer, tessellation?: number);
  100607. updateGizmoRotationToMatchAttachedMesh: boolean;
  100608. /**
  100609. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  100610. */
  100611. snapDistance: number;
  100612. /**
  100613. * Ratio for the scale of the gizmo (Default: 1)
  100614. */
  100615. scaleRatio: number;
  100616. /**
  100617. * Disposes of the gizmo
  100618. */
  100619. dispose(): void;
  100620. /**
  100621. * CustomMeshes are not supported by this gizmo
  100622. * @param mesh The mesh to replace the default mesh of the gizmo
  100623. */
  100624. setCustomMesh(mesh: Mesh): void;
  100625. }
  100626. }
  100627. declare module BABYLON {
  100628. /**
  100629. * Gizmo that enables dragging a mesh along 3 axis
  100630. */
  100631. export class PositionGizmo extends Gizmo {
  100632. /**
  100633. * Internal gizmo used for interactions on the x axis
  100634. */
  100635. xGizmo: AxisDragGizmo;
  100636. /**
  100637. * Internal gizmo used for interactions on the y axis
  100638. */
  100639. yGizmo: AxisDragGizmo;
  100640. /**
  100641. * Internal gizmo used for interactions on the z axis
  100642. */
  100643. zGizmo: AxisDragGizmo;
  100644. /** Fires an event when any of it's sub gizmos are dragged */
  100645. onDragStartObservable: Observable<{}>;
  100646. /** Fires an event when any of it's sub gizmos are released from dragging */
  100647. onDragEndObservable: Observable<{}>;
  100648. attachedMesh: Nullable<AbstractMesh>;
  100649. /**
  100650. * Creates a PositionGizmo
  100651. * @param gizmoLayer The utility layer the gizmo will be added to
  100652. */
  100653. constructor(gizmoLayer?: UtilityLayerRenderer);
  100654. updateGizmoRotationToMatchAttachedMesh: boolean;
  100655. /**
  100656. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  100657. */
  100658. snapDistance: number;
  100659. /**
  100660. * Ratio for the scale of the gizmo (Default: 1)
  100661. */
  100662. scaleRatio: number;
  100663. /**
  100664. * Disposes of the gizmo
  100665. */
  100666. dispose(): void;
  100667. /**
  100668. * CustomMeshes are not supported by this gizmo
  100669. * @param mesh The mesh to replace the default mesh of the gizmo
  100670. */
  100671. setCustomMesh(mesh: Mesh): void;
  100672. }
  100673. }
  100674. declare module BABYLON {
  100675. /**
  100676. * Class containing static functions to help procedurally build meshes
  100677. */
  100678. export class PolyhedronBuilder {
  100679. /**
  100680. * Creates a polyhedron mesh
  100681. * * 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
  100682. * * The parameter `size` (positive float, default 1) sets the polygon size
  100683. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  100684. * * 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`
  100685. * * 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
  100686. * * 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)`)
  100687. * * 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
  100688. * * 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
  100689. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  100690. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  100691. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  100692. * @param name defines the name of the mesh
  100693. * @param options defines the options used to create the mesh
  100694. * @param scene defines the hosting scene
  100695. * @returns the polyhedron mesh
  100696. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  100697. */
  100698. static CreatePolyhedron(name: string, options: {
  100699. type?: number;
  100700. size?: number;
  100701. sizeX?: number;
  100702. sizeY?: number;
  100703. sizeZ?: number;
  100704. custom?: any;
  100705. faceUV?: Vector4[];
  100706. faceColors?: Color4[];
  100707. flat?: boolean;
  100708. updatable?: boolean;
  100709. sideOrientation?: number;
  100710. frontUVs?: Vector4;
  100711. backUVs?: Vector4;
  100712. }, scene: Scene): Mesh;
  100713. }
  100714. }
  100715. declare module BABYLON {
  100716. /**
  100717. * Gizmo that enables scaling a mesh along 3 axis
  100718. */
  100719. export class ScaleGizmo extends Gizmo {
  100720. /**
  100721. * Internal gizmo used for interactions on the x axis
  100722. */
  100723. xGizmo: AxisScaleGizmo;
  100724. /**
  100725. * Internal gizmo used for interactions on the y axis
  100726. */
  100727. yGizmo: AxisScaleGizmo;
  100728. /**
  100729. * Internal gizmo used for interactions on the z axis
  100730. */
  100731. zGizmo: AxisScaleGizmo;
  100732. /**
  100733. * Internal gizmo used to scale all axis equally
  100734. */
  100735. uniformScaleGizmo: AxisScaleGizmo;
  100736. /** Fires an event when any of it's sub gizmos are dragged */
  100737. onDragStartObservable: Observable<{}>;
  100738. /** Fires an event when any of it's sub gizmos are released from dragging */
  100739. onDragEndObservable: Observable<{}>;
  100740. attachedMesh: Nullable<AbstractMesh>;
  100741. /**
  100742. * Creates a ScaleGizmo
  100743. * @param gizmoLayer The utility layer the gizmo will be added to
  100744. */
  100745. constructor(gizmoLayer?: UtilityLayerRenderer);
  100746. updateGizmoRotationToMatchAttachedMesh: boolean;
  100747. /**
  100748. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  100749. */
  100750. snapDistance: number;
  100751. /**
  100752. * Ratio for the scale of the gizmo (Default: 1)
  100753. */
  100754. scaleRatio: number;
  100755. /**
  100756. * Disposes of the gizmo
  100757. */
  100758. dispose(): void;
  100759. }
  100760. }
  100761. declare module BABYLON {
  100762. /**
  100763. * Helps setup gizmo's in the scene to rotate/scale/position meshes
  100764. */
  100765. export class GizmoManager implements IDisposable {
  100766. private scene;
  100767. /**
  100768. * Gizmo's created by the gizmo manager, gizmo will be null until gizmo has been enabled for the first time
  100769. */
  100770. gizmos: {
  100771. positionGizmo: Nullable<PositionGizmo>;
  100772. rotationGizmo: Nullable<RotationGizmo>;
  100773. scaleGizmo: Nullable<ScaleGizmo>;
  100774. boundingBoxGizmo: Nullable<BoundingBoxGizmo>;
  100775. };
  100776. /** When true, the gizmo will be detached from the current object when a pointer down occurs with an empty picked mesh */
  100777. clearGizmoOnEmptyPointerEvent: boolean;
  100778. /** Fires an event when the manager is attached to a mesh */
  100779. onAttachedToMeshObservable: Observable<Nullable<AbstractMesh>>;
  100780. private _gizmosEnabled;
  100781. private _pointerObserver;
  100782. private _attachedMesh;
  100783. private _boundingBoxColor;
  100784. private _defaultUtilityLayer;
  100785. private _defaultKeepDepthUtilityLayer;
  100786. /**
  100787. * When bounding box gizmo is enabled, this can be used to track drag/end events
  100788. */
  100789. boundingBoxDragBehavior: SixDofDragBehavior;
  100790. /**
  100791. * Array of meshes which will have the gizmo attached when a pointer selected them. If null, all meshes are attachable. (Default: null)
  100792. */
  100793. attachableMeshes: Nullable<Array<AbstractMesh>>;
  100794. /**
  100795. * If pointer events should perform attaching/detaching a gizmo, if false this can be done manually via attachToMesh. (Default: true)
  100796. */
  100797. usePointerToAttachGizmos: boolean;
  100798. /**
  100799. * Instatiates a gizmo manager
  100800. * @param scene the scene to overlay the gizmos on top of
  100801. */
  100802. constructor(scene: Scene);
  100803. /**
  100804. * Attaches a set of gizmos to the specified mesh
  100805. * @param mesh The mesh the gizmo's should be attached to
  100806. */
  100807. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  100808. /**
  100809. * If the position gizmo is enabled
  100810. */
  100811. positionGizmoEnabled: boolean;
  100812. /**
  100813. * If the rotation gizmo is enabled
  100814. */
  100815. rotationGizmoEnabled: boolean;
  100816. /**
  100817. * If the scale gizmo is enabled
  100818. */
  100819. scaleGizmoEnabled: boolean;
  100820. /**
  100821. * If the boundingBox gizmo is enabled
  100822. */
  100823. boundingBoxGizmoEnabled: boolean;
  100824. /**
  100825. * Disposes of the gizmo manager
  100826. */
  100827. dispose(): void;
  100828. }
  100829. }
  100830. declare module BABYLON {
  100831. /**
  100832. * Gizmo that enables viewing a light
  100833. */
  100834. export class LightGizmo extends Gizmo {
  100835. private _box;
  100836. /**
  100837. * Creates a LightGizmo
  100838. * @param gizmoLayer The utility layer the gizmo will be added to
  100839. */
  100840. constructor(gizmoLayer?: UtilityLayerRenderer);
  100841. private _light;
  100842. /**
  100843. * The light that the gizmo is attached to
  100844. */
  100845. light: Nullable<Light>;
  100846. /**
  100847. * @hidden
  100848. * Updates the gizmo to match the attached mesh's position/rotation
  100849. */
  100850. protected _update(): void;
  100851. }
  100852. }
  100853. declare module BABYLON {
  100854. /** @hidden */
  100855. export var backgroundFragmentDeclaration: {
  100856. name: string;
  100857. shader: string;
  100858. };
  100859. }
  100860. declare module BABYLON {
  100861. /** @hidden */
  100862. export var backgroundUboDeclaration: {
  100863. name: string;
  100864. shader: string;
  100865. };
  100866. }
  100867. declare module BABYLON {
  100868. /** @hidden */
  100869. export var backgroundPixelShader: {
  100870. name: string;
  100871. shader: string;
  100872. };
  100873. }
  100874. declare module BABYLON {
  100875. /** @hidden */
  100876. export var backgroundVertexDeclaration: {
  100877. name: string;
  100878. shader: string;
  100879. };
  100880. }
  100881. declare module BABYLON {
  100882. /** @hidden */
  100883. export var backgroundVertexShader: {
  100884. name: string;
  100885. shader: string;
  100886. };
  100887. }
  100888. declare module BABYLON {
  100889. /**
  100890. * Background material used to create an efficient environement around your scene.
  100891. */
  100892. export class BackgroundMaterial extends PushMaterial {
  100893. /**
  100894. * Standard reflectance value at parallel view angle.
  100895. */
  100896. static StandardReflectance0: number;
  100897. /**
  100898. * Standard reflectance value at grazing angle.
  100899. */
  100900. static StandardReflectance90: number;
  100901. protected _primaryColor: Color3;
  100902. /**
  100903. * Key light Color (multiply against the environement texture)
  100904. */
  100905. primaryColor: Color3;
  100906. protected __perceptualColor: Nullable<Color3>;
  100907. /**
  100908. * Experimental Internal Use Only.
  100909. *
  100910. * Key light Color in "perceptual value" meaning the color you would like to see on screen.
  100911. * This acts as a helper to set the primary color to a more "human friendly" value.
  100912. * Conversion to linear space as well as exposure and tone mapping correction will be applied to keep the
  100913. * output color as close as possible from the chosen value.
  100914. * (This does not account for contrast color grading and color curves as they are considered post effect and not directly
  100915. * part of lighting setup.)
  100916. */
  100917. _perceptualColor: Nullable<Color3>;
  100918. protected _primaryColorShadowLevel: float;
  100919. /**
  100920. * Defines the level of the shadows (dark area of the reflection map) in order to help scaling the colors.
  100921. * The color opposite to the primary color is used at the level chosen to define what the black area would look.
  100922. */
  100923. primaryColorShadowLevel: float;
  100924. protected _primaryColorHighlightLevel: float;
  100925. /**
  100926. * Defines the level of the highliights (highlight area of the reflection map) in order to help scaling the colors.
  100927. * The primary color is used at the level chosen to define what the white area would look.
  100928. */
  100929. primaryColorHighlightLevel: float;
  100930. protected _reflectionTexture: Nullable<BaseTexture>;
  100931. /**
  100932. * Reflection Texture used in the material.
  100933. * Should be author in a specific way for the best result (refer to the documentation).
  100934. */
  100935. reflectionTexture: Nullable<BaseTexture>;
  100936. protected _reflectionBlur: float;
  100937. /**
  100938. * Reflection Texture level of blur.
  100939. *
  100940. * Can be use to reuse an existing HDR Texture and target a specific LOD to prevent authoring the
  100941. * texture twice.
  100942. */
  100943. reflectionBlur: float;
  100944. protected _diffuseTexture: Nullable<BaseTexture>;
  100945. /**
  100946. * Diffuse Texture used in the material.
  100947. * Should be author in a specific way for the best result (refer to the documentation).
  100948. */
  100949. diffuseTexture: Nullable<BaseTexture>;
  100950. protected _shadowLights: Nullable<IShadowLight[]>;
  100951. /**
  100952. * Specify the list of lights casting shadow on the material.
  100953. * All scene shadow lights will be included if null.
  100954. */
  100955. shadowLights: Nullable<IShadowLight[]>;
  100956. protected _shadowLevel: float;
  100957. /**
  100958. * Helps adjusting the shadow to a softer level if required.
  100959. * 0 means black shadows and 1 means no shadows.
  100960. */
  100961. shadowLevel: float;
  100962. protected _sceneCenter: Vector3;
  100963. /**
  100964. * In case of opacity Fresnel or reflection falloff, this is use as a scene center.
  100965. * It is usually zero but might be interesting to modify according to your setup.
  100966. */
  100967. sceneCenter: Vector3;
  100968. protected _opacityFresnel: boolean;
  100969. /**
  100970. * This helps specifying that the material is falling off to the sky box at grazing angle.
  100971. * This helps ensuring a nice transition when the camera goes under the ground.
  100972. */
  100973. opacityFresnel: boolean;
  100974. protected _reflectionFresnel: boolean;
  100975. /**
  100976. * This helps specifying that the material is falling off from diffuse to the reflection texture at grazing angle.
  100977. * This helps adding a mirror texture on the ground.
  100978. */
  100979. reflectionFresnel: boolean;
  100980. protected _reflectionFalloffDistance: number;
  100981. /**
  100982. * This helps specifying the falloff radius off the reflection texture from the sceneCenter.
  100983. * This helps adding a nice falloff effect to the reflection if used as a mirror for instance.
  100984. */
  100985. reflectionFalloffDistance: number;
  100986. protected _reflectionAmount: number;
  100987. /**
  100988. * This specifies the weight of the reflection against the background in case of reflection Fresnel.
  100989. */
  100990. reflectionAmount: number;
  100991. protected _reflectionReflectance0: number;
  100992. /**
  100993. * This specifies the weight of the reflection at grazing angle.
  100994. */
  100995. reflectionReflectance0: number;
  100996. protected _reflectionReflectance90: number;
  100997. /**
  100998. * This specifies the weight of the reflection at a perpendicular point of view.
  100999. */
  101000. reflectionReflectance90: number;
  101001. /**
  101002. * Sets the reflection reflectance fresnel values according to the default standard
  101003. * empirically know to work well :-)
  101004. */
  101005. reflectionStandardFresnelWeight: number;
  101006. protected _useRGBColor: boolean;
  101007. /**
  101008. * Helps to directly use the maps channels instead of their level.
  101009. */
  101010. useRGBColor: boolean;
  101011. protected _enableNoise: boolean;
  101012. /**
  101013. * This helps reducing the banding effect that could occur on the background.
  101014. */
  101015. enableNoise: boolean;
  101016. /**
  101017. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  101018. * Best used when trying to implement visual zoom effects like fish-eye or binoculars while not adjusting camera fov.
  101019. * Recommended to be keep at 1.0 except for special cases.
  101020. */
  101021. fovMultiplier: number;
  101022. private _fovMultiplier;
  101023. /**
  101024. * Enable the FOV adjustment feature controlled by fovMultiplier.
  101025. */
  101026. useEquirectangularFOV: boolean;
  101027. private _maxSimultaneousLights;
  101028. /**
  101029. * Number of Simultaneous lights allowed on the material.
  101030. */
  101031. maxSimultaneousLights: int;
  101032. /**
  101033. * Default configuration related to image processing available in the Background Material.
  101034. */
  101035. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  101036. /**
  101037. * Keep track of the image processing observer to allow dispose and replace.
  101038. */
  101039. private _imageProcessingObserver;
  101040. /**
  101041. * Attaches a new image processing configuration to the PBR Material.
  101042. * @param configuration (if null the scene configuration will be use)
  101043. */
  101044. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  101045. /**
  101046. * Gets the image processing configuration used either in this material.
  101047. */
  101048. /**
  101049. * Sets the Default image processing configuration used either in the this material.
  101050. *
  101051. * If sets to null, the scene one is in use.
  101052. */
  101053. imageProcessingConfiguration: Nullable<ImageProcessingConfiguration>;
  101054. /**
  101055. * Gets wether the color curves effect is enabled.
  101056. */
  101057. /**
  101058. * Sets wether the color curves effect is enabled.
  101059. */
  101060. cameraColorCurvesEnabled: boolean;
  101061. /**
  101062. * Gets wether the color grading effect is enabled.
  101063. */
  101064. /**
  101065. * Gets wether the color grading effect is enabled.
  101066. */
  101067. cameraColorGradingEnabled: boolean;
  101068. /**
  101069. * Gets wether tonemapping is enabled or not.
  101070. */
  101071. /**
  101072. * Sets wether tonemapping is enabled or not
  101073. */
  101074. cameraToneMappingEnabled: boolean;
  101075. /**
  101076. * The camera exposure used on this material.
  101077. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  101078. * This corresponds to a photographic exposure.
  101079. */
  101080. /**
  101081. * The camera exposure used on this material.
  101082. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  101083. * This corresponds to a photographic exposure.
  101084. */
  101085. cameraExposure: float;
  101086. /**
  101087. * Gets The camera contrast used on this material.
  101088. */
  101089. /**
  101090. * Sets The camera contrast used on this material.
  101091. */
  101092. cameraContrast: float;
  101093. /**
  101094. * Gets the Color Grading 2D Lookup Texture.
  101095. */
  101096. /**
  101097. * Sets the Color Grading 2D Lookup Texture.
  101098. */
  101099. cameraColorGradingTexture: Nullable<BaseTexture>;
  101100. /**
  101101. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  101102. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  101103. * 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;
  101104. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  101105. */
  101106. /**
  101107. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  101108. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  101109. * 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;
  101110. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  101111. */
  101112. cameraColorCurves: Nullable<ColorCurves>;
  101113. /**
  101114. * Due to a bug in iOS10, video tags (which are using the background material) are in BGR and not RGB.
  101115. * Setting this flag to true (not done automatically!) will convert it back to RGB.
  101116. */
  101117. switchToBGR: boolean;
  101118. private _renderTargets;
  101119. private _reflectionControls;
  101120. private _white;
  101121. private _primaryShadowColor;
  101122. private _primaryHighlightColor;
  101123. /**
  101124. * Instantiates a Background Material in the given scene
  101125. * @param name The friendly name of the material
  101126. * @param scene The scene to add the material to
  101127. */
  101128. constructor(name: string, scene: Scene);
  101129. /**
  101130. * Gets a boolean indicating that current material needs to register RTT
  101131. */
  101132. readonly hasRenderTargetTextures: boolean;
  101133. /**
  101134. * The entire material has been created in order to prevent overdraw.
  101135. * @returns false
  101136. */
  101137. needAlphaTesting(): boolean;
  101138. /**
  101139. * The entire material has been created in order to prevent overdraw.
  101140. * @returns true if blending is enable
  101141. */
  101142. needAlphaBlending(): boolean;
  101143. /**
  101144. * Checks wether the material is ready to be rendered for a given mesh.
  101145. * @param mesh The mesh to render
  101146. * @param subMesh The submesh to check against
  101147. * @param useInstances Specify wether or not the material is used with instances
  101148. * @returns true if all the dependencies are ready (Textures, Effects...)
  101149. */
  101150. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  101151. /**
  101152. * Compute the primary color according to the chosen perceptual color.
  101153. */
  101154. private _computePrimaryColorFromPerceptualColor;
  101155. /**
  101156. * Compute the highlights and shadow colors according to their chosen levels.
  101157. */
  101158. private _computePrimaryColors;
  101159. /**
  101160. * Build the uniform buffer used in the material.
  101161. */
  101162. buildUniformLayout(): void;
  101163. /**
  101164. * Unbind the material.
  101165. */
  101166. unbind(): void;
  101167. /**
  101168. * Bind only the world matrix to the material.
  101169. * @param world The world matrix to bind.
  101170. */
  101171. bindOnlyWorldMatrix(world: Matrix): void;
  101172. /**
  101173. * Bind the material for a dedicated submeh (every used meshes will be considered opaque).
  101174. * @param world The world matrix to bind.
  101175. * @param subMesh The submesh to bind for.
  101176. */
  101177. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  101178. /**
  101179. * Dispose the material.
  101180. * @param forceDisposeEffect Force disposal of the associated effect.
  101181. * @param forceDisposeTextures Force disposal of the associated textures.
  101182. */
  101183. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  101184. /**
  101185. * Clones the material.
  101186. * @param name The cloned name.
  101187. * @returns The cloned material.
  101188. */
  101189. clone(name: string): BackgroundMaterial;
  101190. /**
  101191. * Serializes the current material to its JSON representation.
  101192. * @returns The JSON representation.
  101193. */
  101194. serialize(): any;
  101195. /**
  101196. * Gets the class name of the material
  101197. * @returns "BackgroundMaterial"
  101198. */
  101199. getClassName(): string;
  101200. /**
  101201. * Parse a JSON input to create back a background material.
  101202. * @param source The JSON data to parse
  101203. * @param scene The scene to create the parsed material in
  101204. * @param rootUrl The root url of the assets the material depends upon
  101205. * @returns the instantiated BackgroundMaterial.
  101206. */
  101207. static Parse(source: any, scene: Scene, rootUrl: string): BackgroundMaterial;
  101208. }
  101209. }
  101210. declare module BABYLON {
  101211. /**
  101212. * Represents the different options available during the creation of
  101213. * a Environment helper.
  101214. *
  101215. * This can control the default ground, skybox and image processing setup of your scene.
  101216. */
  101217. export interface IEnvironmentHelperOptions {
  101218. /**
  101219. * Specifies wether or not to create a ground.
  101220. * True by default.
  101221. */
  101222. createGround: boolean;
  101223. /**
  101224. * Specifies the ground size.
  101225. * 15 by default.
  101226. */
  101227. groundSize: number;
  101228. /**
  101229. * The texture used on the ground for the main color.
  101230. * Comes from the BabylonJS CDN by default.
  101231. *
  101232. * Remarks: Can be either a texture or a url.
  101233. */
  101234. groundTexture: string | BaseTexture;
  101235. /**
  101236. * The color mixed in the ground texture by default.
  101237. * BabylonJS clearColor by default.
  101238. */
  101239. groundColor: Color3;
  101240. /**
  101241. * Specifies the ground opacity.
  101242. * 1 by default.
  101243. */
  101244. groundOpacity: number;
  101245. /**
  101246. * Enables the ground to receive shadows.
  101247. * True by default.
  101248. */
  101249. enableGroundShadow: boolean;
  101250. /**
  101251. * Helps preventing the shadow to be fully black on the ground.
  101252. * 0.5 by default.
  101253. */
  101254. groundShadowLevel: number;
  101255. /**
  101256. * Creates a mirror texture attach to the ground.
  101257. * false by default.
  101258. */
  101259. enableGroundMirror: boolean;
  101260. /**
  101261. * Specifies the ground mirror size ratio.
  101262. * 0.3 by default as the default kernel is 64.
  101263. */
  101264. groundMirrorSizeRatio: number;
  101265. /**
  101266. * Specifies the ground mirror blur kernel size.
  101267. * 64 by default.
  101268. */
  101269. groundMirrorBlurKernel: number;
  101270. /**
  101271. * Specifies the ground mirror visibility amount.
  101272. * 1 by default
  101273. */
  101274. groundMirrorAmount: number;
  101275. /**
  101276. * Specifies the ground mirror reflectance weight.
  101277. * This uses the standard weight of the background material to setup the fresnel effect
  101278. * of the mirror.
  101279. * 1 by default.
  101280. */
  101281. groundMirrorFresnelWeight: number;
  101282. /**
  101283. * Specifies the ground mirror Falloff distance.
  101284. * This can helps reducing the size of the reflection.
  101285. * 0 by Default.
  101286. */
  101287. groundMirrorFallOffDistance: number;
  101288. /**
  101289. * Specifies the ground mirror texture type.
  101290. * Unsigned Int by Default.
  101291. */
  101292. groundMirrorTextureType: number;
  101293. /**
  101294. * Specifies a bias applied to the ground vertical position to prevent z-fighting with
  101295. * the shown objects.
  101296. */
  101297. groundYBias: number;
  101298. /**
  101299. * Specifies wether or not to create a skybox.
  101300. * True by default.
  101301. */
  101302. createSkybox: boolean;
  101303. /**
  101304. * Specifies the skybox size.
  101305. * 20 by default.
  101306. */
  101307. skyboxSize: number;
  101308. /**
  101309. * The texture used on the skybox for the main color.
  101310. * Comes from the BabylonJS CDN by default.
  101311. *
  101312. * Remarks: Can be either a texture or a url.
  101313. */
  101314. skyboxTexture: string | BaseTexture;
  101315. /**
  101316. * The color mixed in the skybox texture by default.
  101317. * BabylonJS clearColor by default.
  101318. */
  101319. skyboxColor: Color3;
  101320. /**
  101321. * The background rotation around the Y axis of the scene.
  101322. * This helps aligning the key lights of your scene with the background.
  101323. * 0 by default.
  101324. */
  101325. backgroundYRotation: number;
  101326. /**
  101327. * Compute automatically the size of the elements to best fit with the scene.
  101328. */
  101329. sizeAuto: boolean;
  101330. /**
  101331. * Default position of the rootMesh if autoSize is not true.
  101332. */
  101333. rootPosition: Vector3;
  101334. /**
  101335. * Sets up the image processing in the scene.
  101336. * true by default.
  101337. */
  101338. setupImageProcessing: boolean;
  101339. /**
  101340. * The texture used as your environment texture in the scene.
  101341. * Comes from the BabylonJS CDN by default and in use if setupImageProcessing is true.
  101342. *
  101343. * Remarks: Can be either a texture or a url.
  101344. */
  101345. environmentTexture: string | BaseTexture;
  101346. /**
  101347. * The value of the exposure to apply to the scene.
  101348. * 0.6 by default if setupImageProcessing is true.
  101349. */
  101350. cameraExposure: number;
  101351. /**
  101352. * The value of the contrast to apply to the scene.
  101353. * 1.6 by default if setupImageProcessing is true.
  101354. */
  101355. cameraContrast: number;
  101356. /**
  101357. * Specifies wether or not tonemapping should be enabled in the scene.
  101358. * true by default if setupImageProcessing is true.
  101359. */
  101360. toneMappingEnabled: boolean;
  101361. }
  101362. /**
  101363. * The Environment helper class can be used to add a fully featuread none expensive background to your scene.
  101364. * It includes by default a skybox and a ground relying on the BackgroundMaterial.
  101365. * It also helps with the default setup of your imageProcessing configuration.
  101366. */
  101367. export class EnvironmentHelper {
  101368. /**
  101369. * Default ground texture URL.
  101370. */
  101371. private static _groundTextureCDNUrl;
  101372. /**
  101373. * Default skybox texture URL.
  101374. */
  101375. private static _skyboxTextureCDNUrl;
  101376. /**
  101377. * Default environment texture URL.
  101378. */
  101379. private static _environmentTextureCDNUrl;
  101380. /**
  101381. * Creates the default options for the helper.
  101382. */
  101383. private static _getDefaultOptions;
  101384. private _rootMesh;
  101385. /**
  101386. * Gets the root mesh created by the helper.
  101387. */
  101388. readonly rootMesh: Mesh;
  101389. private _skybox;
  101390. /**
  101391. * Gets the skybox created by the helper.
  101392. */
  101393. readonly skybox: Nullable<Mesh>;
  101394. private _skyboxTexture;
  101395. /**
  101396. * Gets the skybox texture created by the helper.
  101397. */
  101398. readonly skyboxTexture: Nullable<BaseTexture>;
  101399. private _skyboxMaterial;
  101400. /**
  101401. * Gets the skybox material created by the helper.
  101402. */
  101403. readonly skyboxMaterial: Nullable<BackgroundMaterial>;
  101404. private _ground;
  101405. /**
  101406. * Gets the ground mesh created by the helper.
  101407. */
  101408. readonly ground: Nullable<Mesh>;
  101409. private _groundTexture;
  101410. /**
  101411. * Gets the ground texture created by the helper.
  101412. */
  101413. readonly groundTexture: Nullable<BaseTexture>;
  101414. private _groundMirror;
  101415. /**
  101416. * Gets the ground mirror created by the helper.
  101417. */
  101418. readonly groundMirror: Nullable<MirrorTexture>;
  101419. /**
  101420. * Gets the ground mirror render list to helps pushing the meshes
  101421. * you wish in the ground reflection.
  101422. */
  101423. readonly groundMirrorRenderList: Nullable<AbstractMesh[]>;
  101424. private _groundMaterial;
  101425. /**
  101426. * Gets the ground material created by the helper.
  101427. */
  101428. readonly groundMaterial: Nullable<BackgroundMaterial>;
  101429. /**
  101430. * Stores the creation options.
  101431. */
  101432. private readonly _scene;
  101433. private _options;
  101434. /**
  101435. * This observable will be notified with any error during the creation of the environment,
  101436. * mainly texture creation errors.
  101437. */
  101438. onErrorObservable: Observable<{
  101439. message?: string;
  101440. exception?: any;
  101441. }>;
  101442. /**
  101443. * constructor
  101444. * @param options Defines the options we want to customize the helper
  101445. * @param scene The scene to add the material to
  101446. */
  101447. constructor(options: Partial<IEnvironmentHelperOptions>, scene: Scene);
  101448. /**
  101449. * Updates the background according to the new options
  101450. * @param options
  101451. */
  101452. updateOptions(options: Partial<IEnvironmentHelperOptions>): void;
  101453. /**
  101454. * Sets the primary color of all the available elements.
  101455. * @param color the main color to affect to the ground and the background
  101456. */
  101457. setMainColor(color: Color3): void;
  101458. /**
  101459. * Setup the image processing according to the specified options.
  101460. */
  101461. private _setupImageProcessing;
  101462. /**
  101463. * Setup the environment texture according to the specified options.
  101464. */
  101465. private _setupEnvironmentTexture;
  101466. /**
  101467. * Setup the background according to the specified options.
  101468. */
  101469. private _setupBackground;
  101470. /**
  101471. * Get the scene sizes according to the setup.
  101472. */
  101473. private _getSceneSize;
  101474. /**
  101475. * Setup the ground according to the specified options.
  101476. */
  101477. private _setupGround;
  101478. /**
  101479. * Setup the ground material according to the specified options.
  101480. */
  101481. private _setupGroundMaterial;
  101482. /**
  101483. * Setup the ground diffuse texture according to the specified options.
  101484. */
  101485. private _setupGroundDiffuseTexture;
  101486. /**
  101487. * Setup the ground mirror texture according to the specified options.
  101488. */
  101489. private _setupGroundMirrorTexture;
  101490. /**
  101491. * Setup the ground to receive the mirror texture.
  101492. */
  101493. private _setupMirrorInGroundMaterial;
  101494. /**
  101495. * Setup the skybox according to the specified options.
  101496. */
  101497. private _setupSkybox;
  101498. /**
  101499. * Setup the skybox material according to the specified options.
  101500. */
  101501. private _setupSkyboxMaterial;
  101502. /**
  101503. * Setup the skybox reflection texture according to the specified options.
  101504. */
  101505. private _setupSkyboxReflectionTexture;
  101506. private _errorHandler;
  101507. /**
  101508. * Dispose all the elements created by the Helper.
  101509. */
  101510. dispose(): void;
  101511. }
  101512. }
  101513. declare module BABYLON {
  101514. /**
  101515. * Display a 360 degree photo on an approximately spherical surface, useful for VR applications or skyboxes.
  101516. * As a subclass of TransformNode, this allow parenting to the camera with different locations in the scene.
  101517. * This class achieves its effect with a Texture and a correctly configured BackgroundMaterial on an inverted sphere.
  101518. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  101519. */
  101520. export class PhotoDome extends TransformNode {
  101521. private _useDirectMapping;
  101522. /**
  101523. * The texture being displayed on the sphere
  101524. */
  101525. protected _photoTexture: Texture;
  101526. /**
  101527. * Gets or sets the texture being displayed on the sphere
  101528. */
  101529. photoTexture: Texture;
  101530. /**
  101531. * Observable raised when an error occured while loading the 360 image
  101532. */
  101533. onLoadErrorObservable: Observable<string>;
  101534. /**
  101535. * The skybox material
  101536. */
  101537. protected _material: BackgroundMaterial;
  101538. /**
  101539. * The surface used for the skybox
  101540. */
  101541. protected _mesh: Mesh;
  101542. /**
  101543. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  101544. * Also see the options.resolution property.
  101545. */
  101546. fovMultiplier: number;
  101547. /**
  101548. * Create an instance of this class and pass through the parameters to the relevant classes, Texture, StandardMaterial, and Mesh.
  101549. * @param name Element's name, child elements will append suffixes for their own names.
  101550. * @param urlsOfPhoto defines the url of the photo to display
  101551. * @param options defines an object containing optional or exposed sub element properties
  101552. * @param onError defines a callback called when an error occured while loading the texture
  101553. */
  101554. constructor(name: string, urlOfPhoto: string, options: {
  101555. resolution?: number;
  101556. size?: number;
  101557. useDirectMapping?: boolean;
  101558. faceForward?: boolean;
  101559. }, scene: Scene, onError?: Nullable<(message?: string, exception?: any) => void>);
  101560. /**
  101561. * Releases resources associated with this node.
  101562. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  101563. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  101564. */
  101565. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  101566. }
  101567. }
  101568. declare module BABYLON {
  101569. /**
  101570. * Class used to host texture specific utilities
  101571. */
  101572. export class TextureTools {
  101573. /**
  101574. * Uses the GPU to create a copy texture rescaled at a given size
  101575. * @param texture Texture to copy from
  101576. * @param width defines the desired width
  101577. * @param height defines the desired height
  101578. * @param useBilinearMode defines if bilinear mode has to be used
  101579. * @return the generated texture
  101580. */
  101581. static CreateResizedCopy(texture: Texture, width: number, height: number, useBilinearMode?: boolean): Texture;
  101582. /**
  101583. * Gets a default environment BRDF for MS-BRDF Height Correlated BRDF
  101584. * @param scene defines the hosting scene
  101585. * @returns the environment BRDF texture
  101586. */
  101587. static GetEnvironmentBRDFTexture(scene: Scene): BaseTexture;
  101588. private static _environmentBRDFBase64Texture;
  101589. }
  101590. }
  101591. declare module BABYLON {
  101592. /**
  101593. * @hidden
  101594. */
  101595. export interface IMaterialClearCoatDefines {
  101596. CLEARCOAT: boolean;
  101597. CLEARCOAT_DEFAULTIOR: boolean;
  101598. CLEARCOAT_TEXTURE: boolean;
  101599. CLEARCOAT_TEXTUREDIRECTUV: number;
  101600. CLEARCOAT_BUMP: boolean;
  101601. CLEARCOAT_BUMPDIRECTUV: number;
  101602. CLEARCOAT_TINT: boolean;
  101603. CLEARCOAT_TINT_TEXTURE: boolean;
  101604. CLEARCOAT_TINT_TEXTUREDIRECTUV: number;
  101605. /** @hidden */
  101606. _areTexturesDirty: boolean;
  101607. }
  101608. /**
  101609. * Define the code related to the clear coat parameters of the pbr material.
  101610. */
  101611. export class PBRClearCoatConfiguration {
  101612. /**
  101613. * This defaults to 1.5 corresponding to a 0.04 f0 or a 4% reflectance at normal incidence
  101614. * The default fits with a polyurethane material.
  101615. */
  101616. private static readonly _DefaultIndiceOfRefraction;
  101617. private _isEnabled;
  101618. /**
  101619. * Defines if the clear coat is enabled in the material.
  101620. */
  101621. isEnabled: boolean;
  101622. /**
  101623. * Defines the clear coat layer strength (between 0 and 1) it defaults to 1.
  101624. */
  101625. intensity: number;
  101626. /**
  101627. * Defines the clear coat layer roughness.
  101628. */
  101629. roughness: number;
  101630. private _indiceOfRefraction;
  101631. /**
  101632. * Defines the indice of refraction of the clear coat.
  101633. * This defaults to 1.5 corresponding to a 0.04 f0 or a 4% reflectance at normal incidence
  101634. * The default fits with a polyurethane material.
  101635. * Changing the default value is more performance intensive.
  101636. */
  101637. indiceOfRefraction: number;
  101638. private _texture;
  101639. /**
  101640. * Stores the clear coat values in a texture.
  101641. */
  101642. texture: Nullable<BaseTexture>;
  101643. private _bumpTexture;
  101644. /**
  101645. * Define the clear coat specific bump texture.
  101646. */
  101647. bumpTexture: Nullable<BaseTexture>;
  101648. private _isTintEnabled;
  101649. /**
  101650. * Defines if the clear coat tint is enabled in the material.
  101651. */
  101652. isTintEnabled: boolean;
  101653. /**
  101654. * Defines if the clear coat tint is enabled in the material.
  101655. * This is only use if tint is enabled
  101656. */
  101657. tintColor: Color3;
  101658. /**
  101659. * Defines if the distance at which the tint color should be found in the
  101660. * clear coat media.
  101661. * This is only use if tint is enabled
  101662. */
  101663. tintColorAtDistance: number;
  101664. /**
  101665. * Defines the clear coat layer thickness.
  101666. * This is only use if tint is enabled
  101667. */
  101668. tintThickness: number;
  101669. private _tintTexture;
  101670. /**
  101671. * Stores the clear tint values in a texture.
  101672. * rgb is tint
  101673. * a is a thickness factor
  101674. */
  101675. tintTexture: Nullable<BaseTexture>;
  101676. /** @hidden */
  101677. private _internalMarkAllSubMeshesAsTexturesDirty;
  101678. /** @hidden */
  101679. _markAllSubMeshesAsTexturesDirty(): void;
  101680. /**
  101681. * Instantiate a new istance of clear coat configuration.
  101682. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  101683. */
  101684. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  101685. /**
  101686. * Specifies that the submesh is ready to be used.
  101687. * @param defines the list of "defines" to update.
  101688. * @param scene defines the scene the material belongs to.
  101689. * @param engine defines the engine the material belongs to.
  101690. * @param disableBumpMap defines wether the material disables bump or not.
  101691. * @returns - boolean indicating that the submesh is ready or not.
  101692. */
  101693. isReadyForSubMesh(defines: IMaterialClearCoatDefines, scene: Scene, engine: Engine, disableBumpMap: boolean): boolean;
  101694. /**
  101695. * Checks to see if a texture is used in the material.
  101696. * @param defines the list of "defines" to update.
  101697. * @param scene defines the scene to the material belongs to.
  101698. */
  101699. prepareDefines(defines: IMaterialClearCoatDefines, scene: Scene): void;
  101700. /**
  101701. * Binds the material data.
  101702. * @param uniformBuffer defines the Uniform buffer to fill in.
  101703. * @param scene defines the scene the material belongs to.
  101704. * @param engine defines the engine the material belongs to.
  101705. * @param disableBumpMap defines wether the material disables bump or not.
  101706. * @param isFrozen defines wether the material is frozen or not.
  101707. * @param invertNormalMapX If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  101708. * @param invertNormalMapY If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  101709. */
  101710. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, engine: Engine, disableBumpMap: boolean, isFrozen: boolean, invertNormalMapX: boolean, invertNormalMapY: boolean): void;
  101711. /**
  101712. * Checks to see if a texture is used in the material.
  101713. * @param texture - Base texture to use.
  101714. * @returns - Boolean specifying if a texture is used in the material.
  101715. */
  101716. hasTexture(texture: BaseTexture): boolean;
  101717. /**
  101718. * Returns an array of the actively used textures.
  101719. * @param activeTextures Array of BaseTextures
  101720. */
  101721. getActiveTextures(activeTextures: BaseTexture[]): void;
  101722. /**
  101723. * Returns the animatable textures.
  101724. * @param animatables Array of animatable textures.
  101725. */
  101726. getAnimatables(animatables: IAnimatable[]): void;
  101727. /**
  101728. * Disposes the resources of the material.
  101729. * @param forceDisposeTextures - Forces the disposal of all textures.
  101730. */
  101731. dispose(forceDisposeTextures?: boolean): void;
  101732. /**
  101733. * Get the current class name of the texture useful for serialization or dynamic coding.
  101734. * @returns "PBRClearCoatConfiguration"
  101735. */
  101736. getClassName(): string;
  101737. /**
  101738. * Add fallbacks to the effect fallbacks list.
  101739. * @param defines defines the Base texture to use.
  101740. * @param fallbacks defines the current fallback list.
  101741. * @param currentRank defines the current fallback rank.
  101742. * @returns the new fallback rank.
  101743. */
  101744. static AddFallbacks(defines: IMaterialClearCoatDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  101745. /**
  101746. * Add the required uniforms to the current list.
  101747. * @param uniforms defines the current uniform list.
  101748. */
  101749. static AddUniforms(uniforms: string[]): void;
  101750. /**
  101751. * Add the required samplers to the current list.
  101752. * @param samplers defines the current sampler list.
  101753. */
  101754. static AddSamplers(samplers: string[]): void;
  101755. /**
  101756. * Add the required uniforms to the current buffer.
  101757. * @param uniformBuffer defines the current uniform buffer.
  101758. */
  101759. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  101760. /**
  101761. * Makes a duplicate of the current configuration into another one.
  101762. * @param clearCoatConfiguration define the config where to copy the info
  101763. */
  101764. copyTo(clearCoatConfiguration: PBRClearCoatConfiguration): void;
  101765. /**
  101766. * Serializes this clear coat configuration.
  101767. * @returns - An object with the serialized config.
  101768. */
  101769. serialize(): any;
  101770. /**
  101771. * Parses a Clear Coat Configuration from a serialized object.
  101772. * @param source - Serialized object.
  101773. */
  101774. parse(source: any): void;
  101775. }
  101776. }
  101777. declare module BABYLON {
  101778. /**
  101779. * @hidden
  101780. */
  101781. export interface IMaterialAnisotropicDefines {
  101782. ANISOTROPIC: boolean;
  101783. ANISOTROPIC_TEXTURE: boolean;
  101784. ANISOTROPIC_TEXTUREDIRECTUV: number;
  101785. MAINUV1: boolean;
  101786. _areTexturesDirty: boolean;
  101787. _needUVs: boolean;
  101788. }
  101789. /**
  101790. * Define the code related to the anisotropic parameters of the pbr material.
  101791. */
  101792. export class PBRAnisotropicConfiguration {
  101793. private _isEnabled;
  101794. /**
  101795. * Defines if the anisotropy is enabled in the material.
  101796. */
  101797. isEnabled: boolean;
  101798. /**
  101799. * Defines the anisotropy strength (between 0 and 1) it defaults to 1.
  101800. */
  101801. intensity: number;
  101802. /**
  101803. * Defines if the effect is along the tangents, bitangents or in between.
  101804. * By default, the effect is "strectching" the highlights along the tangents.
  101805. */
  101806. direction: Vector2;
  101807. private _texture;
  101808. /**
  101809. * Stores the anisotropy values in a texture.
  101810. * rg is direction (like normal from -1 to 1)
  101811. * b is a intensity
  101812. */
  101813. texture: Nullable<BaseTexture>;
  101814. /** @hidden */
  101815. private _internalMarkAllSubMeshesAsTexturesDirty;
  101816. /** @hidden */
  101817. _markAllSubMeshesAsTexturesDirty(): void;
  101818. /**
  101819. * Instantiate a new istance of anisotropy configuration.
  101820. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  101821. */
  101822. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  101823. /**
  101824. * Specifies that the submesh is ready to be used.
  101825. * @param defines the list of "defines" to update.
  101826. * @param scene defines the scene the material belongs to.
  101827. * @returns - boolean indicating that the submesh is ready or not.
  101828. */
  101829. isReadyForSubMesh(defines: IMaterialAnisotropicDefines, scene: Scene): boolean;
  101830. /**
  101831. * Checks to see if a texture is used in the material.
  101832. * @param defines the list of "defines" to update.
  101833. * @param mesh the mesh we are preparing the defines for.
  101834. * @param scene defines the scene the material belongs to.
  101835. */
  101836. prepareDefines(defines: IMaterialAnisotropicDefines, mesh: AbstractMesh, scene: Scene): void;
  101837. /**
  101838. * Binds the material data.
  101839. * @param uniformBuffer defines the Uniform buffer to fill in.
  101840. * @param scene defines the scene the material belongs to.
  101841. * @param isFrozen defines wether the material is frozen or not.
  101842. */
  101843. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  101844. /**
  101845. * Checks to see if a texture is used in the material.
  101846. * @param texture - Base texture to use.
  101847. * @returns - Boolean specifying if a texture is used in the material.
  101848. */
  101849. hasTexture(texture: BaseTexture): boolean;
  101850. /**
  101851. * Returns an array of the actively used textures.
  101852. * @param activeTextures Array of BaseTextures
  101853. */
  101854. getActiveTextures(activeTextures: BaseTexture[]): void;
  101855. /**
  101856. * Returns the animatable textures.
  101857. * @param animatables Array of animatable textures.
  101858. */
  101859. getAnimatables(animatables: IAnimatable[]): void;
  101860. /**
  101861. * Disposes the resources of the material.
  101862. * @param forceDisposeTextures - Forces the disposal of all textures.
  101863. */
  101864. dispose(forceDisposeTextures?: boolean): void;
  101865. /**
  101866. * Get the current class name of the texture useful for serialization or dynamic coding.
  101867. * @returns "PBRAnisotropicConfiguration"
  101868. */
  101869. getClassName(): string;
  101870. /**
  101871. * Add fallbacks to the effect fallbacks list.
  101872. * @param defines defines the Base texture to use.
  101873. * @param fallbacks defines the current fallback list.
  101874. * @param currentRank defines the current fallback rank.
  101875. * @returns the new fallback rank.
  101876. */
  101877. static AddFallbacks(defines: IMaterialAnisotropicDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  101878. /**
  101879. * Add the required uniforms to the current list.
  101880. * @param uniforms defines the current uniform list.
  101881. */
  101882. static AddUniforms(uniforms: string[]): void;
  101883. /**
  101884. * Add the required uniforms to the current buffer.
  101885. * @param uniformBuffer defines the current uniform buffer.
  101886. */
  101887. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  101888. /**
  101889. * Add the required samplers to the current list.
  101890. * @param samplers defines the current sampler list.
  101891. */
  101892. static AddSamplers(samplers: string[]): void;
  101893. /**
  101894. * Makes a duplicate of the current configuration into another one.
  101895. * @param anisotropicConfiguration define the config where to copy the info
  101896. */
  101897. copyTo(anisotropicConfiguration: PBRAnisotropicConfiguration): void;
  101898. /**
  101899. * Serializes this anisotropy configuration.
  101900. * @returns - An object with the serialized config.
  101901. */
  101902. serialize(): any;
  101903. /**
  101904. * Parses a anisotropy Configuration from a serialized object.
  101905. * @param source - Serialized object.
  101906. */
  101907. parse(source: any): void;
  101908. }
  101909. }
  101910. declare module BABYLON {
  101911. /**
  101912. * @hidden
  101913. */
  101914. export interface IMaterialBRDFDefines {
  101915. BRDF_V_HEIGHT_CORRELATED: boolean;
  101916. MS_BRDF_ENERGY_CONSERVATION: boolean;
  101917. /** @hidden */
  101918. _areMiscDirty: boolean;
  101919. }
  101920. /**
  101921. * Define the code related to the BRDF parameters of the pbr material.
  101922. */
  101923. export class PBRBRDFConfiguration {
  101924. private _useEnergyConservation;
  101925. /**
  101926. * Defines if the material uses energy conservation.
  101927. */
  101928. useEnergyConservation: boolean;
  101929. private _useSmithVisibilityHeightCorrelated;
  101930. /**
  101931. * LEGACY Mode set to false
  101932. * Defines if the material uses height smith correlated visibility term.
  101933. * If you intent to not use our default BRDF, you need to load a separate BRDF Texture for the PBR
  101934. * You can either load https://assets.babylonjs.com/environments/uncorrelatedBRDF.png
  101935. * or https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds to have more precision
  101936. * Not relying on height correlated will also disable energy conservation.
  101937. */
  101938. useSmithVisibilityHeightCorrelated: boolean;
  101939. /** @hidden */
  101940. private _internalMarkAllSubMeshesAsMiscDirty;
  101941. /** @hidden */
  101942. _markAllSubMeshesAsMiscDirty(): void;
  101943. /**
  101944. * Instantiate a new istance of clear coat configuration.
  101945. * @param markAllSubMeshesAsMiscDirty Callback to flag the material to dirty
  101946. */
  101947. constructor(markAllSubMeshesAsMiscDirty: () => void);
  101948. /**
  101949. * Checks to see if a texture is used in the material.
  101950. * @param defines the list of "defines" to update.
  101951. */
  101952. prepareDefines(defines: IMaterialBRDFDefines): void;
  101953. /**
  101954. * Get the current class name of the texture useful for serialization or dynamic coding.
  101955. * @returns "PBRClearCoatConfiguration"
  101956. */
  101957. getClassName(): string;
  101958. /**
  101959. * Makes a duplicate of the current configuration into another one.
  101960. * @param brdfConfiguration define the config where to copy the info
  101961. */
  101962. copyTo(brdfConfiguration: PBRBRDFConfiguration): void;
  101963. /**
  101964. * Serializes this BRDF configuration.
  101965. * @returns - An object with the serialized config.
  101966. */
  101967. serialize(): any;
  101968. /**
  101969. * Parses a BRDF Configuration from a serialized object.
  101970. * @param source - Serialized object.
  101971. */
  101972. parse(source: any): void;
  101973. }
  101974. }
  101975. declare module BABYLON {
  101976. /**
  101977. * @hidden
  101978. */
  101979. export interface IMaterialSheenDefines {
  101980. SHEEN: boolean;
  101981. SHEEN_TEXTURE: boolean;
  101982. SHEEN_TEXTUREDIRECTUV: number;
  101983. SHEEN_LINKWITHALBEDO: boolean;
  101984. /** @hidden */
  101985. _areTexturesDirty: boolean;
  101986. }
  101987. /**
  101988. * Define the code related to the Sheen parameters of the pbr material.
  101989. */
  101990. export class PBRSheenConfiguration {
  101991. private _isEnabled;
  101992. /**
  101993. * Defines if the material uses sheen.
  101994. */
  101995. isEnabled: boolean;
  101996. private _linkSheenWithAlbedo;
  101997. /**
  101998. * Defines if the sheen is linked to the sheen color.
  101999. */
  102000. linkSheenWithAlbedo: boolean;
  102001. /**
  102002. * Defines the sheen intensity.
  102003. */
  102004. intensity: number;
  102005. /**
  102006. * Defines the sheen color.
  102007. */
  102008. color: Color3;
  102009. private _texture;
  102010. /**
  102011. * Stores the sheen tint values in a texture.
  102012. * rgb is tint
  102013. * a is a intensity
  102014. */
  102015. texture: Nullable<BaseTexture>;
  102016. /** @hidden */
  102017. private _internalMarkAllSubMeshesAsTexturesDirty;
  102018. /** @hidden */
  102019. _markAllSubMeshesAsTexturesDirty(): void;
  102020. /**
  102021. * Instantiate a new istance of clear coat configuration.
  102022. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  102023. */
  102024. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  102025. /**
  102026. * Specifies that the submesh is ready to be used.
  102027. * @param defines the list of "defines" to update.
  102028. * @param scene defines the scene the material belongs to.
  102029. * @returns - boolean indicating that the submesh is ready or not.
  102030. */
  102031. isReadyForSubMesh(defines: IMaterialSheenDefines, scene: Scene): boolean;
  102032. /**
  102033. * Checks to see if a texture is used in the material.
  102034. * @param defines the list of "defines" to update.
  102035. * @param scene defines the scene the material belongs to.
  102036. */
  102037. prepareDefines(defines: IMaterialSheenDefines, scene: Scene): void;
  102038. /**
  102039. * Binds the material data.
  102040. * @param uniformBuffer defines the Uniform buffer to fill in.
  102041. * @param scene defines the scene the material belongs to.
  102042. * @param isFrozen defines wether the material is frozen or not.
  102043. */
  102044. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  102045. /**
  102046. * Checks to see if a texture is used in the material.
  102047. * @param texture - Base texture to use.
  102048. * @returns - Boolean specifying if a texture is used in the material.
  102049. */
  102050. hasTexture(texture: BaseTexture): boolean;
  102051. /**
  102052. * Returns an array of the actively used textures.
  102053. * @param activeTextures Array of BaseTextures
  102054. */
  102055. getActiveTextures(activeTextures: BaseTexture[]): void;
  102056. /**
  102057. * Returns the animatable textures.
  102058. * @param animatables Array of animatable textures.
  102059. */
  102060. getAnimatables(animatables: IAnimatable[]): void;
  102061. /**
  102062. * Disposes the resources of the material.
  102063. * @param forceDisposeTextures - Forces the disposal of all textures.
  102064. */
  102065. dispose(forceDisposeTextures?: boolean): void;
  102066. /**
  102067. * Get the current class name of the texture useful for serialization or dynamic coding.
  102068. * @returns "PBRSheenConfiguration"
  102069. */
  102070. getClassName(): string;
  102071. /**
  102072. * Add fallbacks to the effect fallbacks list.
  102073. * @param defines defines the Base texture to use.
  102074. * @param fallbacks defines the current fallback list.
  102075. * @param currentRank defines the current fallback rank.
  102076. * @returns the new fallback rank.
  102077. */
  102078. static AddFallbacks(defines: IMaterialSheenDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  102079. /**
  102080. * Add the required uniforms to the current list.
  102081. * @param uniforms defines the current uniform list.
  102082. */
  102083. static AddUniforms(uniforms: string[]): void;
  102084. /**
  102085. * Add the required uniforms to the current buffer.
  102086. * @param uniformBuffer defines the current uniform buffer.
  102087. */
  102088. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  102089. /**
  102090. * Add the required samplers to the current list.
  102091. * @param samplers defines the current sampler list.
  102092. */
  102093. static AddSamplers(samplers: string[]): void;
  102094. /**
  102095. * Makes a duplicate of the current configuration into another one.
  102096. * @param sheenConfiguration define the config where to copy the info
  102097. */
  102098. copyTo(sheenConfiguration: PBRSheenConfiguration): void;
  102099. /**
  102100. * Serializes this BRDF configuration.
  102101. * @returns - An object with the serialized config.
  102102. */
  102103. serialize(): any;
  102104. /**
  102105. * Parses a Sheen Configuration from a serialized object.
  102106. * @param source - Serialized object.
  102107. */
  102108. parse(source: any): void;
  102109. }
  102110. }
  102111. declare module BABYLON {
  102112. /** @hidden */
  102113. export var pbrFragmentDeclaration: {
  102114. name: string;
  102115. shader: string;
  102116. };
  102117. }
  102118. declare module BABYLON {
  102119. /** @hidden */
  102120. export var pbrUboDeclaration: {
  102121. name: string;
  102122. shader: string;
  102123. };
  102124. }
  102125. declare module BABYLON {
  102126. /** @hidden */
  102127. export var pbrFragmentExtraDeclaration: {
  102128. name: string;
  102129. shader: string;
  102130. };
  102131. }
  102132. declare module BABYLON {
  102133. /** @hidden */
  102134. export var pbrFragmentSamplersDeclaration: {
  102135. name: string;
  102136. shader: string;
  102137. };
  102138. }
  102139. declare module BABYLON {
  102140. /** @hidden */
  102141. export var pbrHelperFunctions: {
  102142. name: string;
  102143. shader: string;
  102144. };
  102145. }
  102146. declare module BABYLON {
  102147. /** @hidden */
  102148. export var harmonicsFunctions: {
  102149. name: string;
  102150. shader: string;
  102151. };
  102152. }
  102153. declare module BABYLON {
  102154. /** @hidden */
  102155. export var pbrDirectLightingSetupFunctions: {
  102156. name: string;
  102157. shader: string;
  102158. };
  102159. }
  102160. declare module BABYLON {
  102161. /** @hidden */
  102162. export var pbrDirectLightingFalloffFunctions: {
  102163. name: string;
  102164. shader: string;
  102165. };
  102166. }
  102167. declare module BABYLON {
  102168. /** @hidden */
  102169. export var pbrBRDFFunctions: {
  102170. name: string;
  102171. shader: string;
  102172. };
  102173. }
  102174. declare module BABYLON {
  102175. /** @hidden */
  102176. export var pbrDirectLightingFunctions: {
  102177. name: string;
  102178. shader: string;
  102179. };
  102180. }
  102181. declare module BABYLON {
  102182. /** @hidden */
  102183. export var pbrIBLFunctions: {
  102184. name: string;
  102185. shader: string;
  102186. };
  102187. }
  102188. declare module BABYLON {
  102189. /** @hidden */
  102190. export var pbrDebug: {
  102191. name: string;
  102192. shader: string;
  102193. };
  102194. }
  102195. declare module BABYLON {
  102196. /** @hidden */
  102197. export var pbrPixelShader: {
  102198. name: string;
  102199. shader: string;
  102200. };
  102201. }
  102202. declare module BABYLON {
  102203. /** @hidden */
  102204. export var pbrVertexDeclaration: {
  102205. name: string;
  102206. shader: string;
  102207. };
  102208. }
  102209. declare module BABYLON {
  102210. /** @hidden */
  102211. export var pbrVertexShader: {
  102212. name: string;
  102213. shader: string;
  102214. };
  102215. }
  102216. declare module BABYLON {
  102217. /**
  102218. * The Physically based material base class of BJS.
  102219. *
  102220. * This offers the main features of a standard PBR material.
  102221. * For more information, please refer to the documentation :
  102222. * http://doc.babylonjs.com/extensions/Physically_Based_Rendering
  102223. */
  102224. export abstract class PBRBaseMaterial extends PushMaterial {
  102225. /**
  102226. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  102227. */
  102228. static readonly PBRMATERIAL_OPAQUE: number;
  102229. /**
  102230. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  102231. */
  102232. static readonly PBRMATERIAL_ALPHATEST: number;
  102233. /**
  102234. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  102235. */
  102236. static readonly PBRMATERIAL_ALPHABLEND: number;
  102237. /**
  102238. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  102239. * They are also discarded below the alpha cutoff threshold to improve performances.
  102240. */
  102241. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  102242. /**
  102243. * Defines the default value of how much AO map is occluding the analytical lights
  102244. * (point spot...).
  102245. */
  102246. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  102247. /**
  102248. * PBRMaterialLightFalloff Physical: light is falling off following the inverse squared distance law.
  102249. */
  102250. static readonly LIGHTFALLOFF_PHYSICAL: number;
  102251. /**
  102252. * PBRMaterialLightFalloff gltf: light is falling off as described in the gltf moving to PBR document
  102253. * to enhance interoperability with other engines.
  102254. */
  102255. static readonly LIGHTFALLOFF_GLTF: number;
  102256. /**
  102257. * PBRMaterialLightFalloff Standard: light is falling off like in the standard material
  102258. * to enhance interoperability with other materials.
  102259. */
  102260. static readonly LIGHTFALLOFF_STANDARD: number;
  102261. /**
  102262. * Intensity of the direct lights e.g. the four lights available in your scene.
  102263. * This impacts both the direct diffuse and specular highlights.
  102264. */
  102265. protected _directIntensity: number;
  102266. /**
  102267. * Intensity of the emissive part of the material.
  102268. * This helps controlling the emissive effect without modifying the emissive color.
  102269. */
  102270. protected _emissiveIntensity: number;
  102271. /**
  102272. * Intensity of the environment e.g. how much the environment will light the object
  102273. * either through harmonics for rough material or through the refelction for shiny ones.
  102274. */
  102275. protected _environmentIntensity: number;
  102276. /**
  102277. * This is a special control allowing the reduction of the specular highlights coming from the
  102278. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  102279. */
  102280. protected _specularIntensity: number;
  102281. /**
  102282. * This stores the direct, emissive, environment, and specular light intensities into a Vector4.
  102283. */
  102284. private _lightingInfos;
  102285. /**
  102286. * Debug Control allowing disabling the bump map on this material.
  102287. */
  102288. protected _disableBumpMap: boolean;
  102289. /**
  102290. * AKA Diffuse Texture in standard nomenclature.
  102291. */
  102292. protected _albedoTexture: BaseTexture;
  102293. /**
  102294. * AKA Occlusion Texture in other nomenclature.
  102295. */
  102296. protected _ambientTexture: BaseTexture;
  102297. /**
  102298. * AKA Occlusion Texture Intensity in other nomenclature.
  102299. */
  102300. protected _ambientTextureStrength: number;
  102301. /**
  102302. * Defines how much the AO map is occluding the analytical lights (point spot...).
  102303. * 1 means it completely occludes it
  102304. * 0 mean it has no impact
  102305. */
  102306. protected _ambientTextureImpactOnAnalyticalLights: number;
  102307. /**
  102308. * Stores the alpha values in a texture.
  102309. */
  102310. protected _opacityTexture: BaseTexture;
  102311. /**
  102312. * Stores the reflection values in a texture.
  102313. */
  102314. protected _reflectionTexture: BaseTexture;
  102315. /**
  102316. * Stores the refraction values in a texture.
  102317. */
  102318. protected _refractionTexture: BaseTexture;
  102319. /**
  102320. * Stores the emissive values in a texture.
  102321. */
  102322. protected _emissiveTexture: BaseTexture;
  102323. /**
  102324. * AKA Specular texture in other nomenclature.
  102325. */
  102326. protected _reflectivityTexture: BaseTexture;
  102327. /**
  102328. * Used to switch from specular/glossiness to metallic/roughness workflow.
  102329. */
  102330. protected _metallicTexture: BaseTexture;
  102331. /**
  102332. * Specifies the metallic scalar of the metallic/roughness workflow.
  102333. * Can also be used to scale the metalness values of the metallic texture.
  102334. */
  102335. protected _metallic: Nullable<number>;
  102336. /**
  102337. * Specifies the roughness scalar of the metallic/roughness workflow.
  102338. * Can also be used to scale the roughness values of the metallic texture.
  102339. */
  102340. protected _roughness: Nullable<number>;
  102341. /**
  102342. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  102343. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  102344. */
  102345. protected _microSurfaceTexture: BaseTexture;
  102346. /**
  102347. * Stores surface normal data used to displace a mesh in a texture.
  102348. */
  102349. protected _bumpTexture: BaseTexture;
  102350. /**
  102351. * Stores the pre-calculated light information of a mesh in a texture.
  102352. */
  102353. protected _lightmapTexture: BaseTexture;
  102354. /**
  102355. * The color of a material in ambient lighting.
  102356. */
  102357. protected _ambientColor: Color3;
  102358. /**
  102359. * AKA Diffuse Color in other nomenclature.
  102360. */
  102361. protected _albedoColor: Color3;
  102362. /**
  102363. * AKA Specular Color in other nomenclature.
  102364. */
  102365. protected _reflectivityColor: Color3;
  102366. /**
  102367. * The color applied when light is reflected from a material.
  102368. */
  102369. protected _reflectionColor: Color3;
  102370. /**
  102371. * The color applied when light is emitted from a material.
  102372. */
  102373. protected _emissiveColor: Color3;
  102374. /**
  102375. * AKA Glossiness in other nomenclature.
  102376. */
  102377. protected _microSurface: number;
  102378. /**
  102379. * source material index of refraction (IOR)' / 'destination material IOR.
  102380. */
  102381. protected _indexOfRefraction: number;
  102382. /**
  102383. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  102384. */
  102385. protected _invertRefractionY: boolean;
  102386. /**
  102387. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  102388. * Materials half opaque for instance using refraction could benefit from this control.
  102389. */
  102390. protected _linkRefractionWithTransparency: boolean;
  102391. /**
  102392. * Specifies that the material will use the light map as a show map.
  102393. */
  102394. protected _useLightmapAsShadowmap: boolean;
  102395. /**
  102396. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  102397. * makes the reflect vector face the model (under horizon).
  102398. */
  102399. protected _useHorizonOcclusion: boolean;
  102400. /**
  102401. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  102402. * too much the area relying on ambient texture to define their ambient occlusion.
  102403. */
  102404. protected _useRadianceOcclusion: boolean;
  102405. /**
  102406. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  102407. */
  102408. protected _useAlphaFromAlbedoTexture: boolean;
  102409. /**
  102410. * Specifies that the material will keeps the specular highlights over a transparent surface (only the most limunous ones).
  102411. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  102412. */
  102413. protected _useSpecularOverAlpha: boolean;
  102414. /**
  102415. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  102416. */
  102417. protected _useMicroSurfaceFromReflectivityMapAlpha: boolean;
  102418. /**
  102419. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  102420. */
  102421. protected _useRoughnessFromMetallicTextureAlpha: boolean;
  102422. /**
  102423. * Specifies if the metallic texture contains the roughness information in its green channel.
  102424. */
  102425. protected _useRoughnessFromMetallicTextureGreen: boolean;
  102426. /**
  102427. * Specifies if the metallic texture contains the metallness information in its blue channel.
  102428. */
  102429. protected _useMetallnessFromMetallicTextureBlue: boolean;
  102430. /**
  102431. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  102432. */
  102433. protected _useAmbientOcclusionFromMetallicTextureRed: boolean;
  102434. /**
  102435. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  102436. */
  102437. protected _useAmbientInGrayScale: boolean;
  102438. /**
  102439. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  102440. * The material will try to infer what glossiness each pixel should be.
  102441. */
  102442. protected _useAutoMicroSurfaceFromReflectivityMap: boolean;
  102443. /**
  102444. * Defines the falloff type used in this material.
  102445. * It by default is Physical.
  102446. */
  102447. protected _lightFalloff: number;
  102448. /**
  102449. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  102450. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  102451. */
  102452. protected _useRadianceOverAlpha: boolean;
  102453. /**
  102454. * Allows using an object space normal map (instead of tangent space).
  102455. */
  102456. protected _useObjectSpaceNormalMap: boolean;
  102457. /**
  102458. * Allows using the bump map in parallax mode.
  102459. */
  102460. protected _useParallax: boolean;
  102461. /**
  102462. * Allows using the bump map in parallax occlusion mode.
  102463. */
  102464. protected _useParallaxOcclusion: boolean;
  102465. /**
  102466. * Controls the scale bias of the parallax mode.
  102467. */
  102468. protected _parallaxScaleBias: number;
  102469. /**
  102470. * If sets to true, disables all the lights affecting the material.
  102471. */
  102472. protected _disableLighting: boolean;
  102473. /**
  102474. * Number of Simultaneous lights allowed on the material.
  102475. */
  102476. protected _maxSimultaneousLights: number;
  102477. /**
  102478. * If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  102479. */
  102480. protected _invertNormalMapX: boolean;
  102481. /**
  102482. * If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  102483. */
  102484. protected _invertNormalMapY: boolean;
  102485. /**
  102486. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  102487. */
  102488. protected _twoSidedLighting: boolean;
  102489. /**
  102490. * Defines the alpha limits in alpha test mode.
  102491. */
  102492. protected _alphaCutOff: number;
  102493. /**
  102494. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  102495. */
  102496. protected _forceAlphaTest: boolean;
  102497. /**
  102498. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  102499. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  102500. */
  102501. protected _useAlphaFresnel: boolean;
  102502. /**
  102503. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  102504. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  102505. */
  102506. protected _useLinearAlphaFresnel: boolean;
  102507. /**
  102508. * The transparency mode of the material.
  102509. */
  102510. protected _transparencyMode: Nullable<number>;
  102511. /**
  102512. * Specifies the environment BRDF texture used to comput the scale and offset roughness values
  102513. * from cos thetav and roughness:
  102514. * http://blog.selfshadow.com/publications/s2013-shading-course/karis/s2013_pbs_epic_notes_v2.pdf
  102515. */
  102516. protected _environmentBRDFTexture: Nullable<BaseTexture>;
  102517. /**
  102518. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  102519. */
  102520. protected _forceIrradianceInFragment: boolean;
  102521. /**
  102522. * Force normal to face away from face.
  102523. */
  102524. protected _forceNormalForward: boolean;
  102525. /**
  102526. * Enables specular anti aliasing in the PBR shader.
  102527. * It will both interacts on the Geometry for analytical and IBL lighting.
  102528. * It also prefilter the roughness map based on the bump values.
  102529. */
  102530. protected _enableSpecularAntiAliasing: boolean;
  102531. /**
  102532. * Default configuration related to image processing available in the PBR Material.
  102533. */
  102534. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  102535. /**
  102536. * Keep track of the image processing observer to allow dispose and replace.
  102537. */
  102538. private _imageProcessingObserver;
  102539. /**
  102540. * Attaches a new image processing configuration to the PBR Material.
  102541. * @param configuration
  102542. */
  102543. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  102544. /**
  102545. * Stores the available render targets.
  102546. */
  102547. private _renderTargets;
  102548. /**
  102549. * Sets the global ambient color for the material used in lighting calculations.
  102550. */
  102551. private _globalAmbientColor;
  102552. /**
  102553. * Enables the use of logarithmic depth buffers, which is good for wide depth buffers.
  102554. */
  102555. private _useLogarithmicDepth;
  102556. /**
  102557. * If set to true, no lighting calculations will be applied.
  102558. */
  102559. private _unlit;
  102560. private _debugMode;
  102561. /**
  102562. * @hidden
  102563. * This is reserved for the inspector.
  102564. * Defines the material debug mode.
  102565. * It helps seeing only some components of the material while troubleshooting.
  102566. */
  102567. debugMode: number;
  102568. /**
  102569. * @hidden
  102570. * This is reserved for the inspector.
  102571. * Specify from where on screen the debug mode should start.
  102572. * The value goes from -1 (full screen) to 1 (not visible)
  102573. * It helps with side by side comparison against the final render
  102574. * This defaults to -1
  102575. */
  102576. private debugLimit;
  102577. /**
  102578. * @hidden
  102579. * This is reserved for the inspector.
  102580. * As the default viewing range might not be enough (if the ambient is really small for instance)
  102581. * You can use the factor to better multiply the final value.
  102582. */
  102583. private debugFactor;
  102584. /**
  102585. * Defines the clear coat layer parameters for the material.
  102586. */
  102587. readonly clearCoat: PBRClearCoatConfiguration;
  102588. /**
  102589. * Defines the anisotropic parameters for the material.
  102590. */
  102591. readonly anisotropy: PBRAnisotropicConfiguration;
  102592. /**
  102593. * Defines the BRDF parameters for the material.
  102594. */
  102595. readonly brdf: PBRBRDFConfiguration;
  102596. /**
  102597. * Defines the Sheen parameters for the material.
  102598. */
  102599. readonly sheen: PBRSheenConfiguration;
  102600. /**
  102601. * Instantiates a new PBRMaterial instance.
  102602. *
  102603. * @param name The material name
  102604. * @param scene The scene the material will be use in.
  102605. */
  102606. constructor(name: string, scene: Scene);
  102607. /**
  102608. * Gets a boolean indicating that current material needs to register RTT
  102609. */
  102610. readonly hasRenderTargetTextures: boolean;
  102611. /**
  102612. * Gets the name of the material class.
  102613. */
  102614. getClassName(): string;
  102615. /**
  102616. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  102617. */
  102618. /**
  102619. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  102620. */
  102621. useLogarithmicDepth: boolean;
  102622. /**
  102623. * Gets the current transparency mode.
  102624. */
  102625. /**
  102626. * Sets the transparency mode of the material.
  102627. *
  102628. * | Value | Type | Description |
  102629. * | ----- | ----------------------------------- | ----------- |
  102630. * | 0 | OPAQUE | |
  102631. * | 1 | ALPHATEST | |
  102632. * | 2 | ALPHABLEND | |
  102633. * | 3 | ALPHATESTANDBLEND | |
  102634. *
  102635. */
  102636. transparencyMode: Nullable<number>;
  102637. /**
  102638. * Returns true if alpha blending should be disabled.
  102639. */
  102640. private readonly _disableAlphaBlending;
  102641. /**
  102642. * Specifies whether or not this material should be rendered in alpha blend mode.
  102643. */
  102644. needAlphaBlending(): boolean;
  102645. /**
  102646. * Specifies if the mesh will require alpha blending.
  102647. * @param mesh - BJS mesh.
  102648. */
  102649. needAlphaBlendingForMesh(mesh: AbstractMesh): boolean;
  102650. /**
  102651. * Specifies whether or not this material should be rendered in alpha test mode.
  102652. */
  102653. needAlphaTesting(): boolean;
  102654. /**
  102655. * Specifies whether or not the alpha value of the albedo texture should be used for alpha blending.
  102656. */
  102657. protected _shouldUseAlphaFromAlbedoTexture(): boolean;
  102658. /**
  102659. * Gets the texture used for the alpha test.
  102660. */
  102661. getAlphaTestTexture(): BaseTexture;
  102662. /**
  102663. * Specifies that the submesh is ready to be used.
  102664. * @param mesh - BJS mesh.
  102665. * @param subMesh - A submesh of the BJS mesh. Used to check if it is ready.
  102666. * @param useInstances - Specifies that instances should be used.
  102667. * @returns - boolean indicating that the submesh is ready or not.
  102668. */
  102669. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  102670. /**
  102671. * Specifies if the material uses metallic roughness workflow.
  102672. * @returns boolean specifiying if the material uses metallic roughness workflow.
  102673. */
  102674. isMetallicWorkflow(): boolean;
  102675. private _prepareEffect;
  102676. private _prepareDefines;
  102677. /**
  102678. * Force shader compilation
  102679. */
  102680. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<{
  102681. clipPlane: boolean;
  102682. }>): void;
  102683. /**
  102684. * Initializes the uniform buffer layout for the shader.
  102685. */
  102686. buildUniformLayout(): void;
  102687. /**
  102688. * Unbinds the textures.
  102689. */
  102690. unbind(): void;
  102691. /**
  102692. * Binds the submesh data.
  102693. * @param world - The world matrix.
  102694. * @param mesh - The BJS mesh.
  102695. * @param subMesh - A submesh of the BJS mesh.
  102696. */
  102697. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  102698. /**
  102699. * Returns the animatable textures.
  102700. * @returns - Array of animatable textures.
  102701. */
  102702. getAnimatables(): IAnimatable[];
  102703. /**
  102704. * Returns the texture used for reflections.
  102705. * @returns - Reflection texture if present. Otherwise, returns the environment texture.
  102706. */
  102707. private _getReflectionTexture;
  102708. /**
  102709. * Returns the texture used for refraction or null if none is used.
  102710. * @returns - Refection texture if present. If no refraction texture and refraction
  102711. * is linked with transparency, returns environment texture. Otherwise, returns null.
  102712. */
  102713. private _getRefractionTexture;
  102714. /**
  102715. * Returns an array of the actively used textures.
  102716. * @returns - Array of BaseTextures
  102717. */
  102718. getActiveTextures(): BaseTexture[];
  102719. /**
  102720. * Checks to see if a texture is used in the material.
  102721. * @param texture - Base texture to use.
  102722. * @returns - Boolean specifying if a texture is used in the material.
  102723. */
  102724. hasTexture(texture: BaseTexture): boolean;
  102725. /**
  102726. * Disposes the resources of the material.
  102727. * @param forceDisposeEffect - Forces the disposal of effects.
  102728. * @param forceDisposeTextures - Forces the disposal of all textures.
  102729. */
  102730. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  102731. }
  102732. }
  102733. declare module BABYLON {
  102734. /**
  102735. * The Physically based material of BJS.
  102736. *
  102737. * This offers the main features of a standard PBR material.
  102738. * For more information, please refer to the documentation :
  102739. * http://doc.babylonjs.com/extensions/Physically_Based_Rendering
  102740. */
  102741. export class PBRMaterial extends PBRBaseMaterial {
  102742. /**
  102743. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  102744. */
  102745. static readonly PBRMATERIAL_OPAQUE: number;
  102746. /**
  102747. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  102748. */
  102749. static readonly PBRMATERIAL_ALPHATEST: number;
  102750. /**
  102751. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  102752. */
  102753. static readonly PBRMATERIAL_ALPHABLEND: number;
  102754. /**
  102755. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  102756. * They are also discarded below the alpha cutoff threshold to improve performances.
  102757. */
  102758. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  102759. /**
  102760. * Defines the default value of how much AO map is occluding the analytical lights
  102761. * (point spot...).
  102762. */
  102763. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  102764. /**
  102765. * Intensity of the direct lights e.g. the four lights available in your scene.
  102766. * This impacts both the direct diffuse and specular highlights.
  102767. */
  102768. directIntensity: number;
  102769. /**
  102770. * Intensity of the emissive part of the material.
  102771. * This helps controlling the emissive effect without modifying the emissive color.
  102772. */
  102773. emissiveIntensity: number;
  102774. /**
  102775. * Intensity of the environment e.g. how much the environment will light the object
  102776. * either through harmonics for rough material or through the refelction for shiny ones.
  102777. */
  102778. environmentIntensity: number;
  102779. /**
  102780. * This is a special control allowing the reduction of the specular highlights coming from the
  102781. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  102782. */
  102783. specularIntensity: number;
  102784. /**
  102785. * Debug Control allowing disabling the bump map on this material.
  102786. */
  102787. disableBumpMap: boolean;
  102788. /**
  102789. * AKA Diffuse Texture in standard nomenclature.
  102790. */
  102791. albedoTexture: BaseTexture;
  102792. /**
  102793. * AKA Occlusion Texture in other nomenclature.
  102794. */
  102795. ambientTexture: BaseTexture;
  102796. /**
  102797. * AKA Occlusion Texture Intensity in other nomenclature.
  102798. */
  102799. ambientTextureStrength: number;
  102800. /**
  102801. * Defines how much the AO map is occluding the analytical lights (point spot...).
  102802. * 1 means it completely occludes it
  102803. * 0 mean it has no impact
  102804. */
  102805. ambientTextureImpactOnAnalyticalLights: number;
  102806. /**
  102807. * Stores the alpha values in a texture.
  102808. */
  102809. opacityTexture: BaseTexture;
  102810. /**
  102811. * Stores the reflection values in a texture.
  102812. */
  102813. reflectionTexture: Nullable<BaseTexture>;
  102814. /**
  102815. * Stores the emissive values in a texture.
  102816. */
  102817. emissiveTexture: BaseTexture;
  102818. /**
  102819. * AKA Specular texture in other nomenclature.
  102820. */
  102821. reflectivityTexture: BaseTexture;
  102822. /**
  102823. * Used to switch from specular/glossiness to metallic/roughness workflow.
  102824. */
  102825. metallicTexture: BaseTexture;
  102826. /**
  102827. * Specifies the metallic scalar of the metallic/roughness workflow.
  102828. * Can also be used to scale the metalness values of the metallic texture.
  102829. */
  102830. metallic: Nullable<number>;
  102831. /**
  102832. * Specifies the roughness scalar of the metallic/roughness workflow.
  102833. * Can also be used to scale the roughness values of the metallic texture.
  102834. */
  102835. roughness: Nullable<number>;
  102836. /**
  102837. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  102838. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  102839. */
  102840. microSurfaceTexture: BaseTexture;
  102841. /**
  102842. * Stores surface normal data used to displace a mesh in a texture.
  102843. */
  102844. bumpTexture: BaseTexture;
  102845. /**
  102846. * Stores the pre-calculated light information of a mesh in a texture.
  102847. */
  102848. lightmapTexture: BaseTexture;
  102849. /**
  102850. * Stores the refracted light information in a texture.
  102851. */
  102852. refractionTexture: BaseTexture;
  102853. /**
  102854. * The color of a material in ambient lighting.
  102855. */
  102856. ambientColor: Color3;
  102857. /**
  102858. * AKA Diffuse Color in other nomenclature.
  102859. */
  102860. albedoColor: Color3;
  102861. /**
  102862. * AKA Specular Color in other nomenclature.
  102863. */
  102864. reflectivityColor: Color3;
  102865. /**
  102866. * The color reflected from the material.
  102867. */
  102868. reflectionColor: Color3;
  102869. /**
  102870. * The color emitted from the material.
  102871. */
  102872. emissiveColor: Color3;
  102873. /**
  102874. * AKA Glossiness in other nomenclature.
  102875. */
  102876. microSurface: number;
  102877. /**
  102878. * source material index of refraction (IOR)' / 'destination material IOR.
  102879. */
  102880. indexOfRefraction: number;
  102881. /**
  102882. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  102883. */
  102884. invertRefractionY: boolean;
  102885. /**
  102886. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  102887. * Materials half opaque for instance using refraction could benefit from this control.
  102888. */
  102889. linkRefractionWithTransparency: boolean;
  102890. /**
  102891. * If true, the light map contains occlusion information instead of lighting info.
  102892. */
  102893. useLightmapAsShadowmap: boolean;
  102894. /**
  102895. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  102896. */
  102897. useAlphaFromAlbedoTexture: boolean;
  102898. /**
  102899. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  102900. */
  102901. forceAlphaTest: boolean;
  102902. /**
  102903. * Defines the alpha limits in alpha test mode.
  102904. */
  102905. alphaCutOff: number;
  102906. /**
  102907. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  102908. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  102909. */
  102910. useSpecularOverAlpha: boolean;
  102911. /**
  102912. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  102913. */
  102914. useMicroSurfaceFromReflectivityMapAlpha: boolean;
  102915. /**
  102916. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  102917. */
  102918. useRoughnessFromMetallicTextureAlpha: boolean;
  102919. /**
  102920. * Specifies if the metallic texture contains the roughness information in its green channel.
  102921. */
  102922. useRoughnessFromMetallicTextureGreen: boolean;
  102923. /**
  102924. * Specifies if the metallic texture contains the metallness information in its blue channel.
  102925. */
  102926. useMetallnessFromMetallicTextureBlue: boolean;
  102927. /**
  102928. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  102929. */
  102930. useAmbientOcclusionFromMetallicTextureRed: boolean;
  102931. /**
  102932. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  102933. */
  102934. useAmbientInGrayScale: boolean;
  102935. /**
  102936. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  102937. * The material will try to infer what glossiness each pixel should be.
  102938. */
  102939. useAutoMicroSurfaceFromReflectivityMap: boolean;
  102940. /**
  102941. * BJS is using an harcoded light falloff based on a manually sets up range.
  102942. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  102943. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  102944. */
  102945. /**
  102946. * BJS is using an harcoded light falloff based on a manually sets up range.
  102947. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  102948. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  102949. */
  102950. usePhysicalLightFalloff: boolean;
  102951. /**
  102952. * In order to support the falloff compatibility with gltf, a special mode has been added
  102953. * to reproduce the gltf light falloff.
  102954. */
  102955. /**
  102956. * In order to support the falloff compatibility with gltf, a special mode has been added
  102957. * to reproduce the gltf light falloff.
  102958. */
  102959. useGLTFLightFalloff: boolean;
  102960. /**
  102961. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  102962. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  102963. */
  102964. useRadianceOverAlpha: boolean;
  102965. /**
  102966. * Allows using an object space normal map (instead of tangent space).
  102967. */
  102968. useObjectSpaceNormalMap: boolean;
  102969. /**
  102970. * Allows using the bump map in parallax mode.
  102971. */
  102972. useParallax: boolean;
  102973. /**
  102974. * Allows using the bump map in parallax occlusion mode.
  102975. */
  102976. useParallaxOcclusion: boolean;
  102977. /**
  102978. * Controls the scale bias of the parallax mode.
  102979. */
  102980. parallaxScaleBias: number;
  102981. /**
  102982. * If sets to true, disables all the lights affecting the material.
  102983. */
  102984. disableLighting: boolean;
  102985. /**
  102986. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  102987. */
  102988. forceIrradianceInFragment: boolean;
  102989. /**
  102990. * Number of Simultaneous lights allowed on the material.
  102991. */
  102992. maxSimultaneousLights: number;
  102993. /**
  102994. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  102995. */
  102996. invertNormalMapX: boolean;
  102997. /**
  102998. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  102999. */
  103000. invertNormalMapY: boolean;
  103001. /**
  103002. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  103003. */
  103004. twoSidedLighting: boolean;
  103005. /**
  103006. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  103007. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  103008. */
  103009. useAlphaFresnel: boolean;
  103010. /**
  103011. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  103012. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  103013. */
  103014. useLinearAlphaFresnel: boolean;
  103015. /**
  103016. * Let user defines the brdf lookup texture used for IBL.
  103017. * A default 8bit version is embedded but you could point at :
  103018. * * Default texture: https://assets.babylonjs.com/environments/correlatedMSBRDF.png
  103019. * * Default 16bit pixel depth texture: https://assets.babylonjs.com/environments/correlatedMSBRDF.dds
  103020. * * LEGACY Default None correlated https://assets.babylonjs.com/environments/uncorrelatedBRDF.png
  103021. * * LEGACY Default None correlated 16bit pixel depth https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds
  103022. */
  103023. environmentBRDFTexture: Nullable<BaseTexture>;
  103024. /**
  103025. * Force normal to face away from face.
  103026. */
  103027. forceNormalForward: boolean;
  103028. /**
  103029. * Enables specular anti aliasing in the PBR shader.
  103030. * It will both interacts on the Geometry for analytical and IBL lighting.
  103031. * It also prefilter the roughness map based on the bump values.
  103032. */
  103033. enableSpecularAntiAliasing: boolean;
  103034. /**
  103035. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  103036. * makes the reflect vector face the model (under horizon).
  103037. */
  103038. useHorizonOcclusion: boolean;
  103039. /**
  103040. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  103041. * too much the area relying on ambient texture to define their ambient occlusion.
  103042. */
  103043. useRadianceOcclusion: boolean;
  103044. /**
  103045. * If set to true, no lighting calculations will be applied.
  103046. */
  103047. unlit: boolean;
  103048. /**
  103049. * Gets the image processing configuration used either in this material.
  103050. */
  103051. /**
  103052. * Sets the Default image processing configuration used either in the this material.
  103053. *
  103054. * If sets to null, the scene one is in use.
  103055. */
  103056. imageProcessingConfiguration: ImageProcessingConfiguration;
  103057. /**
  103058. * Gets wether the color curves effect is enabled.
  103059. */
  103060. /**
  103061. * Sets wether the color curves effect is enabled.
  103062. */
  103063. cameraColorCurvesEnabled: boolean;
  103064. /**
  103065. * Gets wether the color grading effect is enabled.
  103066. */
  103067. /**
  103068. * Gets wether the color grading effect is enabled.
  103069. */
  103070. cameraColorGradingEnabled: boolean;
  103071. /**
  103072. * Gets wether tonemapping is enabled or not.
  103073. */
  103074. /**
  103075. * Sets wether tonemapping is enabled or not
  103076. */
  103077. cameraToneMappingEnabled: boolean;
  103078. /**
  103079. * The camera exposure used on this material.
  103080. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  103081. * This corresponds to a photographic exposure.
  103082. */
  103083. /**
  103084. * The camera exposure used on this material.
  103085. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  103086. * This corresponds to a photographic exposure.
  103087. */
  103088. cameraExposure: number;
  103089. /**
  103090. * Gets The camera contrast used on this material.
  103091. */
  103092. /**
  103093. * Sets The camera contrast used on this material.
  103094. */
  103095. cameraContrast: number;
  103096. /**
  103097. * Gets the Color Grading 2D Lookup Texture.
  103098. */
  103099. /**
  103100. * Sets the Color Grading 2D Lookup Texture.
  103101. */
  103102. cameraColorGradingTexture: Nullable<BaseTexture>;
  103103. /**
  103104. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  103105. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  103106. * 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;
  103107. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  103108. */
  103109. /**
  103110. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  103111. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  103112. * 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;
  103113. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  103114. */
  103115. cameraColorCurves: Nullable<ColorCurves>;
  103116. /**
  103117. * Instantiates a new PBRMaterial instance.
  103118. *
  103119. * @param name The material name
  103120. * @param scene The scene the material will be use in.
  103121. */
  103122. constructor(name: string, scene: Scene);
  103123. /**
  103124. * Returns the name of this material class.
  103125. */
  103126. getClassName(): string;
  103127. /**
  103128. * Makes a duplicate of the current material.
  103129. * @param name - name to use for the new material.
  103130. */
  103131. clone(name: string): PBRMaterial;
  103132. /**
  103133. * Serializes this PBR Material.
  103134. * @returns - An object with the serialized material.
  103135. */
  103136. serialize(): any;
  103137. /**
  103138. * Parses a PBR Material from a serialized object.
  103139. * @param source - Serialized object.
  103140. * @param scene - BJS scene instance.
  103141. * @param rootUrl - url for the scene object
  103142. * @returns - PBRMaterial
  103143. */
  103144. static Parse(source: any, scene: Scene, rootUrl: string): PBRMaterial;
  103145. }
  103146. }
  103147. declare module BABYLON {
  103148. /**
  103149. * Direct draw surface info
  103150. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dx-graphics-dds-pguide
  103151. */
  103152. export interface DDSInfo {
  103153. /**
  103154. * Width of the texture
  103155. */
  103156. width: number;
  103157. /**
  103158. * Width of the texture
  103159. */
  103160. height: number;
  103161. /**
  103162. * Number of Mipmaps for the texture
  103163. * @see https://en.wikipedia.org/wiki/Mipmap
  103164. */
  103165. mipmapCount: number;
  103166. /**
  103167. * If the textures format is a known fourCC format
  103168. * @see https://www.fourcc.org/
  103169. */
  103170. isFourCC: boolean;
  103171. /**
  103172. * If the texture is an RGB format eg. DXGI_FORMAT_B8G8R8X8_UNORM format
  103173. */
  103174. isRGB: boolean;
  103175. /**
  103176. * If the texture is a lumincance format
  103177. */
  103178. isLuminance: boolean;
  103179. /**
  103180. * If this is a cube texture
  103181. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dds-file-layout-for-cubic-environment-maps
  103182. */
  103183. isCube: boolean;
  103184. /**
  103185. * If the texture is a compressed format eg. FOURCC_DXT1
  103186. */
  103187. isCompressed: boolean;
  103188. /**
  103189. * The dxgiFormat of the texture
  103190. * @see https://docs.microsoft.com/en-us/windows/desktop/api/dxgiformat/ne-dxgiformat-dxgi_format
  103191. */
  103192. dxgiFormat: number;
  103193. /**
  103194. * Texture type eg. Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT
  103195. */
  103196. textureType: number;
  103197. /**
  103198. * Sphericle polynomial created for the dds texture
  103199. */
  103200. sphericalPolynomial?: SphericalPolynomial;
  103201. }
  103202. /**
  103203. * Class used to provide DDS decompression tools
  103204. */
  103205. export class DDSTools {
  103206. /**
  103207. * Gets or sets a boolean indicating that LOD info is stored in alpha channel (false by default)
  103208. */
  103209. static StoreLODInAlphaChannel: boolean;
  103210. /**
  103211. * Gets DDS information from an array buffer
  103212. * @param arrayBuffer defines the array buffer to read data from
  103213. * @returns the DDS information
  103214. */
  103215. static GetDDSInfo(arrayBuffer: any): DDSInfo;
  103216. private static _FloatView;
  103217. private static _Int32View;
  103218. private static _ToHalfFloat;
  103219. private static _FromHalfFloat;
  103220. private static _GetHalfFloatAsFloatRGBAArrayBuffer;
  103221. private static _GetHalfFloatRGBAArrayBuffer;
  103222. private static _GetFloatRGBAArrayBuffer;
  103223. private static _GetFloatAsUIntRGBAArrayBuffer;
  103224. private static _GetHalfFloatAsUIntRGBAArrayBuffer;
  103225. private static _GetRGBAArrayBuffer;
  103226. private static _ExtractLongWordOrder;
  103227. private static _GetRGBArrayBuffer;
  103228. private static _GetLuminanceArrayBuffer;
  103229. /**
  103230. * Uploads DDS Levels to a Babylon Texture
  103231. * @hidden
  103232. */
  103233. static UploadDDSLevels(engine: Engine, texture: InternalTexture, arrayBuffer: any, info: DDSInfo, loadMipmaps: boolean, faces: number, lodIndex?: number, currentFace?: number): void;
  103234. }
  103235. interface Engine {
  103236. /**
  103237. * Create a cube texture from prefiltered data (ie. the mipmaps contain ready to use data for PBR reflection)
  103238. * @param rootUrl defines the url where the file to load is located
  103239. * @param scene defines the current scene
  103240. * @param lodScale defines scale to apply to the mip map selection
  103241. * @param lodOffset defines offset to apply to the mip map selection
  103242. * @param onLoad defines an optional callback raised when the texture is loaded
  103243. * @param onError defines an optional callback raised if there is an issue to load the texture
  103244. * @param format defines the format of the data
  103245. * @param forcedExtension defines the extension to use to pick the right loader
  103246. * @param createPolynomials defines wheter or not to create polynomails harmonics for the texture
  103247. * @returns the cube texture as an InternalTexture
  103248. */
  103249. 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;
  103250. }
  103251. }
  103252. declare module BABYLON {
  103253. /**
  103254. * Implementation of the DDS Texture Loader.
  103255. * @hidden
  103256. */
  103257. export class _DDSTextureLoader implements IInternalTextureLoader {
  103258. /**
  103259. * Defines wether the loader supports cascade loading the different faces.
  103260. */
  103261. readonly supportCascades: boolean;
  103262. /**
  103263. * This returns if the loader support the current file information.
  103264. * @param extension defines the file extension of the file being loaded
  103265. * @param textureFormatInUse defines the current compressed format in use iun the engine
  103266. * @param fallback defines the fallback internal texture if any
  103267. * @param isBase64 defines whether the texture is encoded as a base64
  103268. * @param isBuffer defines whether the texture data are stored as a buffer
  103269. * @returns true if the loader can load the specified file
  103270. */
  103271. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  103272. /**
  103273. * Transform the url before loading if required.
  103274. * @param rootUrl the url of the texture
  103275. * @param textureFormatInUse defines the current compressed format in use iun the engine
  103276. * @returns the transformed texture
  103277. */
  103278. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  103279. /**
  103280. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  103281. * @param rootUrl the url of the texture
  103282. * @param textureFormatInUse defines the current compressed format in use iun the engine
  103283. * @returns the fallback texture
  103284. */
  103285. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  103286. /**
  103287. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  103288. * @param data contains the texture data
  103289. * @param texture defines the BabylonJS internal texture
  103290. * @param createPolynomials will be true if polynomials have been requested
  103291. * @param onLoad defines the callback to trigger once the texture is ready
  103292. * @param onError defines the callback to trigger in case of error
  103293. */
  103294. loadCubeData(imgs: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  103295. /**
  103296. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  103297. * @param data contains the texture data
  103298. * @param texture defines the BabylonJS internal texture
  103299. * @param callback defines the method to call once ready to upload
  103300. */
  103301. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  103302. }
  103303. }
  103304. declare module BABYLON {
  103305. /** @hidden */
  103306. export var rgbdEncodePixelShader: {
  103307. name: string;
  103308. shader: string;
  103309. };
  103310. }
  103311. declare module BABYLON {
  103312. /** @hidden */
  103313. export var rgbdDecodePixelShader: {
  103314. name: string;
  103315. shader: string;
  103316. };
  103317. }
  103318. declare module BABYLON {
  103319. /**
  103320. * Raw texture data and descriptor sufficient for WebGL texture upload
  103321. */
  103322. export interface EnvironmentTextureInfo {
  103323. /**
  103324. * Version of the environment map
  103325. */
  103326. version: number;
  103327. /**
  103328. * Width of image
  103329. */
  103330. width: number;
  103331. /**
  103332. * Irradiance information stored in the file.
  103333. */
  103334. irradiance: any;
  103335. /**
  103336. * Specular information stored in the file.
  103337. */
  103338. specular: any;
  103339. }
  103340. /**
  103341. * Sets of helpers addressing the serialization and deserialization of environment texture
  103342. * stored in a BabylonJS env file.
  103343. * Those files are usually stored as .env files.
  103344. */
  103345. export class EnvironmentTextureTools {
  103346. /**
  103347. * Magic number identifying the env file.
  103348. */
  103349. private static _MagicBytes;
  103350. /**
  103351. * Gets the environment info from an env file.
  103352. * @param data The array buffer containing the .env bytes.
  103353. * @returns the environment file info (the json header) if successfully parsed.
  103354. */
  103355. static GetEnvInfo(data: ArrayBuffer): Nullable<EnvironmentTextureInfo>;
  103356. /**
  103357. * Creates an environment texture from a loaded cube texture.
  103358. * @param texture defines the cube texture to convert in env file
  103359. * @return a promise containing the environment data if succesfull.
  103360. */
  103361. static CreateEnvTextureAsync(texture: CubeTexture): Promise<ArrayBuffer>;
  103362. /**
  103363. * Creates a JSON representation of the spherical data.
  103364. * @param texture defines the texture containing the polynomials
  103365. * @return the JSON representation of the spherical info
  103366. */
  103367. private static _CreateEnvTextureIrradiance;
  103368. /**
  103369. * Uploads the texture info contained in the env file to the GPU.
  103370. * @param texture defines the internal texture to upload to
  103371. * @param arrayBuffer defines the buffer cotaining the data to load
  103372. * @param info defines the texture info retrieved through the GetEnvInfo method
  103373. * @returns a promise
  103374. */
  103375. static UploadEnvLevelsAsync(texture: InternalTexture, arrayBuffer: any, info: EnvironmentTextureInfo): Promise<void>;
  103376. /**
  103377. * Uploads the levels of image data to the GPU.
  103378. * @param texture defines the internal texture to upload to
  103379. * @param imageData defines the array buffer views of image data [mipmap][face]
  103380. * @returns a promise
  103381. */
  103382. static UploadLevelsAsync(texture: InternalTexture, imageData: ArrayBufferView[][]): Promise<void>;
  103383. /**
  103384. * Uploads spherical polynomials information to the texture.
  103385. * @param texture defines the texture we are trying to upload the information to
  103386. * @param info defines the environment texture info retrieved through the GetEnvInfo method
  103387. */
  103388. static UploadEnvSpherical(texture: InternalTexture, info: EnvironmentTextureInfo): void;
  103389. /** @hidden */
  103390. static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  103391. }
  103392. }
  103393. declare module BABYLON {
  103394. /**
  103395. * Implementation of the ENV Texture Loader.
  103396. * @hidden
  103397. */
  103398. export class _ENVTextureLoader implements IInternalTextureLoader {
  103399. /**
  103400. * Defines wether the loader supports cascade loading the different faces.
  103401. */
  103402. readonly supportCascades: boolean;
  103403. /**
  103404. * This returns if the loader support the current file information.
  103405. * @param extension defines the file extension of the file being loaded
  103406. * @param textureFormatInUse defines the current compressed format in use iun the engine
  103407. * @param fallback defines the fallback internal texture if any
  103408. * @param isBase64 defines whether the texture is encoded as a base64
  103409. * @param isBuffer defines whether the texture data are stored as a buffer
  103410. * @returns true if the loader can load the specified file
  103411. */
  103412. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  103413. /**
  103414. * Transform the url before loading if required.
  103415. * @param rootUrl the url of the texture
  103416. * @param textureFormatInUse defines the current compressed format in use iun the engine
  103417. * @returns the transformed texture
  103418. */
  103419. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  103420. /**
  103421. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  103422. * @param rootUrl the url of the texture
  103423. * @param textureFormatInUse defines the current compressed format in use iun the engine
  103424. * @returns the fallback texture
  103425. */
  103426. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  103427. /**
  103428. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  103429. * @param data contains the texture data
  103430. * @param texture defines the BabylonJS internal texture
  103431. * @param createPolynomials will be true if polynomials have been requested
  103432. * @param onLoad defines the callback to trigger once the texture is ready
  103433. * @param onError defines the callback to trigger in case of error
  103434. */
  103435. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  103436. /**
  103437. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  103438. * @param data contains the texture data
  103439. * @param texture defines the BabylonJS internal texture
  103440. * @param callback defines the method to call once ready to upload
  103441. */
  103442. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  103443. }
  103444. }
  103445. declare module BABYLON {
  103446. /**
  103447. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  103448. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  103449. */
  103450. export class KhronosTextureContainer {
  103451. /** contents of the KTX container file */
  103452. arrayBuffer: any;
  103453. private static HEADER_LEN;
  103454. private static COMPRESSED_2D;
  103455. private static COMPRESSED_3D;
  103456. private static TEX_2D;
  103457. private static TEX_3D;
  103458. /**
  103459. * Gets the openGL type
  103460. */
  103461. glType: number;
  103462. /**
  103463. * Gets the openGL type size
  103464. */
  103465. glTypeSize: number;
  103466. /**
  103467. * Gets the openGL format
  103468. */
  103469. glFormat: number;
  103470. /**
  103471. * Gets the openGL internal format
  103472. */
  103473. glInternalFormat: number;
  103474. /**
  103475. * Gets the base internal format
  103476. */
  103477. glBaseInternalFormat: number;
  103478. /**
  103479. * Gets image width in pixel
  103480. */
  103481. pixelWidth: number;
  103482. /**
  103483. * Gets image height in pixel
  103484. */
  103485. pixelHeight: number;
  103486. /**
  103487. * Gets image depth in pixels
  103488. */
  103489. pixelDepth: number;
  103490. /**
  103491. * Gets the number of array elements
  103492. */
  103493. numberOfArrayElements: number;
  103494. /**
  103495. * Gets the number of faces
  103496. */
  103497. numberOfFaces: number;
  103498. /**
  103499. * Gets the number of mipmap levels
  103500. */
  103501. numberOfMipmapLevels: number;
  103502. /**
  103503. * Gets the bytes of key value data
  103504. */
  103505. bytesOfKeyValueData: number;
  103506. /**
  103507. * Gets the load type
  103508. */
  103509. loadType: number;
  103510. /**
  103511. * If the container has been made invalid (eg. constructor failed to correctly load array buffer)
  103512. */
  103513. isInvalid: boolean;
  103514. /**
  103515. * Creates a new KhronosTextureContainer
  103516. * @param arrayBuffer contents of the KTX container file
  103517. * @param facesExpected should be either 1 or 6, based whether a cube texture or or
  103518. * @param threeDExpected provision for indicating that data should be a 3D texture, not implemented
  103519. * @param textureArrayExpected provision for indicating that data should be a texture array, not implemented
  103520. */
  103521. constructor(
  103522. /** contents of the KTX container file */
  103523. arrayBuffer: any, facesExpected: number, threeDExpected?: boolean, textureArrayExpected?: boolean);
  103524. /**
  103525. * Uploads KTX content to a Babylon Texture.
  103526. * It is assumed that the texture has already been created & is currently bound
  103527. * @hidden
  103528. */
  103529. uploadLevels(texture: InternalTexture, loadMipmaps: boolean): void;
  103530. private _upload2DCompressedLevels;
  103531. }
  103532. }
  103533. declare module BABYLON {
  103534. /**
  103535. * Implementation of the KTX Texture Loader.
  103536. * @hidden
  103537. */
  103538. export class _KTXTextureLoader implements IInternalTextureLoader {
  103539. /**
  103540. * Defines wether the loader supports cascade loading the different faces.
  103541. */
  103542. readonly supportCascades: boolean;
  103543. /**
  103544. * This returns if the loader support the current file information.
  103545. * @param extension defines the file extension of the file being loaded
  103546. * @param textureFormatInUse defines the current compressed format in use iun the engine
  103547. * @param fallback defines the fallback internal texture if any
  103548. * @param isBase64 defines whether the texture is encoded as a base64
  103549. * @param isBuffer defines whether the texture data are stored as a buffer
  103550. * @returns true if the loader can load the specified file
  103551. */
  103552. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  103553. /**
  103554. * Transform the url before loading if required.
  103555. * @param rootUrl the url of the texture
  103556. * @param textureFormatInUse defines the current compressed format in use iun the engine
  103557. * @returns the transformed texture
  103558. */
  103559. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  103560. /**
  103561. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  103562. * @param rootUrl the url of the texture
  103563. * @param textureFormatInUse defines the current compressed format in use iun the engine
  103564. * @returns the fallback texture
  103565. */
  103566. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  103567. /**
  103568. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  103569. * @param data contains the texture data
  103570. * @param texture defines the BabylonJS internal texture
  103571. * @param createPolynomials will be true if polynomials have been requested
  103572. * @param onLoad defines the callback to trigger once the texture is ready
  103573. * @param onError defines the callback to trigger in case of error
  103574. */
  103575. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  103576. /**
  103577. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  103578. * @param data contains the texture data
  103579. * @param texture defines the BabylonJS internal texture
  103580. * @param callback defines the method to call once ready to upload
  103581. */
  103582. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void, loadFailed: boolean) => void): void;
  103583. }
  103584. }
  103585. declare module BABYLON {
  103586. /** @hidden */
  103587. export var _forceSceneHelpersToBundle: boolean;
  103588. interface Scene {
  103589. /**
  103590. * Creates a default light for the scene.
  103591. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-light
  103592. * @param replace has the default false, when true replaces the existing lights in the scene with a hemispheric light
  103593. */
  103594. createDefaultLight(replace?: boolean): void;
  103595. /**
  103596. * Creates a default camera for the scene.
  103597. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-camera
  103598. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  103599. * @param replace has default false, when true replaces the active camera in the scene
  103600. * @param attachCameraControls has default false, when true attaches camera controls to the canvas.
  103601. */
  103602. createDefaultCamera(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  103603. /**
  103604. * Creates a default camera and a default light.
  103605. * @see http://doc.babylonjs.com/how_to/Fast_Build#create-default-camera-or-light
  103606. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  103607. * @param replace has the default false, when true replaces the active camera/light in the scene
  103608. * @param attachCameraControls has the default false, when true attaches camera controls to the canvas.
  103609. */
  103610. createDefaultCameraOrLight(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  103611. /**
  103612. * Creates a new sky box
  103613. * @see http://doc.babylonjs.com/how_to/Fast_Build#create-default-skybox
  103614. * @param environmentTexture defines the texture to use as environment texture
  103615. * @param pbr has default false which requires the StandardMaterial to be used, when true PBRMaterial must be used
  103616. * @param scale defines the overall scale of the skybox
  103617. * @param blur is only available when pbr is true, default is 0, no blur, maximum value is 1
  103618. * @param setGlobalEnvTexture has default true indicating that scene.environmentTexture must match the current skybox texture
  103619. * @returns a new mesh holding the sky box
  103620. */
  103621. createDefaultSkybox(environmentTexture?: BaseTexture, pbr?: boolean, scale?: number, blur?: number, setGlobalEnvTexture?: boolean): Nullable<Mesh>;
  103622. /**
  103623. * Creates a new environment
  103624. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-environment
  103625. * @param options defines the options you can use to configure the environment
  103626. * @returns the new EnvironmentHelper
  103627. */
  103628. createDefaultEnvironment(options?: Partial<IEnvironmentHelperOptions>): Nullable<EnvironmentHelper>;
  103629. /**
  103630. * Creates a new VREXperienceHelper
  103631. * @see http://doc.babylonjs.com/how_to/webvr_helper
  103632. * @param webVROptions defines the options used to create the new VREXperienceHelper
  103633. * @returns a new VREXperienceHelper
  103634. */
  103635. createDefaultVRExperience(webVROptions?: VRExperienceHelperOptions): VRExperienceHelper;
  103636. /**
  103637. * Creates a new XREXperienceHelper
  103638. * @see http://doc.babylonjs.com/how_to/webxr
  103639. * @returns a promise for a new XREXperienceHelper
  103640. */
  103641. createDefaultXRExperienceAsync(): Promise<WebXRExperienceHelper>;
  103642. }
  103643. }
  103644. declare module BABYLON {
  103645. /**
  103646. * Display a 360 degree video on an approximately spherical surface, useful for VR applications or skyboxes.
  103647. * As a subclass of TransformNode, this allow parenting to the camera or multiple videos with different locations in the scene.
  103648. * This class achieves its effect with a VideoTexture and a correctly configured BackgroundMaterial on an inverted sphere.
  103649. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  103650. */
  103651. export class VideoDome extends TransformNode {
  103652. /**
  103653. * Define the video source as a Monoscopic panoramic 360 video.
  103654. */
  103655. static readonly MODE_MONOSCOPIC: number;
  103656. /**
  103657. * Define the video source as a Stereoscopic TopBottom/OverUnder panoramic 360 video.
  103658. */
  103659. static readonly MODE_TOPBOTTOM: number;
  103660. /**
  103661. * Define the video source as a Stereoscopic Side by Side panoramic 360 video.
  103662. */
  103663. static readonly MODE_SIDEBYSIDE: number;
  103664. private _useDirectMapping;
  103665. /**
  103666. * The video texture being displayed on the sphere
  103667. */
  103668. protected _videoTexture: VideoTexture;
  103669. /**
  103670. * Gets the video texture being displayed on the sphere
  103671. */
  103672. readonly videoTexture: VideoTexture;
  103673. /**
  103674. * The skybox material
  103675. */
  103676. protected _material: BackgroundMaterial;
  103677. /**
  103678. * The surface used for the skybox
  103679. */
  103680. protected _mesh: Mesh;
  103681. /**
  103682. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  103683. * Also see the options.resolution property.
  103684. */
  103685. fovMultiplier: number;
  103686. private _videoMode;
  103687. /**
  103688. * Gets or set the current video mode for the video. It can be:
  103689. * * VideoDome.MODE_MONOSCOPIC : Define the video source as a Monoscopic panoramic 360 video.
  103690. * * VideoDome.MODE_TOPBOTTOM : Define the video source as a Stereoscopic TopBottom/OverUnder panoramic 360 video.
  103691. * * VideoDome.MODE_SIDEBYSIDE : Define the video source as a Stereoscopic Side by Side panoramic 360 video.
  103692. */
  103693. videoMode: number;
  103694. /**
  103695. * Oberserver used in Stereoscopic VR Mode.
  103696. */
  103697. private _onBeforeCameraRenderObserver;
  103698. /**
  103699. * Create an instance of this class and pass through the parameters to the relevant classes, VideoTexture, StandardMaterial, and Mesh.
  103700. * @param name Element's name, child elements will append suffixes for their own names.
  103701. * @param urlsOrVideo defines the url(s) or the video element to use
  103702. * @param options An object containing optional or exposed sub element properties
  103703. */
  103704. constructor(name: string, urlsOrVideo: string | string[] | HTMLVideoElement, options: {
  103705. resolution?: number;
  103706. clickToPlay?: boolean;
  103707. autoPlay?: boolean;
  103708. loop?: boolean;
  103709. size?: number;
  103710. poster?: string;
  103711. faceForward?: boolean;
  103712. useDirectMapping?: boolean;
  103713. }, scene: Scene);
  103714. private _changeVideoMode;
  103715. /**
  103716. * Releases resources associated with this node.
  103717. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  103718. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  103719. */
  103720. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  103721. }
  103722. }
  103723. declare module BABYLON {
  103724. /**
  103725. * This class can be used to get instrumentation data from a Babylon engine
  103726. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  103727. */
  103728. export class EngineInstrumentation implements IDisposable {
  103729. /**
  103730. * Define the instrumented engine.
  103731. */
  103732. engine: Engine;
  103733. private _captureGPUFrameTime;
  103734. private _gpuFrameTimeToken;
  103735. private _gpuFrameTime;
  103736. private _captureShaderCompilationTime;
  103737. private _shaderCompilationTime;
  103738. private _onBeginFrameObserver;
  103739. private _onEndFrameObserver;
  103740. private _onBeforeShaderCompilationObserver;
  103741. private _onAfterShaderCompilationObserver;
  103742. /**
  103743. * Gets the perf counter used for GPU frame time
  103744. */
  103745. readonly gpuFrameTimeCounter: PerfCounter;
  103746. /**
  103747. * Gets the GPU frame time capture status
  103748. */
  103749. /**
  103750. * Enable or disable the GPU frame time capture
  103751. */
  103752. captureGPUFrameTime: boolean;
  103753. /**
  103754. * Gets the perf counter used for shader compilation time
  103755. */
  103756. readonly shaderCompilationTimeCounter: PerfCounter;
  103757. /**
  103758. * Gets the shader compilation time capture status
  103759. */
  103760. /**
  103761. * Enable or disable the shader compilation time capture
  103762. */
  103763. captureShaderCompilationTime: boolean;
  103764. /**
  103765. * Instantiates a new engine instrumentation.
  103766. * This class can be used to get instrumentation data from a Babylon engine
  103767. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  103768. * @param engine Defines the engine to instrument
  103769. */
  103770. constructor(
  103771. /**
  103772. * Define the instrumented engine.
  103773. */
  103774. engine: Engine);
  103775. /**
  103776. * Dispose and release associated resources.
  103777. */
  103778. dispose(): void;
  103779. }
  103780. }
  103781. declare module BABYLON {
  103782. /**
  103783. * This class can be used to get instrumentation data from a Babylon engine
  103784. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  103785. */
  103786. export class SceneInstrumentation implements IDisposable {
  103787. /**
  103788. * Defines the scene to instrument
  103789. */
  103790. scene: Scene;
  103791. private _captureActiveMeshesEvaluationTime;
  103792. private _activeMeshesEvaluationTime;
  103793. private _captureRenderTargetsRenderTime;
  103794. private _renderTargetsRenderTime;
  103795. private _captureFrameTime;
  103796. private _frameTime;
  103797. private _captureRenderTime;
  103798. private _renderTime;
  103799. private _captureInterFrameTime;
  103800. private _interFrameTime;
  103801. private _captureParticlesRenderTime;
  103802. private _particlesRenderTime;
  103803. private _captureSpritesRenderTime;
  103804. private _spritesRenderTime;
  103805. private _capturePhysicsTime;
  103806. private _physicsTime;
  103807. private _captureAnimationsTime;
  103808. private _animationsTime;
  103809. private _captureCameraRenderTime;
  103810. private _cameraRenderTime;
  103811. private _onBeforeActiveMeshesEvaluationObserver;
  103812. private _onAfterActiveMeshesEvaluationObserver;
  103813. private _onBeforeRenderTargetsRenderObserver;
  103814. private _onAfterRenderTargetsRenderObserver;
  103815. private _onAfterRenderObserver;
  103816. private _onBeforeDrawPhaseObserver;
  103817. private _onAfterDrawPhaseObserver;
  103818. private _onBeforeAnimationsObserver;
  103819. private _onBeforeParticlesRenderingObserver;
  103820. private _onAfterParticlesRenderingObserver;
  103821. private _onBeforeSpritesRenderingObserver;
  103822. private _onAfterSpritesRenderingObserver;
  103823. private _onBeforePhysicsObserver;
  103824. private _onAfterPhysicsObserver;
  103825. private _onAfterAnimationsObserver;
  103826. private _onBeforeCameraRenderObserver;
  103827. private _onAfterCameraRenderObserver;
  103828. /**
  103829. * Gets the perf counter used for active meshes evaluation time
  103830. */
  103831. readonly activeMeshesEvaluationTimeCounter: PerfCounter;
  103832. /**
  103833. * Gets the active meshes evaluation time capture status
  103834. */
  103835. /**
  103836. * Enable or disable the active meshes evaluation time capture
  103837. */
  103838. captureActiveMeshesEvaluationTime: boolean;
  103839. /**
  103840. * Gets the perf counter used for render targets render time
  103841. */
  103842. readonly renderTargetsRenderTimeCounter: PerfCounter;
  103843. /**
  103844. * Gets the render targets render time capture status
  103845. */
  103846. /**
  103847. * Enable or disable the render targets render time capture
  103848. */
  103849. captureRenderTargetsRenderTime: boolean;
  103850. /**
  103851. * Gets the perf counter used for particles render time
  103852. */
  103853. readonly particlesRenderTimeCounter: PerfCounter;
  103854. /**
  103855. * Gets the particles render time capture status
  103856. */
  103857. /**
  103858. * Enable or disable the particles render time capture
  103859. */
  103860. captureParticlesRenderTime: boolean;
  103861. /**
  103862. * Gets the perf counter used for sprites render time
  103863. */
  103864. readonly spritesRenderTimeCounter: PerfCounter;
  103865. /**
  103866. * Gets the sprites render time capture status
  103867. */
  103868. /**
  103869. * Enable or disable the sprites render time capture
  103870. */
  103871. captureSpritesRenderTime: boolean;
  103872. /**
  103873. * Gets the perf counter used for physics time
  103874. */
  103875. readonly physicsTimeCounter: PerfCounter;
  103876. /**
  103877. * Gets the physics time capture status
  103878. */
  103879. /**
  103880. * Enable or disable the physics time capture
  103881. */
  103882. capturePhysicsTime: boolean;
  103883. /**
  103884. * Gets the perf counter used for animations time
  103885. */
  103886. readonly animationsTimeCounter: PerfCounter;
  103887. /**
  103888. * Gets the animations time capture status
  103889. */
  103890. /**
  103891. * Enable or disable the animations time capture
  103892. */
  103893. captureAnimationsTime: boolean;
  103894. /**
  103895. * Gets the perf counter used for frame time capture
  103896. */
  103897. readonly frameTimeCounter: PerfCounter;
  103898. /**
  103899. * Gets the frame time capture status
  103900. */
  103901. /**
  103902. * Enable or disable the frame time capture
  103903. */
  103904. captureFrameTime: boolean;
  103905. /**
  103906. * Gets the perf counter used for inter-frames time capture
  103907. */
  103908. readonly interFrameTimeCounter: PerfCounter;
  103909. /**
  103910. * Gets the inter-frames time capture status
  103911. */
  103912. /**
  103913. * Enable or disable the inter-frames time capture
  103914. */
  103915. captureInterFrameTime: boolean;
  103916. /**
  103917. * Gets the perf counter used for render time capture
  103918. */
  103919. readonly renderTimeCounter: PerfCounter;
  103920. /**
  103921. * Gets the render time capture status
  103922. */
  103923. /**
  103924. * Enable or disable the render time capture
  103925. */
  103926. captureRenderTime: boolean;
  103927. /**
  103928. * Gets the perf counter used for camera render time capture
  103929. */
  103930. readonly cameraRenderTimeCounter: PerfCounter;
  103931. /**
  103932. * Gets the camera render time capture status
  103933. */
  103934. /**
  103935. * Enable or disable the camera render time capture
  103936. */
  103937. captureCameraRenderTime: boolean;
  103938. /**
  103939. * Gets the perf counter used for draw calls
  103940. */
  103941. readonly drawCallsCounter: PerfCounter;
  103942. /**
  103943. * Gets the perf counter used for texture collisions
  103944. */
  103945. readonly textureCollisionsCounter: PerfCounter;
  103946. /**
  103947. * Instantiates a new scene instrumentation.
  103948. * This class can be used to get instrumentation data from a Babylon engine
  103949. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  103950. * @param scene Defines the scene to instrument
  103951. */
  103952. constructor(
  103953. /**
  103954. * Defines the scene to instrument
  103955. */
  103956. scene: Scene);
  103957. /**
  103958. * Dispose and release associated resources.
  103959. */
  103960. dispose(): void;
  103961. }
  103962. }
  103963. declare module BABYLON {
  103964. /** @hidden */
  103965. export var glowMapGenerationPixelShader: {
  103966. name: string;
  103967. shader: string;
  103968. };
  103969. }
  103970. declare module BABYLON {
  103971. /** @hidden */
  103972. export var glowMapGenerationVertexShader: {
  103973. name: string;
  103974. shader: string;
  103975. };
  103976. }
  103977. declare module BABYLON {
  103978. /**
  103979. * Effect layer options. This helps customizing the behaviour
  103980. * of the effect layer.
  103981. */
  103982. export interface IEffectLayerOptions {
  103983. /**
  103984. * Multiplication factor apply to the canvas size to compute the render target size
  103985. * used to generated the objects (the smaller the faster).
  103986. */
  103987. mainTextureRatio: number;
  103988. /**
  103989. * Enforces a fixed size texture to ensure effect stability across devices.
  103990. */
  103991. mainTextureFixedSize?: number;
  103992. /**
  103993. * Alpha blending mode used to apply the blur. Default depends of the implementation.
  103994. */
  103995. alphaBlendingMode: number;
  103996. /**
  103997. * The camera attached to the layer.
  103998. */
  103999. camera: Nullable<Camera>;
  104000. /**
  104001. * The rendering group to draw the layer in.
  104002. */
  104003. renderingGroupId: number;
  104004. }
  104005. /**
  104006. * The effect layer Helps adding post process effect blended with the main pass.
  104007. *
  104008. * This can be for instance use to generate glow or higlight effects on the scene.
  104009. *
  104010. * The effect layer class can not be used directly and is intented to inherited from to be
  104011. * customized per effects.
  104012. */
  104013. export abstract class EffectLayer {
  104014. private _vertexBuffers;
  104015. private _indexBuffer;
  104016. private _cachedDefines;
  104017. private _effectLayerMapGenerationEffect;
  104018. private _effectLayerOptions;
  104019. private _mergeEffect;
  104020. protected _scene: Scene;
  104021. protected _engine: Engine;
  104022. protected _maxSize: number;
  104023. protected _mainTextureDesiredSize: ISize;
  104024. protected _mainTexture: RenderTargetTexture;
  104025. protected _shouldRender: boolean;
  104026. protected _postProcesses: PostProcess[];
  104027. protected _textures: BaseTexture[];
  104028. protected _emissiveTextureAndColor: {
  104029. texture: Nullable<BaseTexture>;
  104030. color: Color4;
  104031. };
  104032. /**
  104033. * The name of the layer
  104034. */
  104035. name: string;
  104036. /**
  104037. * The clear color of the texture used to generate the glow map.
  104038. */
  104039. neutralColor: Color4;
  104040. /**
  104041. * Specifies wether the highlight layer is enabled or not.
  104042. */
  104043. isEnabled: boolean;
  104044. /**
  104045. * Gets the camera attached to the layer.
  104046. */
  104047. readonly camera: Nullable<Camera>;
  104048. /**
  104049. * Gets the rendering group id the layer should render in.
  104050. */
  104051. readonly renderingGroupId: number;
  104052. /**
  104053. * An event triggered when the effect layer has been disposed.
  104054. */
  104055. onDisposeObservable: Observable<EffectLayer>;
  104056. /**
  104057. * An event triggered when the effect layer is about rendering the main texture with the glowy parts.
  104058. */
  104059. onBeforeRenderMainTextureObservable: Observable<EffectLayer>;
  104060. /**
  104061. * An event triggered when the generated texture is being merged in the scene.
  104062. */
  104063. onBeforeComposeObservable: Observable<EffectLayer>;
  104064. /**
  104065. * An event triggered when the generated texture has been merged in the scene.
  104066. */
  104067. onAfterComposeObservable: Observable<EffectLayer>;
  104068. /**
  104069. * An event triggered when the efffect layer changes its size.
  104070. */
  104071. onSizeChangedObservable: Observable<EffectLayer>;
  104072. /** @hidden */
  104073. static _SceneComponentInitialization: (scene: Scene) => void;
  104074. /**
  104075. * Instantiates a new effect Layer and references it in the scene.
  104076. * @param name The name of the layer
  104077. * @param scene The scene to use the layer in
  104078. */
  104079. constructor(
  104080. /** The Friendly of the effect in the scene */
  104081. name: string, scene: Scene);
  104082. /**
  104083. * Get the effect name of the layer.
  104084. * @return The effect name
  104085. */
  104086. abstract getEffectName(): string;
  104087. /**
  104088. * Checks for the readiness of the element composing the layer.
  104089. * @param subMesh the mesh to check for
  104090. * @param useInstances specify wether or not to use instances to render the mesh
  104091. * @return true if ready otherwise, false
  104092. */
  104093. abstract isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  104094. /**
  104095. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  104096. * @returns true if the effect requires stencil during the main canvas render pass.
  104097. */
  104098. abstract needStencil(): boolean;
  104099. /**
  104100. * Create the merge effect. This is the shader use to blit the information back
  104101. * to the main canvas at the end of the scene rendering.
  104102. * @returns The effect containing the shader used to merge the effect on the main canvas
  104103. */
  104104. protected abstract _createMergeEffect(): Effect;
  104105. /**
  104106. * Creates the render target textures and post processes used in the effect layer.
  104107. */
  104108. protected abstract _createTextureAndPostProcesses(): void;
  104109. /**
  104110. * Implementation specific of rendering the generating effect on the main canvas.
  104111. * @param effect The effect used to render through
  104112. */
  104113. protected abstract _internalRender(effect: Effect): void;
  104114. /**
  104115. * Sets the required values for both the emissive texture and and the main color.
  104116. */
  104117. protected abstract _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  104118. /**
  104119. * Free any resources and references associated to a mesh.
  104120. * Internal use
  104121. * @param mesh The mesh to free.
  104122. */
  104123. abstract _disposeMesh(mesh: Mesh): void;
  104124. /**
  104125. * Serializes this layer (Glow or Highlight for example)
  104126. * @returns a serialized layer object
  104127. */
  104128. abstract serialize?(): any;
  104129. /**
  104130. * Initializes the effect layer with the required options.
  104131. * @param options Sets of none mandatory options to use with the layer (see IEffectLayerOptions for more information)
  104132. */
  104133. protected _init(options: Partial<IEffectLayerOptions>): void;
  104134. /**
  104135. * Generates the index buffer of the full screen quad blending to the main canvas.
  104136. */
  104137. private _generateIndexBuffer;
  104138. /**
  104139. * Generates the vertex buffer of the full screen quad blending to the main canvas.
  104140. */
  104141. private _genrateVertexBuffer;
  104142. /**
  104143. * Sets the main texture desired size which is the closest power of two
  104144. * of the engine canvas size.
  104145. */
  104146. private _setMainTextureSize;
  104147. /**
  104148. * Creates the main texture for the effect layer.
  104149. */
  104150. protected _createMainTexture(): void;
  104151. /**
  104152. * Adds specific effects defines.
  104153. * @param defines The defines to add specifics to.
  104154. */
  104155. protected _addCustomEffectDefines(defines: string[]): void;
  104156. /**
  104157. * Checks for the readiness of the element composing the layer.
  104158. * @param subMesh the mesh to check for
  104159. * @param useInstances specify wether or not to use instances to render the mesh
  104160. * @param emissiveTexture the associated emissive texture used to generate the glow
  104161. * @return true if ready otherwise, false
  104162. */
  104163. protected _isReady(subMesh: SubMesh, useInstances: boolean, emissiveTexture: Nullable<BaseTexture>): boolean;
  104164. /**
  104165. * Renders the glowing part of the scene by blending the blurred glowing meshes on top of the rendered scene.
  104166. */
  104167. render(): void;
  104168. /**
  104169. * Determine if a given mesh will be used in the current effect.
  104170. * @param mesh mesh to test
  104171. * @returns true if the mesh will be used
  104172. */
  104173. hasMesh(mesh: AbstractMesh): boolean;
  104174. /**
  104175. * Returns true if the layer contains information to display, otherwise false.
  104176. * @returns true if the glow layer should be rendered
  104177. */
  104178. shouldRender(): boolean;
  104179. /**
  104180. * Returns true if the mesh should render, otherwise false.
  104181. * @param mesh The mesh to render
  104182. * @returns true if it should render otherwise false
  104183. */
  104184. protected _shouldRenderMesh(mesh: AbstractMesh): boolean;
  104185. /**
  104186. * Returns true if the mesh can be rendered, otherwise false.
  104187. * @param mesh The mesh to render
  104188. * @param material The material used on the mesh
  104189. * @returns true if it can be rendered otherwise false
  104190. */
  104191. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  104192. /**
  104193. * Returns true if the mesh should render, otherwise false.
  104194. * @param mesh The mesh to render
  104195. * @returns true if it should render otherwise false
  104196. */
  104197. protected _shouldRenderEmissiveTextureForMesh(): boolean;
  104198. /**
  104199. * Renders the submesh passed in parameter to the generation map.
  104200. */
  104201. protected _renderSubMesh(subMesh: SubMesh): void;
  104202. /**
  104203. * Rebuild the required buffers.
  104204. * @hidden Internal use only.
  104205. */
  104206. _rebuild(): void;
  104207. /**
  104208. * Dispose only the render target textures and post process.
  104209. */
  104210. private _disposeTextureAndPostProcesses;
  104211. /**
  104212. * Dispose the highlight layer and free resources.
  104213. */
  104214. dispose(): void;
  104215. /**
  104216. * Gets the class name of the effect layer
  104217. * @returns the string with the class name of the effect layer
  104218. */
  104219. getClassName(): string;
  104220. /**
  104221. * Creates an effect layer from parsed effect layer data
  104222. * @param parsedEffectLayer defines effect layer data
  104223. * @param scene defines the current scene
  104224. * @param rootUrl defines the root URL containing the effect layer information
  104225. * @returns a parsed effect Layer
  104226. */
  104227. static Parse(parsedEffectLayer: any, scene: Scene, rootUrl: string): EffectLayer;
  104228. }
  104229. }
  104230. declare module BABYLON {
  104231. interface AbstractScene {
  104232. /**
  104233. * The list of effect layers (highlights/glow) added to the scene
  104234. * @see http://doc.babylonjs.com/how_to/highlight_layer
  104235. * @see http://doc.babylonjs.com/how_to/glow_layer
  104236. */
  104237. effectLayers: Array<EffectLayer>;
  104238. /**
  104239. * Removes the given effect layer from this scene.
  104240. * @param toRemove defines the effect layer to remove
  104241. * @returns the index of the removed effect layer
  104242. */
  104243. removeEffectLayer(toRemove: EffectLayer): number;
  104244. /**
  104245. * Adds the given effect layer to this scene
  104246. * @param newEffectLayer defines the effect layer to add
  104247. */
  104248. addEffectLayer(newEffectLayer: EffectLayer): void;
  104249. }
  104250. /**
  104251. * Defines the layer scene component responsible to manage any effect layers
  104252. * in a given scene.
  104253. */
  104254. export class EffectLayerSceneComponent implements ISceneSerializableComponent {
  104255. /**
  104256. * The component name helpfull to identify the component in the list of scene components.
  104257. */
  104258. readonly name: string;
  104259. /**
  104260. * The scene the component belongs to.
  104261. */
  104262. scene: Scene;
  104263. private _engine;
  104264. private _renderEffects;
  104265. private _needStencil;
  104266. private _previousStencilState;
  104267. /**
  104268. * Creates a new instance of the component for the given scene
  104269. * @param scene Defines the scene to register the component in
  104270. */
  104271. constructor(scene: Scene);
  104272. /**
  104273. * Registers the component in a given scene
  104274. */
  104275. register(): void;
  104276. /**
  104277. * Rebuilds the elements related to this component in case of
  104278. * context lost for instance.
  104279. */
  104280. rebuild(): void;
  104281. /**
  104282. * Serializes the component data to the specified json object
  104283. * @param serializationObject The object to serialize to
  104284. */
  104285. serialize(serializationObject: any): void;
  104286. /**
  104287. * Adds all the element from the container to the scene
  104288. * @param container the container holding the elements
  104289. */
  104290. addFromContainer(container: AbstractScene): void;
  104291. /**
  104292. * Removes all the elements in the container from the scene
  104293. * @param container contains the elements to remove
  104294. */
  104295. removeFromContainer(container: AbstractScene): void;
  104296. /**
  104297. * Disposes the component and the associated ressources.
  104298. */
  104299. dispose(): void;
  104300. private _isReadyForMesh;
  104301. private _renderMainTexture;
  104302. private _setStencil;
  104303. private _setStencilBack;
  104304. private _draw;
  104305. private _drawCamera;
  104306. private _drawRenderingGroup;
  104307. }
  104308. }
  104309. declare module BABYLON {
  104310. /** @hidden */
  104311. export var glowMapMergePixelShader: {
  104312. name: string;
  104313. shader: string;
  104314. };
  104315. }
  104316. declare module BABYLON {
  104317. /** @hidden */
  104318. export var glowMapMergeVertexShader: {
  104319. name: string;
  104320. shader: string;
  104321. };
  104322. }
  104323. declare module BABYLON {
  104324. interface AbstractScene {
  104325. /**
  104326. * Return a the first highlight layer of the scene with a given name.
  104327. * @param name The name of the highlight layer to look for.
  104328. * @return The highlight layer if found otherwise null.
  104329. */
  104330. getGlowLayerByName(name: string): Nullable<GlowLayer>;
  104331. }
  104332. /**
  104333. * Glow layer options. This helps customizing the behaviour
  104334. * of the glow layer.
  104335. */
  104336. export interface IGlowLayerOptions {
  104337. /**
  104338. * Multiplication factor apply to the canvas size to compute the render target size
  104339. * used to generated the glowing objects (the smaller the faster).
  104340. */
  104341. mainTextureRatio: number;
  104342. /**
  104343. * Enforces a fixed size texture to ensure resize independant blur.
  104344. */
  104345. mainTextureFixedSize?: number;
  104346. /**
  104347. * How big is the kernel of the blur texture.
  104348. */
  104349. blurKernelSize: number;
  104350. /**
  104351. * The camera attached to the layer.
  104352. */
  104353. camera: Nullable<Camera>;
  104354. /**
  104355. * Enable MSAA by chosing the number of samples.
  104356. */
  104357. mainTextureSamples?: number;
  104358. /**
  104359. * The rendering group to draw the layer in.
  104360. */
  104361. renderingGroupId: number;
  104362. }
  104363. /**
  104364. * The glow layer Helps adding a glow effect around the emissive parts of a mesh.
  104365. *
  104366. * Once instantiated in a scene, simply use the pushMesh or removeMesh method to add or remove
  104367. * glowy meshes to your scene.
  104368. *
  104369. * Documentation: https://doc.babylonjs.com/how_to/glow_layer
  104370. */
  104371. export class GlowLayer extends EffectLayer {
  104372. /**
  104373. * Effect Name of the layer.
  104374. */
  104375. static readonly EffectName: string;
  104376. /**
  104377. * The default blur kernel size used for the glow.
  104378. */
  104379. static DefaultBlurKernelSize: number;
  104380. /**
  104381. * The default texture size ratio used for the glow.
  104382. */
  104383. static DefaultTextureRatio: number;
  104384. /**
  104385. * Sets the kernel size of the blur.
  104386. */
  104387. /**
  104388. * Gets the kernel size of the blur.
  104389. */
  104390. blurKernelSize: number;
  104391. /**
  104392. * Sets the glow intensity.
  104393. */
  104394. /**
  104395. * Gets the glow intensity.
  104396. */
  104397. intensity: number;
  104398. private _options;
  104399. private _intensity;
  104400. private _horizontalBlurPostprocess1;
  104401. private _verticalBlurPostprocess1;
  104402. private _horizontalBlurPostprocess2;
  104403. private _verticalBlurPostprocess2;
  104404. private _blurTexture1;
  104405. private _blurTexture2;
  104406. private _postProcesses1;
  104407. private _postProcesses2;
  104408. private _includedOnlyMeshes;
  104409. private _excludedMeshes;
  104410. /**
  104411. * Callback used to let the user override the color selection on a per mesh basis
  104412. */
  104413. customEmissiveColorSelector: (mesh: Mesh, subMesh: SubMesh, material: Material, result: Color4) => void;
  104414. /**
  104415. * Callback used to let the user override the texture selection on a per mesh basis
  104416. */
  104417. customEmissiveTextureSelector: (mesh: Mesh, subMesh: SubMesh, material: Material) => Texture;
  104418. /**
  104419. * Instantiates a new glow Layer and references it to the scene.
  104420. * @param name The name of the layer
  104421. * @param scene The scene to use the layer in
  104422. * @param options Sets of none mandatory options to use with the layer (see IGlowLayerOptions for more information)
  104423. */
  104424. constructor(name: string, scene: Scene, options?: Partial<IGlowLayerOptions>);
  104425. /**
  104426. * Get the effect name of the layer.
  104427. * @return The effect name
  104428. */
  104429. getEffectName(): string;
  104430. /**
  104431. * Create the merge effect. This is the shader use to blit the information back
  104432. * to the main canvas at the end of the scene rendering.
  104433. */
  104434. protected _createMergeEffect(): Effect;
  104435. /**
  104436. * Creates the render target textures and post processes used in the glow layer.
  104437. */
  104438. protected _createTextureAndPostProcesses(): void;
  104439. /**
  104440. * Checks for the readiness of the element composing the layer.
  104441. * @param subMesh the mesh to check for
  104442. * @param useInstances specify wether or not to use instances to render the mesh
  104443. * @param emissiveTexture the associated emissive texture used to generate the glow
  104444. * @return true if ready otherwise, false
  104445. */
  104446. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  104447. /**
  104448. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  104449. */
  104450. needStencil(): boolean;
  104451. /**
  104452. * Returns true if the mesh can be rendered, otherwise false.
  104453. * @param mesh The mesh to render
  104454. * @param material The material used on the mesh
  104455. * @returns true if it can be rendered otherwise false
  104456. */
  104457. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  104458. /**
  104459. * Implementation specific of rendering the generating effect on the main canvas.
  104460. * @param effect The effect used to render through
  104461. */
  104462. protected _internalRender(effect: Effect): void;
  104463. /**
  104464. * Sets the required values for both the emissive texture and and the main color.
  104465. */
  104466. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  104467. /**
  104468. * Returns true if the mesh should render, otherwise false.
  104469. * @param mesh The mesh to render
  104470. * @returns true if it should render otherwise false
  104471. */
  104472. protected _shouldRenderMesh(mesh: Mesh): boolean;
  104473. /**
  104474. * Adds specific effects defines.
  104475. * @param defines The defines to add specifics to.
  104476. */
  104477. protected _addCustomEffectDefines(defines: string[]): void;
  104478. /**
  104479. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the glow layer.
  104480. * @param mesh The mesh to exclude from the glow layer
  104481. */
  104482. addExcludedMesh(mesh: Mesh): void;
  104483. /**
  104484. * Remove a mesh from the exclusion list to let it impact or being impacted by the glow layer.
  104485. * @param mesh The mesh to remove
  104486. */
  104487. removeExcludedMesh(mesh: Mesh): void;
  104488. /**
  104489. * Add a mesh in the inclusion list to impact or being impacted by the glow layer.
  104490. * @param mesh The mesh to include in the glow layer
  104491. */
  104492. addIncludedOnlyMesh(mesh: Mesh): void;
  104493. /**
  104494. * Remove a mesh from the Inclusion list to prevent it to impact or being impacted by the glow layer.
  104495. * @param mesh The mesh to remove
  104496. */
  104497. removeIncludedOnlyMesh(mesh: Mesh): void;
  104498. /**
  104499. * Determine if a given mesh will be used in the glow layer
  104500. * @param mesh The mesh to test
  104501. * @returns true if the mesh will be highlighted by the current glow layer
  104502. */
  104503. hasMesh(mesh: AbstractMesh): boolean;
  104504. /**
  104505. * Free any resources and references associated to a mesh.
  104506. * Internal use
  104507. * @param mesh The mesh to free.
  104508. * @hidden
  104509. */
  104510. _disposeMesh(mesh: Mesh): void;
  104511. /**
  104512. * Gets the class name of the effect layer
  104513. * @returns the string with the class name of the effect layer
  104514. */
  104515. getClassName(): string;
  104516. /**
  104517. * Serializes this glow layer
  104518. * @returns a serialized glow layer object
  104519. */
  104520. serialize(): any;
  104521. /**
  104522. * Creates a Glow Layer from parsed glow layer data
  104523. * @param parsedGlowLayer defines glow layer data
  104524. * @param scene defines the current scene
  104525. * @param rootUrl defines the root URL containing the glow layer information
  104526. * @returns a parsed Glow Layer
  104527. */
  104528. static Parse(parsedGlowLayer: any, scene: Scene, rootUrl: string): GlowLayer;
  104529. }
  104530. }
  104531. declare module BABYLON {
  104532. /** @hidden */
  104533. export var glowBlurPostProcessPixelShader: {
  104534. name: string;
  104535. shader: string;
  104536. };
  104537. }
  104538. declare module BABYLON {
  104539. interface AbstractScene {
  104540. /**
  104541. * Return a the first highlight layer of the scene with a given name.
  104542. * @param name The name of the highlight layer to look for.
  104543. * @return The highlight layer if found otherwise null.
  104544. */
  104545. getHighlightLayerByName(name: string): Nullable<HighlightLayer>;
  104546. }
  104547. /**
  104548. * Highlight layer options. This helps customizing the behaviour
  104549. * of the highlight layer.
  104550. */
  104551. export interface IHighlightLayerOptions {
  104552. /**
  104553. * Multiplication factor apply to the canvas size to compute the render target size
  104554. * used to generated the glowing objects (the smaller the faster).
  104555. */
  104556. mainTextureRatio: number;
  104557. /**
  104558. * Enforces a fixed size texture to ensure resize independant blur.
  104559. */
  104560. mainTextureFixedSize?: number;
  104561. /**
  104562. * Multiplication factor apply to the main texture size in the first step of the blur to reduce the size
  104563. * of the picture to blur (the smaller the faster).
  104564. */
  104565. blurTextureSizeRatio: number;
  104566. /**
  104567. * How big in texel of the blur texture is the vertical blur.
  104568. */
  104569. blurVerticalSize: number;
  104570. /**
  104571. * How big in texel of the blur texture is the horizontal blur.
  104572. */
  104573. blurHorizontalSize: number;
  104574. /**
  104575. * Alpha blending mode used to apply the blur. Default is combine.
  104576. */
  104577. alphaBlendingMode: number;
  104578. /**
  104579. * The camera attached to the layer.
  104580. */
  104581. camera: Nullable<Camera>;
  104582. /**
  104583. * Should we display highlight as a solid stroke?
  104584. */
  104585. isStroke?: boolean;
  104586. /**
  104587. * The rendering group to draw the layer in.
  104588. */
  104589. renderingGroupId: number;
  104590. }
  104591. /**
  104592. * The highlight layer Helps adding a glow effect around a mesh.
  104593. *
  104594. * Once instantiated in a scene, simply use the pushMesh or removeMesh method to add or remove
  104595. * glowy meshes to your scene.
  104596. *
  104597. * !!! THIS REQUIRES AN ACTIVE STENCIL BUFFER ON THE CANVAS !!!
  104598. */
  104599. export class HighlightLayer extends EffectLayer {
  104600. name: string;
  104601. /**
  104602. * Effect Name of the highlight layer.
  104603. */
  104604. static readonly EffectName: string;
  104605. /**
  104606. * The neutral color used during the preparation of the glow effect.
  104607. * This is black by default as the blend operation is a blend operation.
  104608. */
  104609. static NeutralColor: Color4;
  104610. /**
  104611. * Stencil value used for glowing meshes.
  104612. */
  104613. static GlowingMeshStencilReference: number;
  104614. /**
  104615. * Stencil value used for the other meshes in the scene.
  104616. */
  104617. static NormalMeshStencilReference: number;
  104618. /**
  104619. * Specifies whether or not the inner glow is ACTIVE in the layer.
  104620. */
  104621. innerGlow: boolean;
  104622. /**
  104623. * Specifies whether or not the outer glow is ACTIVE in the layer.
  104624. */
  104625. outerGlow: boolean;
  104626. /**
  104627. * Specifies the horizontal size of the blur.
  104628. */
  104629. /**
  104630. * Gets the horizontal size of the blur.
  104631. */
  104632. blurHorizontalSize: number;
  104633. /**
  104634. * Specifies the vertical size of the blur.
  104635. */
  104636. /**
  104637. * Gets the vertical size of the blur.
  104638. */
  104639. blurVerticalSize: number;
  104640. /**
  104641. * An event triggered when the highlight layer is being blurred.
  104642. */
  104643. onBeforeBlurObservable: Observable<HighlightLayer>;
  104644. /**
  104645. * An event triggered when the highlight layer has been blurred.
  104646. */
  104647. onAfterBlurObservable: Observable<HighlightLayer>;
  104648. private _instanceGlowingMeshStencilReference;
  104649. private _options;
  104650. private _downSamplePostprocess;
  104651. private _horizontalBlurPostprocess;
  104652. private _verticalBlurPostprocess;
  104653. private _blurTexture;
  104654. private _meshes;
  104655. private _excludedMeshes;
  104656. /**
  104657. * Instantiates a new highlight Layer and references it to the scene..
  104658. * @param name The name of the layer
  104659. * @param scene The scene to use the layer in
  104660. * @param options Sets of none mandatory options to use with the layer (see IHighlightLayerOptions for more information)
  104661. */
  104662. constructor(name: string, scene: Scene, options?: Partial<IHighlightLayerOptions>);
  104663. /**
  104664. * Get the effect name of the layer.
  104665. * @return The effect name
  104666. */
  104667. getEffectName(): string;
  104668. /**
  104669. * Create the merge effect. This is the shader use to blit the information back
  104670. * to the main canvas at the end of the scene rendering.
  104671. */
  104672. protected _createMergeEffect(): Effect;
  104673. /**
  104674. * Creates the render target textures and post processes used in the highlight layer.
  104675. */
  104676. protected _createTextureAndPostProcesses(): void;
  104677. /**
  104678. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  104679. */
  104680. needStencil(): boolean;
  104681. /**
  104682. * Checks for the readiness of the element composing the layer.
  104683. * @param subMesh the mesh to check for
  104684. * @param useInstances specify wether or not to use instances to render the mesh
  104685. * @param emissiveTexture the associated emissive texture used to generate the glow
  104686. * @return true if ready otherwise, false
  104687. */
  104688. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  104689. /**
  104690. * Implementation specific of rendering the generating effect on the main canvas.
  104691. * @param effect The effect used to render through
  104692. */
  104693. protected _internalRender(effect: Effect): void;
  104694. /**
  104695. * Returns true if the layer contains information to display, otherwise false.
  104696. */
  104697. shouldRender(): boolean;
  104698. /**
  104699. * Returns true if the mesh should render, otherwise false.
  104700. * @param mesh The mesh to render
  104701. * @returns true if it should render otherwise false
  104702. */
  104703. protected _shouldRenderMesh(mesh: Mesh): boolean;
  104704. /**
  104705. * Sets the required values for both the emissive texture and and the main color.
  104706. */
  104707. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  104708. /**
  104709. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the highlight layer.
  104710. * @param mesh The mesh to exclude from the highlight layer
  104711. */
  104712. addExcludedMesh(mesh: Mesh): void;
  104713. /**
  104714. * Remove a mesh from the exclusion list to let it impact or being impacted by the highlight layer.
  104715. * @param mesh The mesh to highlight
  104716. */
  104717. removeExcludedMesh(mesh: Mesh): void;
  104718. /**
  104719. * Determine if a given mesh will be highlighted by the current HighlightLayer
  104720. * @param mesh mesh to test
  104721. * @returns true if the mesh will be highlighted by the current HighlightLayer
  104722. */
  104723. hasMesh(mesh: AbstractMesh): boolean;
  104724. /**
  104725. * Add a mesh in the highlight layer in order to make it glow with the chosen color.
  104726. * @param mesh The mesh to highlight
  104727. * @param color The color of the highlight
  104728. * @param glowEmissiveOnly Extract the glow from the emissive texture
  104729. */
  104730. addMesh(mesh: Mesh, color: Color3, glowEmissiveOnly?: boolean): void;
  104731. /**
  104732. * Remove a mesh from the highlight layer in order to make it stop glowing.
  104733. * @param mesh The mesh to highlight
  104734. */
  104735. removeMesh(mesh: Mesh): void;
  104736. /**
  104737. * Force the stencil to the normal expected value for none glowing parts
  104738. */
  104739. private _defaultStencilReference;
  104740. /**
  104741. * Free any resources and references associated to a mesh.
  104742. * Internal use
  104743. * @param mesh The mesh to free.
  104744. * @hidden
  104745. */
  104746. _disposeMesh(mesh: Mesh): void;
  104747. /**
  104748. * Dispose the highlight layer and free resources.
  104749. */
  104750. dispose(): void;
  104751. /**
  104752. * Gets the class name of the effect layer
  104753. * @returns the string with the class name of the effect layer
  104754. */
  104755. getClassName(): string;
  104756. /**
  104757. * Serializes this Highlight layer
  104758. * @returns a serialized Highlight layer object
  104759. */
  104760. serialize(): any;
  104761. /**
  104762. * Creates a Highlight layer from parsed Highlight layer data
  104763. * @param parsedHightlightLayer defines the Highlight layer data
  104764. * @param scene defines the current scene
  104765. * @param rootUrl defines the root URL containing the Highlight layer information
  104766. * @returns a parsed Highlight layer
  104767. */
  104768. static Parse(parsedHightlightLayer: any, scene: Scene, rootUrl: string): HighlightLayer;
  104769. }
  104770. }
  104771. declare module BABYLON {
  104772. /** @hidden */
  104773. export var lensFlarePixelShader: {
  104774. name: string;
  104775. shader: string;
  104776. };
  104777. }
  104778. declare module BABYLON {
  104779. /** @hidden */
  104780. export var lensFlareVertexShader: {
  104781. name: string;
  104782. shader: string;
  104783. };
  104784. }
  104785. declare module BABYLON {
  104786. /**
  104787. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  104788. * It is usually composed of several `lensFlare`.
  104789. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  104790. */
  104791. export class LensFlareSystem {
  104792. /**
  104793. * Define the name of the lens flare system
  104794. */
  104795. name: string;
  104796. /**
  104797. * List of lens flares used in this system.
  104798. */
  104799. lensFlares: LensFlare[];
  104800. /**
  104801. * Define a limit from the border the lens flare can be visible.
  104802. */
  104803. borderLimit: number;
  104804. /**
  104805. * Define a viewport border we do not want to see the lens flare in.
  104806. */
  104807. viewportBorder: number;
  104808. /**
  104809. * Define a predicate which could limit the list of meshes able to occlude the effect.
  104810. */
  104811. meshesSelectionPredicate: (mesh: AbstractMesh) => boolean;
  104812. /**
  104813. * Restricts the rendering of the effect to only the camera rendering this layer mask.
  104814. */
  104815. layerMask: number;
  104816. /**
  104817. * Define the id of the lens flare system in the scene.
  104818. * (equal to name by default)
  104819. */
  104820. id: string;
  104821. private _scene;
  104822. private _emitter;
  104823. private _vertexBuffers;
  104824. private _indexBuffer;
  104825. private _effect;
  104826. private _positionX;
  104827. private _positionY;
  104828. private _isEnabled;
  104829. /** @hidden */
  104830. static _SceneComponentInitialization: (scene: Scene) => void;
  104831. /**
  104832. * Instantiates a lens flare system.
  104833. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  104834. * It is usually composed of several `lensFlare`.
  104835. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  104836. * @param name Define the name of the lens flare system in the scene
  104837. * @param emitter Define the source (the emitter) of the lens flares (it can be a camera, a light or a mesh).
  104838. * @param scene Define the scene the lens flare system belongs to
  104839. */
  104840. constructor(
  104841. /**
  104842. * Define the name of the lens flare system
  104843. */
  104844. name: string, emitter: any, scene: Scene);
  104845. /**
  104846. * Define if the lens flare system is enabled.
  104847. */
  104848. isEnabled: boolean;
  104849. /**
  104850. * Get the scene the effects belongs to.
  104851. * @returns the scene holding the lens flare system
  104852. */
  104853. getScene(): Scene;
  104854. /**
  104855. * Get the emitter of the lens flare system.
  104856. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  104857. * @returns the emitter of the lens flare system
  104858. */
  104859. getEmitter(): any;
  104860. /**
  104861. * Set the emitter of the lens flare system.
  104862. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  104863. * @param newEmitter Define the new emitter of the system
  104864. */
  104865. setEmitter(newEmitter: any): void;
  104866. /**
  104867. * Get the lens flare system emitter position.
  104868. * The emitter defines the source of the lens flares (it can be a camera, a light or a mesh).
  104869. * @returns the position
  104870. */
  104871. getEmitterPosition(): Vector3;
  104872. /**
  104873. * @hidden
  104874. */
  104875. computeEffectivePosition(globalViewport: Viewport): boolean;
  104876. /** @hidden */
  104877. _isVisible(): boolean;
  104878. /**
  104879. * @hidden
  104880. */
  104881. render(): boolean;
  104882. /**
  104883. * Dispose and release the lens flare with its associated resources.
  104884. */
  104885. dispose(): void;
  104886. /**
  104887. * Parse a lens flare system from a JSON repressentation
  104888. * @param parsedLensFlareSystem Define the JSON to parse
  104889. * @param scene Define the scene the parsed system should be instantiated in
  104890. * @param rootUrl Define the rootUrl of the load sequence to easily find a load relative dependencies such as textures
  104891. * @returns the parsed system
  104892. */
  104893. static Parse(parsedLensFlareSystem: any, scene: Scene, rootUrl: string): LensFlareSystem;
  104894. /**
  104895. * Serialize the current Lens Flare System into a JSON representation.
  104896. * @returns the serialized JSON
  104897. */
  104898. serialize(): any;
  104899. }
  104900. }
  104901. declare module BABYLON {
  104902. /**
  104903. * This represents one of the lens effect in a `lensFlareSystem`.
  104904. * It controls one of the indiviual texture used in the effect.
  104905. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  104906. */
  104907. export class LensFlare {
  104908. /**
  104909. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  104910. */
  104911. size: number;
  104912. /**
  104913. * 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.
  104914. */
  104915. position: number;
  104916. /**
  104917. * Define the lens color.
  104918. */
  104919. color: Color3;
  104920. /**
  104921. * Define the lens texture.
  104922. */
  104923. texture: Nullable<Texture>;
  104924. /**
  104925. * Define the alpha mode to render this particular lens.
  104926. */
  104927. alphaMode: number;
  104928. private _system;
  104929. /**
  104930. * Creates a new Lens Flare.
  104931. * This represents one of the lens effect in a `lensFlareSystem`.
  104932. * It controls one of the indiviual texture used in the effect.
  104933. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  104934. * @param size Define the size of the lens flare (a floating value between 0 and 1)
  104935. * @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.
  104936. * @param color Define the lens color
  104937. * @param imgUrl Define the lens texture url
  104938. * @param system Define the `lensFlareSystem` this flare is part of
  104939. * @returns The newly created Lens Flare
  104940. */
  104941. static AddFlare(size: number, position: number, color: Color3, imgUrl: string, system: LensFlareSystem): LensFlare;
  104942. /**
  104943. * Instantiates a new Lens Flare.
  104944. * This represents one of the lens effect in a `lensFlareSystem`.
  104945. * It controls one of the indiviual texture used in the effect.
  104946. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  104947. * @param size Define the size of the lens flare in the system (a floating value between 0 and 1)
  104948. * @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.
  104949. * @param color Define the lens color
  104950. * @param imgUrl Define the lens texture url
  104951. * @param system Define the `lensFlareSystem` this flare is part of
  104952. */
  104953. constructor(
  104954. /**
  104955. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  104956. */
  104957. size: number,
  104958. /**
  104959. * 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.
  104960. */
  104961. position: number, color: Color3, imgUrl: string, system: LensFlareSystem);
  104962. /**
  104963. * Dispose and release the lens flare with its associated resources.
  104964. */
  104965. dispose(): void;
  104966. }
  104967. }
  104968. declare module BABYLON {
  104969. interface AbstractScene {
  104970. /**
  104971. * The list of lens flare system added to the scene
  104972. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  104973. */
  104974. lensFlareSystems: Array<LensFlareSystem>;
  104975. /**
  104976. * Removes the given lens flare system from this scene.
  104977. * @param toRemove The lens flare system to remove
  104978. * @returns The index of the removed lens flare system
  104979. */
  104980. removeLensFlareSystem(toRemove: LensFlareSystem): number;
  104981. /**
  104982. * Adds the given lens flare system to this scene
  104983. * @param newLensFlareSystem The lens flare system to add
  104984. */
  104985. addLensFlareSystem(newLensFlareSystem: LensFlareSystem): void;
  104986. /**
  104987. * Gets a lens flare system using its name
  104988. * @param name defines the name to look for
  104989. * @returns the lens flare system or null if not found
  104990. */
  104991. getLensFlareSystemByName(name: string): Nullable<LensFlareSystem>;
  104992. /**
  104993. * Gets a lens flare system using its id
  104994. * @param id defines the id to look for
  104995. * @returns the lens flare system or null if not found
  104996. */
  104997. getLensFlareSystemByID(id: string): Nullable<LensFlareSystem>;
  104998. }
  104999. /**
  105000. * Defines the lens flare scene component responsible to manage any lens flares
  105001. * in a given scene.
  105002. */
  105003. export class LensFlareSystemSceneComponent implements ISceneSerializableComponent {
  105004. /**
  105005. * The component name helpfull to identify the component in the list of scene components.
  105006. */
  105007. readonly name: string;
  105008. /**
  105009. * The scene the component belongs to.
  105010. */
  105011. scene: Scene;
  105012. /**
  105013. * Creates a new instance of the component for the given scene
  105014. * @param scene Defines the scene to register the component in
  105015. */
  105016. constructor(scene: Scene);
  105017. /**
  105018. * Registers the component in a given scene
  105019. */
  105020. register(): void;
  105021. /**
  105022. * Rebuilds the elements related to this component in case of
  105023. * context lost for instance.
  105024. */
  105025. rebuild(): void;
  105026. /**
  105027. * Adds all the element from the container to the scene
  105028. * @param container the container holding the elements
  105029. */
  105030. addFromContainer(container: AbstractScene): void;
  105031. /**
  105032. * Removes all the elements in the container from the scene
  105033. * @param container contains the elements to remove
  105034. */
  105035. removeFromContainer(container: AbstractScene): void;
  105036. /**
  105037. * Serializes the component data to the specified json object
  105038. * @param serializationObject The object to serialize to
  105039. */
  105040. serialize(serializationObject: any): void;
  105041. /**
  105042. * Disposes the component and the associated ressources.
  105043. */
  105044. dispose(): void;
  105045. private _draw;
  105046. }
  105047. }
  105048. declare module BABYLON {
  105049. /**
  105050. * Defines the shadow generator component responsible to manage any shadow generators
  105051. * in a given scene.
  105052. */
  105053. export class ShadowGeneratorSceneComponent implements ISceneSerializableComponent {
  105054. /**
  105055. * The component name helpfull to identify the component in the list of scene components.
  105056. */
  105057. readonly name: string;
  105058. /**
  105059. * The scene the component belongs to.
  105060. */
  105061. scene: Scene;
  105062. /**
  105063. * Creates a new instance of the component for the given scene
  105064. * @param scene Defines the scene to register the component in
  105065. */
  105066. constructor(scene: Scene);
  105067. /**
  105068. * Registers the component in a given scene
  105069. */
  105070. register(): void;
  105071. /**
  105072. * Rebuilds the elements related to this component in case of
  105073. * context lost for instance.
  105074. */
  105075. rebuild(): void;
  105076. /**
  105077. * Serializes the component data to the specified json object
  105078. * @param serializationObject The object to serialize to
  105079. */
  105080. serialize(serializationObject: any): void;
  105081. /**
  105082. * Adds all the element from the container to the scene
  105083. * @param container the container holding the elements
  105084. */
  105085. addFromContainer(container: AbstractScene): void;
  105086. /**
  105087. * Removes all the elements in the container from the scene
  105088. * @param container contains the elements to remove
  105089. */
  105090. removeFromContainer(container: AbstractScene): void;
  105091. /**
  105092. * Rebuilds the elements related to this component in case of
  105093. * context lost for instance.
  105094. */
  105095. dispose(): void;
  105096. private _gatherRenderTargets;
  105097. }
  105098. }
  105099. declare module BABYLON {
  105100. /**
  105101. * A directional light is defined by a direction (what a surprise!).
  105102. * The light is emitted from everywhere in the specified direction, and has an infinite range.
  105103. * 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.
  105104. * Documentation: https://doc.babylonjs.com/babylon101/lights
  105105. */
  105106. export class DirectionalLight extends ShadowLight {
  105107. private _shadowFrustumSize;
  105108. /**
  105109. * Fix frustum size for the shadow generation. This is disabled if the value is 0.
  105110. */
  105111. /**
  105112. * Specifies a fix frustum size for the shadow generation.
  105113. */
  105114. shadowFrustumSize: number;
  105115. private _shadowOrthoScale;
  105116. /**
  105117. * Gets the shadow projection scale against the optimal computed one.
  105118. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  105119. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  105120. */
  105121. /**
  105122. * Sets the shadow projection scale against the optimal computed one.
  105123. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  105124. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  105125. */
  105126. shadowOrthoScale: number;
  105127. /**
  105128. * Automatically compute the projection matrix to best fit (including all the casters)
  105129. * on each frame.
  105130. */
  105131. autoUpdateExtends: boolean;
  105132. private _orthoLeft;
  105133. private _orthoRight;
  105134. private _orthoTop;
  105135. private _orthoBottom;
  105136. /**
  105137. * Creates a DirectionalLight object in the scene, oriented towards the passed direction (Vector3).
  105138. * The directional light is emitted from everywhere in the given direction.
  105139. * It can cast shadows.
  105140. * Documentation : https://doc.babylonjs.com/babylon101/lights
  105141. * @param name The friendly name of the light
  105142. * @param direction The direction of the light
  105143. * @param scene The scene the light belongs to
  105144. */
  105145. constructor(name: string, direction: Vector3, scene: Scene);
  105146. /**
  105147. * Returns the string "DirectionalLight".
  105148. * @return The class name
  105149. */
  105150. getClassName(): string;
  105151. /**
  105152. * Returns the integer 1.
  105153. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  105154. */
  105155. getTypeID(): number;
  105156. /**
  105157. * Sets the passed matrix "matrix" as projection matrix for the shadows cast by the light according to the passed view matrix.
  105158. * Returns the DirectionalLight Shadow projection matrix.
  105159. */
  105160. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  105161. /**
  105162. * Sets the passed matrix "matrix" as fixed frustum projection matrix for the shadows cast by the light according to the passed view matrix.
  105163. * Returns the DirectionalLight Shadow projection matrix.
  105164. */
  105165. protected _setDefaultFixedFrustumShadowProjectionMatrix(matrix: Matrix): void;
  105166. /**
  105167. * Sets the passed matrix "matrix" as auto extend projection matrix for the shadows cast by the light according to the passed view matrix.
  105168. * Returns the DirectionalLight Shadow projection matrix.
  105169. */
  105170. protected _setDefaultAutoExtendShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  105171. protected _buildUniformLayout(): void;
  105172. /**
  105173. * Sets the passed Effect object with the DirectionalLight transformed position (or position if not parented) and the passed name.
  105174. * @param effect The effect to update
  105175. * @param lightIndex The index of the light in the effect to update
  105176. * @returns The directional light
  105177. */
  105178. transferToEffect(effect: Effect, lightIndex: string): DirectionalLight;
  105179. /**
  105180. * Gets the minZ used for shadow according to both the scene and the light.
  105181. *
  105182. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  105183. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  105184. * @param activeCamera The camera we are returning the min for
  105185. * @returns the depth min z
  105186. */
  105187. getDepthMinZ(activeCamera: Camera): number;
  105188. /**
  105189. * Gets the maxZ used for shadow according to both the scene and the light.
  105190. *
  105191. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  105192. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  105193. * @param activeCamera The camera we are returning the max for
  105194. * @returns the depth max z
  105195. */
  105196. getDepthMaxZ(activeCamera: Camera): number;
  105197. /**
  105198. * Prepares the list of defines specific to the light type.
  105199. * @param defines the list of defines
  105200. * @param lightIndex defines the index of the light for the effect
  105201. */
  105202. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  105203. }
  105204. }
  105205. declare module BABYLON {
  105206. /**
  105207. * A point light is a light defined by an unique point in world space.
  105208. * The light is emitted in every direction from this point.
  105209. * A good example of a point light is a standard light bulb.
  105210. * Documentation: https://doc.babylonjs.com/babylon101/lights
  105211. */
  105212. export class PointLight extends ShadowLight {
  105213. private _shadowAngle;
  105214. /**
  105215. * Getter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  105216. * This specifies what angle the shadow will use to be created.
  105217. *
  105218. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  105219. */
  105220. /**
  105221. * Setter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  105222. * This specifies what angle the shadow will use to be created.
  105223. *
  105224. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  105225. */
  105226. shadowAngle: number;
  105227. /**
  105228. * Gets the direction if it has been set.
  105229. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  105230. */
  105231. /**
  105232. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  105233. */
  105234. direction: Vector3;
  105235. /**
  105236. * Creates a PointLight object from the passed name and position (Vector3) and adds it in the scene.
  105237. * A PointLight emits the light in every direction.
  105238. * It can cast shadows.
  105239. * If the scene camera is already defined and you want to set your PointLight at the camera position, just set it :
  105240. * ```javascript
  105241. * var pointLight = new PointLight("pl", camera.position, scene);
  105242. * ```
  105243. * Documentation : https://doc.babylonjs.com/babylon101/lights
  105244. * @param name The light friendly name
  105245. * @param position The position of the point light in the scene
  105246. * @param scene The scene the lights belongs to
  105247. */
  105248. constructor(name: string, position: Vector3, scene: Scene);
  105249. /**
  105250. * Returns the string "PointLight"
  105251. * @returns the class name
  105252. */
  105253. getClassName(): string;
  105254. /**
  105255. * Returns the integer 0.
  105256. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  105257. */
  105258. getTypeID(): number;
  105259. /**
  105260. * Specifies wether or not the shadowmap should be a cube texture.
  105261. * @returns true if the shadowmap needs to be a cube texture.
  105262. */
  105263. needCube(): boolean;
  105264. /**
  105265. * Returns a new Vector3 aligned with the PointLight cube system according to the passed cube face index (integer).
  105266. * @param faceIndex The index of the face we are computed the direction to generate shadow
  105267. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  105268. */
  105269. getShadowDirection(faceIndex?: number): Vector3;
  105270. /**
  105271. * Sets the passed matrix "matrix" as a left-handed perspective projection matrix with the following settings :
  105272. * - fov = PI / 2
  105273. * - aspect ratio : 1.0
  105274. * - z-near and far equal to the active camera minZ and maxZ.
  105275. * Returns the PointLight.
  105276. */
  105277. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  105278. protected _buildUniformLayout(): void;
  105279. /**
  105280. * Sets the passed Effect "effect" with the PointLight transformed position (or position, if none) and passed name (string).
  105281. * @param effect The effect to update
  105282. * @param lightIndex The index of the light in the effect to update
  105283. * @returns The point light
  105284. */
  105285. transferToEffect(effect: Effect, lightIndex: string): PointLight;
  105286. /**
  105287. * Prepares the list of defines specific to the light type.
  105288. * @param defines the list of defines
  105289. * @param lightIndex defines the index of the light for the effect
  105290. */
  105291. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  105292. }
  105293. }
  105294. declare module BABYLON {
  105295. /**
  105296. * A spot light is defined by a position, a direction, an angle, and an exponent.
  105297. * These values define a cone of light starting from the position, emitting toward the direction.
  105298. * The angle, in radians, defines the size (field of illumination) of the spotlight's conical beam,
  105299. * and the exponent defines the speed of the decay of the light with distance (reach).
  105300. * Documentation: https://doc.babylonjs.com/babylon101/lights
  105301. */
  105302. export class SpotLight extends ShadowLight {
  105303. private _angle;
  105304. private _innerAngle;
  105305. private _cosHalfAngle;
  105306. private _lightAngleScale;
  105307. private _lightAngleOffset;
  105308. /**
  105309. * Gets the cone angle of the spot light in Radians.
  105310. */
  105311. /**
  105312. * Sets the cone angle of the spot light in Radians.
  105313. */
  105314. angle: number;
  105315. /**
  105316. * Only used in gltf falloff mode, this defines the angle where
  105317. * the directional falloff will start before cutting at angle which could be seen
  105318. * as outer angle.
  105319. */
  105320. /**
  105321. * Only used in gltf falloff mode, this defines the angle where
  105322. * the directional falloff will start before cutting at angle which could be seen
  105323. * as outer angle.
  105324. */
  105325. innerAngle: number;
  105326. private _shadowAngleScale;
  105327. /**
  105328. * Allows scaling the angle of the light for shadow generation only.
  105329. */
  105330. /**
  105331. * Allows scaling the angle of the light for shadow generation only.
  105332. */
  105333. shadowAngleScale: number;
  105334. /**
  105335. * The light decay speed with the distance from the emission spot.
  105336. */
  105337. exponent: number;
  105338. private _projectionTextureMatrix;
  105339. /**
  105340. * Allows reading the projecton texture
  105341. */
  105342. readonly projectionTextureMatrix: Matrix;
  105343. protected _projectionTextureLightNear: number;
  105344. /**
  105345. * Gets the near clip of the Spotlight for texture projection.
  105346. */
  105347. /**
  105348. * Sets the near clip of the Spotlight for texture projection.
  105349. */
  105350. projectionTextureLightNear: number;
  105351. protected _projectionTextureLightFar: number;
  105352. /**
  105353. * Gets the far clip of the Spotlight for texture projection.
  105354. */
  105355. /**
  105356. * Sets the far clip of the Spotlight for texture projection.
  105357. */
  105358. projectionTextureLightFar: number;
  105359. protected _projectionTextureUpDirection: Vector3;
  105360. /**
  105361. * Gets the Up vector of the Spotlight for texture projection.
  105362. */
  105363. /**
  105364. * Sets the Up vector of the Spotlight for texture projection.
  105365. */
  105366. projectionTextureUpDirection: Vector3;
  105367. private _projectionTexture;
  105368. /**
  105369. * Gets the projection texture of the light.
  105370. */
  105371. /**
  105372. * Sets the projection texture of the light.
  105373. */
  105374. projectionTexture: Nullable<BaseTexture>;
  105375. private _projectionTextureViewLightDirty;
  105376. private _projectionTextureProjectionLightDirty;
  105377. private _projectionTextureDirty;
  105378. private _projectionTextureViewTargetVector;
  105379. private _projectionTextureViewLightMatrix;
  105380. private _projectionTextureProjectionLightMatrix;
  105381. private _projectionTextureScalingMatrix;
  105382. /**
  105383. * Creates a SpotLight object in the scene. A spot light is a simply light oriented cone.
  105384. * It can cast shadows.
  105385. * Documentation : https://doc.babylonjs.com/babylon101/lights
  105386. * @param name The light friendly name
  105387. * @param position The position of the spot light in the scene
  105388. * @param direction The direction of the light in the scene
  105389. * @param angle The cone angle of the light in Radians
  105390. * @param exponent The light decay speed with the distance from the emission spot
  105391. * @param scene The scene the lights belongs to
  105392. */
  105393. constructor(name: string, position: Vector3, direction: Vector3, angle: number, exponent: number, scene: Scene);
  105394. /**
  105395. * Returns the string "SpotLight".
  105396. * @returns the class name
  105397. */
  105398. getClassName(): string;
  105399. /**
  105400. * Returns the integer 2.
  105401. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  105402. */
  105403. getTypeID(): number;
  105404. /**
  105405. * Overrides the direction setter to recompute the projection texture view light Matrix.
  105406. */
  105407. protected _setDirection(value: Vector3): void;
  105408. /**
  105409. * Overrides the position setter to recompute the projection texture view light Matrix.
  105410. */
  105411. protected _setPosition(value: Vector3): void;
  105412. /**
  105413. * 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.
  105414. * Returns the SpotLight.
  105415. */
  105416. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  105417. protected _computeProjectionTextureViewLightMatrix(): void;
  105418. protected _computeProjectionTextureProjectionLightMatrix(): void;
  105419. /**
  105420. * Main function for light texture projection matrix computing.
  105421. */
  105422. protected _computeProjectionTextureMatrix(): void;
  105423. protected _buildUniformLayout(): void;
  105424. private _computeAngleValues;
  105425. /**
  105426. * Sets the passed Effect object with the SpotLight transfomed position (or position if not parented) and normalized direction.
  105427. * @param effect The effect to update
  105428. * @param lightIndex The index of the light in the effect to update
  105429. * @returns The spot light
  105430. */
  105431. transferToEffect(effect: Effect, lightIndex: string): SpotLight;
  105432. /**
  105433. * Disposes the light and the associated resources.
  105434. */
  105435. dispose(): void;
  105436. /**
  105437. * Prepares the list of defines specific to the light type.
  105438. * @param defines the list of defines
  105439. * @param lightIndex defines the index of the light for the effect
  105440. */
  105441. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  105442. }
  105443. }
  105444. declare module BABYLON {
  105445. /**
  105446. * Header information of HDR texture files.
  105447. */
  105448. export interface HDRInfo {
  105449. /**
  105450. * The height of the texture in pixels.
  105451. */
  105452. height: number;
  105453. /**
  105454. * The width of the texture in pixels.
  105455. */
  105456. width: number;
  105457. /**
  105458. * The index of the beginning of the data in the binary file.
  105459. */
  105460. dataPosition: number;
  105461. }
  105462. /**
  105463. * This groups tools to convert HDR texture to native colors array.
  105464. */
  105465. export class HDRTools {
  105466. private static Ldexp;
  105467. private static Rgbe2float;
  105468. private static readStringLine;
  105469. /**
  105470. * Reads header information from an RGBE texture stored in a native array.
  105471. * More information on this format are available here:
  105472. * https://en.wikipedia.org/wiki/RGBE_image_format
  105473. *
  105474. * @param uint8array The binary file stored in native array.
  105475. * @return The header information.
  105476. */
  105477. static RGBE_ReadHeader(uint8array: Uint8Array): HDRInfo;
  105478. /**
  105479. * Returns the cubemap information (each faces texture data) extracted from an RGBE texture.
  105480. * This RGBE texture needs to store the information as a panorama.
  105481. *
  105482. * More information on this format are available here:
  105483. * https://en.wikipedia.org/wiki/RGBE_image_format
  105484. *
  105485. * @param buffer The binary file stored in an array buffer.
  105486. * @param size The expected size of the extracted cubemap.
  105487. * @return The Cube Map information.
  105488. */
  105489. static GetCubeMapTextureData(buffer: ArrayBuffer, size: number): CubeMapInfo;
  105490. /**
  105491. * Returns the pixels data extracted from an RGBE texture.
  105492. * This pixels will be stored left to right up to down in the R G B order in one array.
  105493. *
  105494. * More information on this format are available here:
  105495. * https://en.wikipedia.org/wiki/RGBE_image_format
  105496. *
  105497. * @param uint8array The binary file stored in an array buffer.
  105498. * @param hdrInfo The header information of the file.
  105499. * @return The pixels data in RGB right to left up to down order.
  105500. */
  105501. static RGBE_ReadPixels(uint8array: Uint8Array, hdrInfo: HDRInfo): Float32Array;
  105502. private static RGBE_ReadPixels_RLE;
  105503. }
  105504. }
  105505. declare module BABYLON {
  105506. /**
  105507. * This represents a texture coming from an HDR input.
  105508. *
  105509. * The only supported format is currently panorama picture stored in RGBE format.
  105510. * Example of such files can be found on HDRLib: http://hdrlib.com/
  105511. */
  105512. export class HDRCubeTexture extends BaseTexture {
  105513. private static _facesMapping;
  105514. private _generateHarmonics;
  105515. private _noMipmap;
  105516. private _textureMatrix;
  105517. private _size;
  105518. private _onLoad;
  105519. private _onError;
  105520. /**
  105521. * The texture URL.
  105522. */
  105523. url: string;
  105524. /**
  105525. * The texture coordinates mode. As this texture is stored in a cube format, please modify carefully.
  105526. */
  105527. coordinatesMode: number;
  105528. protected _isBlocking: boolean;
  105529. /**
  105530. * Sets wether or not the texture is blocking during loading.
  105531. */
  105532. /**
  105533. * Gets wether or not the texture is blocking during loading.
  105534. */
  105535. isBlocking: boolean;
  105536. protected _rotationY: number;
  105537. /**
  105538. * Sets texture matrix rotation angle around Y axis in radians.
  105539. */
  105540. /**
  105541. * Gets texture matrix rotation angle around Y axis radians.
  105542. */
  105543. rotationY: number;
  105544. /**
  105545. * Gets or sets the center of the bounding box associated with the cube texture
  105546. * It must define where the camera used to render the texture was set
  105547. */
  105548. boundingBoxPosition: Vector3;
  105549. private _boundingBoxSize;
  105550. /**
  105551. * Gets or sets the size of the bounding box associated with the cube texture
  105552. * When defined, the cubemap will switch to local mode
  105553. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  105554. * @example https://www.babylonjs-playground.com/#RNASML
  105555. */
  105556. boundingBoxSize: Vector3;
  105557. /**
  105558. * Instantiates an HDRTexture from the following parameters.
  105559. *
  105560. * @param url The location of the HDR raw data (Panorama stored in RGBE format)
  105561. * @param scene The scene the texture will be used in
  105562. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  105563. * @param noMipmap Forces to not generate the mipmap if true
  105564. * @param generateHarmonics Specifies whether you want to extract the polynomial harmonics during the generation process
  105565. * @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)
  105566. * @param reserved Reserved flag for internal use.
  105567. */
  105568. 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>);
  105569. /**
  105570. * Get the current class name of the texture useful for serialization or dynamic coding.
  105571. * @returns "HDRCubeTexture"
  105572. */
  105573. getClassName(): string;
  105574. /**
  105575. * Occurs when the file is raw .hdr file.
  105576. */
  105577. private loadTexture;
  105578. clone(): HDRCubeTexture;
  105579. delayLoad(): void;
  105580. /**
  105581. * Get the texture reflection matrix used to rotate/transform the reflection.
  105582. * @returns the reflection matrix
  105583. */
  105584. getReflectionTextureMatrix(): Matrix;
  105585. /**
  105586. * Set the texture reflection matrix used to rotate/transform the reflection.
  105587. * @param value Define the reflection matrix to set
  105588. */
  105589. setReflectionTextureMatrix(value: Matrix): void;
  105590. /**
  105591. * Parses a JSON representation of an HDR Texture in order to create the texture
  105592. * @param parsedTexture Define the JSON representation
  105593. * @param scene Define the scene the texture should be created in
  105594. * @param rootUrl Define the root url in case we need to load relative dependencies
  105595. * @returns the newly created texture after parsing
  105596. */
  105597. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<HDRCubeTexture>;
  105598. serialize(): any;
  105599. }
  105600. }
  105601. declare module BABYLON {
  105602. /**
  105603. * Class used to control physics engine
  105604. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  105605. */
  105606. export class PhysicsEngine implements IPhysicsEngine {
  105607. private _physicsPlugin;
  105608. /**
  105609. * Global value used to control the smallest number supported by the simulation
  105610. */
  105611. static Epsilon: number;
  105612. private _impostors;
  105613. private _joints;
  105614. /**
  105615. * Gets the gravity vector used by the simulation
  105616. */
  105617. gravity: Vector3;
  105618. /**
  105619. * Factory used to create the default physics plugin.
  105620. * @returns The default physics plugin
  105621. */
  105622. static DefaultPluginFactory(): IPhysicsEnginePlugin;
  105623. /**
  105624. * Creates a new Physics Engine
  105625. * @param gravity defines the gravity vector used by the simulation
  105626. * @param _physicsPlugin defines the plugin to use (CannonJS by default)
  105627. */
  105628. constructor(gravity: Nullable<Vector3>, _physicsPlugin?: IPhysicsEnginePlugin);
  105629. /**
  105630. * Sets the gravity vector used by the simulation
  105631. * @param gravity defines the gravity vector to use
  105632. */
  105633. setGravity(gravity: Vector3): void;
  105634. /**
  105635. * Set the time step of the physics engine.
  105636. * Default is 1/60.
  105637. * To slow it down, enter 1/600 for example.
  105638. * To speed it up, 1/30
  105639. * @param newTimeStep defines the new timestep to apply to this world.
  105640. */
  105641. setTimeStep(newTimeStep?: number): void;
  105642. /**
  105643. * Get the time step of the physics engine.
  105644. * @returns the current time step
  105645. */
  105646. getTimeStep(): number;
  105647. /**
  105648. * Release all resources
  105649. */
  105650. dispose(): void;
  105651. /**
  105652. * Gets the name of the current physics plugin
  105653. * @returns the name of the plugin
  105654. */
  105655. getPhysicsPluginName(): string;
  105656. /**
  105657. * Adding a new impostor for the impostor tracking.
  105658. * This will be done by the impostor itself.
  105659. * @param impostor the impostor to add
  105660. */
  105661. addImpostor(impostor: PhysicsImpostor): void;
  105662. /**
  105663. * Remove an impostor from the engine.
  105664. * This impostor and its mesh will not longer be updated by the physics engine.
  105665. * @param impostor the impostor to remove
  105666. */
  105667. removeImpostor(impostor: PhysicsImpostor): void;
  105668. /**
  105669. * Add a joint to the physics engine
  105670. * @param mainImpostor defines the main impostor to which the joint is added.
  105671. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  105672. * @param joint defines the joint that will connect both impostors.
  105673. */
  105674. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  105675. /**
  105676. * Removes a joint from the simulation
  105677. * @param mainImpostor defines the impostor used with the joint
  105678. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  105679. * @param joint defines the joint to remove
  105680. */
  105681. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  105682. /**
  105683. * Called by the scene. No need to call it.
  105684. * @param delta defines the timespam between frames
  105685. */
  105686. _step(delta: number): void;
  105687. /**
  105688. * Gets the current plugin used to run the simulation
  105689. * @returns current plugin
  105690. */
  105691. getPhysicsPlugin(): IPhysicsEnginePlugin;
  105692. /**
  105693. * Gets the list of physic impostors
  105694. * @returns an array of PhysicsImpostor
  105695. */
  105696. getImpostors(): Array<PhysicsImpostor>;
  105697. /**
  105698. * Gets the impostor for a physics enabled object
  105699. * @param object defines the object impersonated by the impostor
  105700. * @returns the PhysicsImpostor or null if not found
  105701. */
  105702. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  105703. /**
  105704. * Gets the impostor for a physics body object
  105705. * @param body defines physics body used by the impostor
  105706. * @returns the PhysicsImpostor or null if not found
  105707. */
  105708. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  105709. /**
  105710. * Does a raycast in the physics world
  105711. * @param from when should the ray start?
  105712. * @param to when should the ray end?
  105713. * @returns PhysicsRaycastResult
  105714. */
  105715. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  105716. }
  105717. }
  105718. declare module BABYLON {
  105719. /** @hidden */
  105720. export class CannonJSPlugin implements IPhysicsEnginePlugin {
  105721. private _useDeltaForWorldStep;
  105722. world: any;
  105723. name: string;
  105724. private _physicsMaterials;
  105725. private _fixedTimeStep;
  105726. private _cannonRaycastResult;
  105727. private _raycastResult;
  105728. BJSCANNON: any;
  105729. constructor(_useDeltaForWorldStep?: boolean, iterations?: number, cannonInjection?: any);
  105730. setGravity(gravity: Vector3): void;
  105731. setTimeStep(timeStep: number): void;
  105732. getTimeStep(): number;
  105733. executeStep(delta: number): void;
  105734. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  105735. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  105736. generatePhysicsBody(impostor: PhysicsImpostor): void;
  105737. private _processChildMeshes;
  105738. removePhysicsBody(impostor: PhysicsImpostor): void;
  105739. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  105740. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  105741. private _addMaterial;
  105742. private _checkWithEpsilon;
  105743. private _createShape;
  105744. private _createHeightmap;
  105745. private _minus90X;
  105746. private _plus90X;
  105747. private _tmpPosition;
  105748. private _tmpDeltaPosition;
  105749. private _tmpUnityRotation;
  105750. private _updatePhysicsBodyTransformation;
  105751. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  105752. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  105753. isSupported(): boolean;
  105754. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  105755. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  105756. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  105757. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  105758. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  105759. getBodyMass(impostor: PhysicsImpostor): number;
  105760. getBodyFriction(impostor: PhysicsImpostor): number;
  105761. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  105762. getBodyRestitution(impostor: PhysicsImpostor): number;
  105763. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  105764. sleepBody(impostor: PhysicsImpostor): void;
  105765. wakeUpBody(impostor: PhysicsImpostor): void;
  105766. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number): void;
  105767. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  105768. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  105769. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  105770. getRadius(impostor: PhysicsImpostor): number;
  105771. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  105772. dispose(): void;
  105773. private _extendNamespace;
  105774. /**
  105775. * Does a raycast in the physics world
  105776. * @param from when should the ray start?
  105777. * @param to when should the ray end?
  105778. * @returns PhysicsRaycastResult
  105779. */
  105780. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  105781. }
  105782. }
  105783. declare module BABYLON {
  105784. /** @hidden */
  105785. export class OimoJSPlugin implements IPhysicsEnginePlugin {
  105786. world: any;
  105787. name: string;
  105788. BJSOIMO: any;
  105789. private _raycastResult;
  105790. constructor(iterations?: number, oimoInjection?: any);
  105791. setGravity(gravity: Vector3): void;
  105792. setTimeStep(timeStep: number): void;
  105793. getTimeStep(): number;
  105794. private _tmpImpostorsArray;
  105795. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  105796. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  105797. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  105798. generatePhysicsBody(impostor: PhysicsImpostor): void;
  105799. private _tmpPositionVector;
  105800. removePhysicsBody(impostor: PhysicsImpostor): void;
  105801. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  105802. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  105803. isSupported(): boolean;
  105804. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  105805. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  105806. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  105807. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  105808. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  105809. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  105810. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  105811. getBodyMass(impostor: PhysicsImpostor): number;
  105812. getBodyFriction(impostor: PhysicsImpostor): number;
  105813. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  105814. getBodyRestitution(impostor: PhysicsImpostor): number;
  105815. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  105816. sleepBody(impostor: PhysicsImpostor): void;
  105817. wakeUpBody(impostor: PhysicsImpostor): void;
  105818. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  105819. setMotor(joint: IMotorEnabledJoint, speed: number, force?: number, motorIndex?: number): void;
  105820. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  105821. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  105822. getRadius(impostor: PhysicsImpostor): number;
  105823. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  105824. dispose(): void;
  105825. /**
  105826. * Does a raycast in the physics world
  105827. * @param from when should the ray start?
  105828. * @param to when should the ray end?
  105829. * @returns PhysicsRaycastResult
  105830. */
  105831. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  105832. }
  105833. }
  105834. declare module BABYLON {
  105835. interface AbstractScene {
  105836. /**
  105837. * The list of reflection probes added to the scene
  105838. * @see http://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  105839. */
  105840. reflectionProbes: Array<ReflectionProbe>;
  105841. /**
  105842. * Removes the given reflection probe from this scene.
  105843. * @param toRemove The reflection probe to remove
  105844. * @returns The index of the removed reflection probe
  105845. */
  105846. removeReflectionProbe(toRemove: ReflectionProbe): number;
  105847. /**
  105848. * Adds the given reflection probe to this scene.
  105849. * @param newReflectionProbe The reflection probe to add
  105850. */
  105851. addReflectionProbe(newReflectionProbe: ReflectionProbe): void;
  105852. }
  105853. /**
  105854. * Class used to generate realtime reflection / refraction cube textures
  105855. * @see http://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  105856. */
  105857. export class ReflectionProbe {
  105858. /** defines the name of the probe */
  105859. name: string;
  105860. private _scene;
  105861. private _renderTargetTexture;
  105862. private _projectionMatrix;
  105863. private _viewMatrix;
  105864. private _target;
  105865. private _add;
  105866. private _attachedMesh;
  105867. private _invertYAxis;
  105868. /** Gets or sets probe position (center of the cube map) */
  105869. position: Vector3;
  105870. /**
  105871. * Creates a new reflection probe
  105872. * @param name defines the name of the probe
  105873. * @param size defines the texture resolution (for each face)
  105874. * @param scene defines the hosting scene
  105875. * @param generateMipMaps defines if mip maps should be generated automatically (true by default)
  105876. * @param useFloat defines if HDR data (flaot data) should be used to store colors (false by default)
  105877. */
  105878. constructor(
  105879. /** defines the name of the probe */
  105880. name: string, size: number, scene: Scene, generateMipMaps?: boolean, useFloat?: boolean);
  105881. /** Gets or sets the number of samples to use for multi-sampling (0 by default). Required WebGL2 */
  105882. samples: number;
  105883. /** Gets or sets the refresh rate to use (on every frame by default) */
  105884. refreshRate: number;
  105885. /**
  105886. * Gets the hosting scene
  105887. * @returns a Scene
  105888. */
  105889. getScene(): Scene;
  105890. /** Gets the internal CubeTexture used to render to */
  105891. readonly cubeTexture: RenderTargetTexture;
  105892. /** Gets the list of meshes to render */
  105893. readonly renderList: Nullable<AbstractMesh[]>;
  105894. /**
  105895. * Attach the probe to a specific mesh (Rendering will be done from attached mesh's position)
  105896. * @param mesh defines the mesh to attach to
  105897. */
  105898. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  105899. /**
  105900. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups
  105901. * @param renderingGroupId The rendering group id corresponding to its index
  105902. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  105903. */
  105904. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  105905. /**
  105906. * Clean all associated resources
  105907. */
  105908. dispose(): void;
  105909. /**
  105910. * Converts the reflection probe information to a readable string for debug purpose.
  105911. * @param fullDetails Supports for multiple levels of logging within scene loading
  105912. * @returns the human readable reflection probe info
  105913. */
  105914. toString(fullDetails?: boolean): string;
  105915. /**
  105916. * Get the class name of the relfection probe.
  105917. * @returns "ReflectionProbe"
  105918. */
  105919. getClassName(): string;
  105920. /**
  105921. * Serialize the reflection probe to a JSON representation we can easily use in the resepective Parse function.
  105922. * @returns The JSON representation of the texture
  105923. */
  105924. serialize(): any;
  105925. /**
  105926. * Parse the JSON representation of a reflection probe in order to recreate the reflection probe in the given scene.
  105927. * @param parsedReflectionProbe Define the JSON representation of the reflection probe
  105928. * @param scene Define the scene the parsed reflection probe should be instantiated in
  105929. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  105930. * @returns The parsed reflection probe if successful
  105931. */
  105932. static Parse(parsedReflectionProbe: any, scene: Scene, rootUrl: string): Nullable<ReflectionProbe>;
  105933. }
  105934. }
  105935. declare module BABYLON {
  105936. /** @hidden */
  105937. export var _BabylonLoaderRegistered: boolean;
  105938. }
  105939. declare module BABYLON {
  105940. /**
  105941. * The Physically based simple base material of BJS.
  105942. *
  105943. * This enables better naming and convention enforcements on top of the pbrMaterial.
  105944. * It is used as the base class for both the specGloss and metalRough conventions.
  105945. */
  105946. export abstract class PBRBaseSimpleMaterial extends PBRBaseMaterial {
  105947. /**
  105948. * Number of Simultaneous lights allowed on the material.
  105949. */
  105950. maxSimultaneousLights: number;
  105951. /**
  105952. * If sets to true, disables all the lights affecting the material.
  105953. */
  105954. disableLighting: boolean;
  105955. /**
  105956. * Environment Texture used in the material (this is use for both reflection and environment lighting).
  105957. */
  105958. environmentTexture: BaseTexture;
  105959. /**
  105960. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  105961. */
  105962. invertNormalMapX: boolean;
  105963. /**
  105964. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  105965. */
  105966. invertNormalMapY: boolean;
  105967. /**
  105968. * Normal map used in the model.
  105969. */
  105970. normalTexture: BaseTexture;
  105971. /**
  105972. * Emissivie color used to self-illuminate the model.
  105973. */
  105974. emissiveColor: Color3;
  105975. /**
  105976. * Emissivie texture used to self-illuminate the model.
  105977. */
  105978. emissiveTexture: BaseTexture;
  105979. /**
  105980. * Occlusion Channel Strenght.
  105981. */
  105982. occlusionStrength: number;
  105983. /**
  105984. * Occlusion Texture of the material (adding extra occlusion effects).
  105985. */
  105986. occlusionTexture: BaseTexture;
  105987. /**
  105988. * Defines the alpha limits in alpha test mode.
  105989. */
  105990. alphaCutOff: number;
  105991. /**
  105992. * Gets the current double sided mode.
  105993. */
  105994. /**
  105995. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  105996. */
  105997. doubleSided: boolean;
  105998. /**
  105999. * Stores the pre-calculated light information of a mesh in a texture.
  106000. */
  106001. lightmapTexture: BaseTexture;
  106002. /**
  106003. * If true, the light map contains occlusion information instead of lighting info.
  106004. */
  106005. useLightmapAsShadowmap: boolean;
  106006. /**
  106007. * Instantiates a new PBRMaterial instance.
  106008. *
  106009. * @param name The material name
  106010. * @param scene The scene the material will be use in.
  106011. */
  106012. constructor(name: string, scene: Scene);
  106013. getClassName(): string;
  106014. }
  106015. }
  106016. declare module BABYLON {
  106017. /**
  106018. * The PBR material of BJS following the metal roughness convention.
  106019. *
  106020. * This fits to the PBR convention in the GLTF definition:
  106021. * https://github.com/KhronosGroup/glTF/tree/2.0/specification/2.0
  106022. */
  106023. export class PBRMetallicRoughnessMaterial extends PBRBaseSimpleMaterial {
  106024. /**
  106025. * The base color has two different interpretations depending on the value of metalness.
  106026. * When the material is a metal, the base color is the specific measured reflectance value
  106027. * at normal incidence (F0). For a non-metal the base color represents the reflected diffuse color
  106028. * of the material.
  106029. */
  106030. baseColor: Color3;
  106031. /**
  106032. * Base texture of the metallic workflow. It contains both the baseColor information in RGB as
  106033. * well as opacity information in the alpha channel.
  106034. */
  106035. baseTexture: BaseTexture;
  106036. /**
  106037. * Specifies the metallic scalar value of the material.
  106038. * Can also be used to scale the metalness values of the metallic texture.
  106039. */
  106040. metallic: number;
  106041. /**
  106042. * Specifies the roughness scalar value of the material.
  106043. * Can also be used to scale the roughness values of the metallic texture.
  106044. */
  106045. roughness: number;
  106046. /**
  106047. * Texture containing both the metallic value in the B channel and the
  106048. * roughness value in the G channel to keep better precision.
  106049. */
  106050. metallicRoughnessTexture: BaseTexture;
  106051. /**
  106052. * Instantiates a new PBRMetalRoughnessMaterial instance.
  106053. *
  106054. * @param name The material name
  106055. * @param scene The scene the material will be use in.
  106056. */
  106057. constructor(name: string, scene: Scene);
  106058. /**
  106059. * Return the currrent class name of the material.
  106060. */
  106061. getClassName(): string;
  106062. /**
  106063. * Makes a duplicate of the current material.
  106064. * @param name - name to use for the new material.
  106065. */
  106066. clone(name: string): PBRMetallicRoughnessMaterial;
  106067. /**
  106068. * Serialize the material to a parsable JSON object.
  106069. */
  106070. serialize(): any;
  106071. /**
  106072. * Parses a JSON object correponding to the serialize function.
  106073. */
  106074. static Parse(source: any, scene: Scene, rootUrl: string): PBRMetallicRoughnessMaterial;
  106075. }
  106076. }
  106077. declare module BABYLON {
  106078. /**
  106079. * The PBR material of BJS following the specular glossiness convention.
  106080. *
  106081. * This fits to the PBR convention in the GLTF definition:
  106082. * https://github.com/KhronosGroup/glTF/tree/2.0/extensions/Khronos/KHR_materials_pbrSpecularGlossiness
  106083. */
  106084. export class PBRSpecularGlossinessMaterial extends PBRBaseSimpleMaterial {
  106085. /**
  106086. * Specifies the diffuse color of the material.
  106087. */
  106088. diffuseColor: Color3;
  106089. /**
  106090. * Specifies the diffuse texture of the material. This can also contains the opcity value in its alpha
  106091. * channel.
  106092. */
  106093. diffuseTexture: BaseTexture;
  106094. /**
  106095. * Specifies the specular color of the material. This indicates how reflective is the material (none to mirror).
  106096. */
  106097. specularColor: Color3;
  106098. /**
  106099. * Specifies the glossiness of the material. This indicates "how sharp is the reflection".
  106100. */
  106101. glossiness: number;
  106102. /**
  106103. * Specifies both the specular color RGB and the glossiness A of the material per pixels.
  106104. */
  106105. specularGlossinessTexture: BaseTexture;
  106106. /**
  106107. * Instantiates a new PBRSpecularGlossinessMaterial instance.
  106108. *
  106109. * @param name The material name
  106110. * @param scene The scene the material will be use in.
  106111. */
  106112. constructor(name: string, scene: Scene);
  106113. /**
  106114. * Return the currrent class name of the material.
  106115. */
  106116. getClassName(): string;
  106117. /**
  106118. * Makes a duplicate of the current material.
  106119. * @param name - name to use for the new material.
  106120. */
  106121. clone(name: string): PBRSpecularGlossinessMaterial;
  106122. /**
  106123. * Serialize the material to a parsable JSON object.
  106124. */
  106125. serialize(): any;
  106126. /**
  106127. * Parses a JSON object correponding to the serialize function.
  106128. */
  106129. static Parse(source: any, scene: Scene, rootUrl: string): PBRSpecularGlossinessMaterial;
  106130. }
  106131. }
  106132. declare module BABYLON {
  106133. /**
  106134. * This represents a color grading texture. This acts as a lookup table LUT, useful during post process
  106135. * It can help converting any input color in a desired output one. This can then be used to create effects
  106136. * from sepia, black and white to sixties or futuristic rendering...
  106137. *
  106138. * The only supported format is currently 3dl.
  106139. * More information on LUT: https://en.wikipedia.org/wiki/3D_lookup_table
  106140. */
  106141. export class ColorGradingTexture extends BaseTexture {
  106142. /**
  106143. * The current texture matrix. (will always be identity in color grading texture)
  106144. */
  106145. private _textureMatrix;
  106146. /**
  106147. * The texture URL.
  106148. */
  106149. url: string;
  106150. /**
  106151. * Empty line regex stored for GC.
  106152. */
  106153. private static _noneEmptyLineRegex;
  106154. private _engine;
  106155. /**
  106156. * Instantiates a ColorGradingTexture from the following parameters.
  106157. *
  106158. * @param url The location of the color gradind data (currently only supporting 3dl)
  106159. * @param scene The scene the texture will be used in
  106160. */
  106161. constructor(url: string, scene: Scene);
  106162. /**
  106163. * Returns the texture matrix used in most of the material.
  106164. * This is not used in color grading but keep for troubleshooting purpose (easily swap diffuse by colorgrading to look in).
  106165. */
  106166. getTextureMatrix(): Matrix;
  106167. /**
  106168. * Occurs when the file being loaded is a .3dl LUT file.
  106169. */
  106170. private load3dlTexture;
  106171. /**
  106172. * Starts the loading process of the texture.
  106173. */
  106174. private loadTexture;
  106175. /**
  106176. * Clones the color gradind texture.
  106177. */
  106178. clone(): ColorGradingTexture;
  106179. /**
  106180. * Called during delayed load for textures.
  106181. */
  106182. delayLoad(): void;
  106183. /**
  106184. * Parses a color grading texture serialized by Babylon.
  106185. * @param parsedTexture The texture information being parsedTexture
  106186. * @param scene The scene to load the texture in
  106187. * @param rootUrl The root url of the data assets to load
  106188. * @return A color gradind texture
  106189. */
  106190. static Parse(parsedTexture: any, scene: Scene): Nullable<ColorGradingTexture>;
  106191. /**
  106192. * Serializes the LUT texture to json format.
  106193. */
  106194. serialize(): any;
  106195. }
  106196. }
  106197. declare module BABYLON {
  106198. /**
  106199. * This represents a texture coming from an equirectangular image supported by the web browser canvas.
  106200. */
  106201. export class EquiRectangularCubeTexture extends BaseTexture {
  106202. /** The six faces of the cube. */
  106203. private static _FacesMapping;
  106204. private _noMipmap;
  106205. private _onLoad;
  106206. private _onError;
  106207. /** The size of the cubemap. */
  106208. private _size;
  106209. /** The buffer of the image. */
  106210. private _buffer;
  106211. /** The width of the input image. */
  106212. private _width;
  106213. /** The height of the input image. */
  106214. private _height;
  106215. /** The URL to the image. */
  106216. url: string;
  106217. /** The texture coordinates mode. As this texture is stored in a cube format, please modify carefully. */
  106218. coordinatesMode: number;
  106219. /**
  106220. * Instantiates an EquiRectangularCubeTexture from the following parameters.
  106221. * @param url The location of the image
  106222. * @param scene The scene the texture will be used in
  106223. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  106224. * @param noMipmap Forces to not generate the mipmap if true
  106225. * @param gammaSpace Specifies if the texture will be used in gamma or linear space
  106226. * (the PBR material requires those textures in linear space, but the standard material would require them in Gamma space)
  106227. * @param onLoad — defines a callback called when texture is loaded
  106228. * @param onError — defines a callback called if there is an error
  106229. */
  106230. constructor(url: string, scene: Scene, size: number, noMipmap?: boolean, gammaSpace?: boolean, onLoad?: Nullable<() => void>, onError?: Nullable<(message?: string, exception?: any) => void>);
  106231. /**
  106232. * Load the image data, by putting the image on a canvas and extracting its buffer.
  106233. */
  106234. private loadImage;
  106235. /**
  106236. * Convert the image buffer into a cubemap and create a CubeTexture.
  106237. */
  106238. private loadTexture;
  106239. /**
  106240. * Convert the ArrayBuffer into a Float32Array and drop the transparency channel.
  106241. * @param buffer The ArrayBuffer that should be converted.
  106242. * @returns The buffer as Float32Array.
  106243. */
  106244. private getFloat32ArrayFromArrayBuffer;
  106245. /**
  106246. * Get the current class name of the texture useful for serialization or dynamic coding.
  106247. * @returns "EquiRectangularCubeTexture"
  106248. */
  106249. getClassName(): string;
  106250. /**
  106251. * Create a clone of the current EquiRectangularCubeTexture and return it.
  106252. * @returns A clone of the current EquiRectangularCubeTexture.
  106253. */
  106254. clone(): EquiRectangularCubeTexture;
  106255. }
  106256. }
  106257. declare module BABYLON {
  106258. /**
  106259. * Based on jsTGALoader - Javascript loader for TGA file
  106260. * By Vincent Thibault
  106261. * @see http://blog.robrowser.com/javascript-tga-loader.html
  106262. */
  106263. export class TGATools {
  106264. private static _TYPE_INDEXED;
  106265. private static _TYPE_RGB;
  106266. private static _TYPE_GREY;
  106267. private static _TYPE_RLE_INDEXED;
  106268. private static _TYPE_RLE_RGB;
  106269. private static _TYPE_RLE_GREY;
  106270. private static _ORIGIN_MASK;
  106271. private static _ORIGIN_SHIFT;
  106272. private static _ORIGIN_BL;
  106273. private static _ORIGIN_BR;
  106274. private static _ORIGIN_UL;
  106275. private static _ORIGIN_UR;
  106276. /**
  106277. * Gets the header of a TGA file
  106278. * @param data defines the TGA data
  106279. * @returns the header
  106280. */
  106281. static GetTGAHeader(data: Uint8Array): any;
  106282. /**
  106283. * Uploads TGA content to a Babylon Texture
  106284. * @hidden
  106285. */
  106286. static UploadContent(texture: InternalTexture, data: Uint8Array): void;
  106287. /** @hidden */
  106288. 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;
  106289. /** @hidden */
  106290. 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;
  106291. /** @hidden */
  106292. 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;
  106293. /** @hidden */
  106294. 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;
  106295. /** @hidden */
  106296. 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;
  106297. /** @hidden */
  106298. 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;
  106299. }
  106300. }
  106301. declare module BABYLON {
  106302. /**
  106303. * Implementation of the TGA Texture Loader.
  106304. * @hidden
  106305. */
  106306. export class _TGATextureLoader implements IInternalTextureLoader {
  106307. /**
  106308. * Defines wether the loader supports cascade loading the different faces.
  106309. */
  106310. readonly supportCascades: boolean;
  106311. /**
  106312. * This returns if the loader support the current file information.
  106313. * @param extension defines the file extension of the file being loaded
  106314. * @param textureFormatInUse defines the current compressed format in use iun the engine
  106315. * @param fallback defines the fallback internal texture if any
  106316. * @param isBase64 defines whether the texture is encoded as a base64
  106317. * @param isBuffer defines whether the texture data are stored as a buffer
  106318. * @returns true if the loader can load the specified file
  106319. */
  106320. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  106321. /**
  106322. * Transform the url before loading if required.
  106323. * @param rootUrl the url of the texture
  106324. * @param textureFormatInUse defines the current compressed format in use iun the engine
  106325. * @returns the transformed texture
  106326. */
  106327. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  106328. /**
  106329. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  106330. * @param rootUrl the url of the texture
  106331. * @param textureFormatInUse defines the current compressed format in use iun the engine
  106332. * @returns the fallback texture
  106333. */
  106334. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  106335. /**
  106336. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  106337. * @param data contains the texture data
  106338. * @param texture defines the BabylonJS internal texture
  106339. * @param createPolynomials will be true if polynomials have been requested
  106340. * @param onLoad defines the callback to trigger once the texture is ready
  106341. * @param onError defines the callback to trigger in case of error
  106342. */
  106343. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  106344. /**
  106345. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  106346. * @param data contains the texture data
  106347. * @param texture defines the BabylonJS internal texture
  106348. * @param callback defines the method to call once ready to upload
  106349. */
  106350. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  106351. }
  106352. }
  106353. declare module BABYLON {
  106354. /**
  106355. * 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.
  106356. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  106357. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  106358. */
  106359. export class CustomProceduralTexture extends ProceduralTexture {
  106360. private _animate;
  106361. private _time;
  106362. private _config;
  106363. private _texturePath;
  106364. /**
  106365. * Instantiates a new Custom Procedural Texture.
  106366. * 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.
  106367. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  106368. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  106369. * @param name Define the name of the texture
  106370. * @param texturePath Define the folder path containing all the cutom texture related files (config, shaders...)
  106371. * @param size Define the size of the texture to create
  106372. * @param scene Define the scene the texture belongs to
  106373. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  106374. * @param generateMipMaps Define if the texture should creates mip maps or not
  106375. */
  106376. constructor(name: string, texturePath: string, size: number, scene: Scene, fallbackTexture?: Texture, generateMipMaps?: boolean);
  106377. private _loadJson;
  106378. /**
  106379. * Is the texture ready to be used ? (rendered at least once)
  106380. * @returns true if ready, otherwise, false.
  106381. */
  106382. isReady(): boolean;
  106383. /**
  106384. * Render the texture to its associated render target.
  106385. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  106386. */
  106387. render(useCameraPostProcess?: boolean): void;
  106388. /**
  106389. * Update the list of dependant textures samplers in the shader.
  106390. */
  106391. updateTextures(): void;
  106392. /**
  106393. * Update the uniform values of the procedural texture in the shader.
  106394. */
  106395. updateShaderUniforms(): void;
  106396. /**
  106397. * Define if the texture animates or not.
  106398. */
  106399. animate: boolean;
  106400. }
  106401. }
  106402. declare module BABYLON {
  106403. /** @hidden */
  106404. export var noisePixelShader: {
  106405. name: string;
  106406. shader: string;
  106407. };
  106408. }
  106409. declare module BABYLON {
  106410. /**
  106411. * Class used to generate noise procedural textures
  106412. */
  106413. export class NoiseProceduralTexture extends ProceduralTexture {
  106414. private _time;
  106415. /** Gets or sets a value between 0 and 1 indicating the overall brightness of the texture (default is 0.2) */
  106416. brightness: number;
  106417. /** Defines the number of octaves to process */
  106418. octaves: number;
  106419. /** Defines the level of persistence (0.8 by default) */
  106420. persistence: number;
  106421. /** Gets or sets animation speed factor (default is 1) */
  106422. animationSpeedFactor: number;
  106423. /**
  106424. * Creates a new NoiseProceduralTexture
  106425. * @param name defines the name fo the texture
  106426. * @param size defines the size of the texture (default is 256)
  106427. * @param scene defines the hosting scene
  106428. * @param fallbackTexture defines the texture to use if the NoiseProceduralTexture can't be created
  106429. * @param generateMipMaps defines if mipmaps must be generated (true by default)
  106430. */
  106431. constructor(name: string, size?: number, scene?: Nullable<Scene>, fallbackTexture?: Texture, generateMipMaps?: boolean);
  106432. private _updateShaderUniforms;
  106433. protected _getDefines(): string;
  106434. /** Generate the current state of the procedural texture */
  106435. render(useCameraPostProcess?: boolean): void;
  106436. /**
  106437. * Serializes this noise procedural texture
  106438. * @returns a serialized noise procedural texture object
  106439. */
  106440. serialize(): any;
  106441. /**
  106442. * Creates a NoiseProceduralTexture from parsed noise procedural texture data
  106443. * @param parsedTexture defines parsed texture data
  106444. * @param scene defines the current scene
  106445. * @param rootUrl defines the root URL containing noise procedural texture information
  106446. * @returns a parsed NoiseProceduralTexture
  106447. */
  106448. static Parse(parsedTexture: any, scene: Scene): NoiseProceduralTexture;
  106449. }
  106450. }
  106451. declare module BABYLON {
  106452. /**
  106453. * Raw cube texture where the raw buffers are passed in
  106454. */
  106455. export class RawCubeTexture extends CubeTexture {
  106456. /**
  106457. * Creates a cube texture where the raw buffers are passed in.
  106458. * @param scene defines the scene the texture is attached to
  106459. * @param data defines the array of data to use to create each face
  106460. * @param size defines the size of the textures
  106461. * @param format defines the format of the data
  106462. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  106463. * @param generateMipMaps defines if the engine should generate the mip levels
  106464. * @param invertY defines if data must be stored with Y axis inverted
  106465. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  106466. * @param compression defines the compression used (null by default)
  106467. */
  106468. constructor(scene: Scene, data: Nullable<ArrayBufferView[]>, size: number, format?: number, type?: number, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, compression?: Nullable<string>);
  106469. /**
  106470. * Updates the raw cube texture.
  106471. * @param data defines the data to store
  106472. * @param format defines the data format
  106473. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  106474. * @param invertY defines if data must be stored with Y axis inverted
  106475. * @param compression defines the compression used (null by default)
  106476. * @param level defines which level of the texture to update
  106477. */
  106478. update(data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression?: Nullable<string>): void;
  106479. /**
  106480. * Updates a raw cube texture with RGBD encoded data.
  106481. * @param data defines the array of data [mipmap][face] to use to create each face
  106482. * @param sphericalPolynomial defines the spherical polynomial for irradiance
  106483. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  106484. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  106485. * @returns a promsie that resolves when the operation is complete
  106486. */
  106487. updateRGBDAsync(data: ArrayBufferView[][], sphericalPolynomial?: Nullable<SphericalPolynomial>, lodScale?: number, lodOffset?: number): Promise<void>;
  106488. /**
  106489. * Clones the raw cube texture.
  106490. * @return a new cube texture
  106491. */
  106492. clone(): CubeTexture;
  106493. /** @hidden */
  106494. static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  106495. }
  106496. }
  106497. declare module BABYLON {
  106498. /**
  106499. * Class used to store 3D textures containing user data
  106500. */
  106501. export class RawTexture3D extends Texture {
  106502. /** Gets or sets the texture format to use */
  106503. format: number;
  106504. private _engine;
  106505. /**
  106506. * Create a new RawTexture3D
  106507. * @param data defines the data of the texture
  106508. * @param width defines the width of the texture
  106509. * @param height defines the height of the texture
  106510. * @param depth defines the depth of the texture
  106511. * @param format defines the texture format to use
  106512. * @param scene defines the hosting scene
  106513. * @param generateMipMaps defines a boolean indicating if mip levels should be generated (true by default)
  106514. * @param invertY defines if texture must be stored with Y axis inverted
  106515. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  106516. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  106517. */
  106518. constructor(data: ArrayBufferView, width: number, height: number, depth: number,
  106519. /** Gets or sets the texture format to use */
  106520. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, textureType?: number);
  106521. /**
  106522. * Update the texture with new data
  106523. * @param data defines the data to store in the texture
  106524. */
  106525. update(data: ArrayBufferView): void;
  106526. }
  106527. }
  106528. declare module BABYLON {
  106529. /**
  106530. * Creates a refraction texture used by refraction channel of the standard material.
  106531. * It is like a mirror but to see through a material.
  106532. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  106533. */
  106534. export class RefractionTexture extends RenderTargetTexture {
  106535. /**
  106536. * Define the reflection plane we want to use. The refractionPlane is usually set to the constructed refractor.
  106537. * 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.
  106538. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  106539. */
  106540. refractionPlane: Plane;
  106541. /**
  106542. * Define how deep under the surface we should see.
  106543. */
  106544. depth: number;
  106545. /**
  106546. * Creates a refraction texture used by refraction channel of the standard material.
  106547. * It is like a mirror but to see through a material.
  106548. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  106549. * @param name Define the texture name
  106550. * @param size Define the size of the underlying texture
  106551. * @param scene Define the scene the refraction belongs to
  106552. * @param generateMipMaps Define if we need to generate mips level for the refraction
  106553. */
  106554. constructor(name: string, size: number, scene: Scene, generateMipMaps?: boolean);
  106555. /**
  106556. * Clone the refraction texture.
  106557. * @returns the cloned texture
  106558. */
  106559. clone(): RefractionTexture;
  106560. /**
  106561. * Serialize the texture to a JSON representation you could use in Parse later on
  106562. * @returns the serialized JSON representation
  106563. */
  106564. serialize(): any;
  106565. }
  106566. }
  106567. declare module BABYLON {
  106568. /**
  106569. * Configuration for Draco compression
  106570. */
  106571. export interface IDracoCompressionConfiguration {
  106572. /**
  106573. * Configuration for the decoder.
  106574. */
  106575. decoder?: {
  106576. /**
  106577. * The url to the WebAssembly module.
  106578. */
  106579. wasmUrl?: string;
  106580. /**
  106581. * The url to the WebAssembly binary.
  106582. */
  106583. wasmBinaryUrl?: string;
  106584. /**
  106585. * The url to the fallback JavaScript module.
  106586. */
  106587. fallbackUrl?: string;
  106588. };
  106589. }
  106590. /**
  106591. * Draco compression (https://google.github.io/draco/)
  106592. *
  106593. * This class wraps the Draco module.
  106594. *
  106595. * **Encoder**
  106596. *
  106597. * The encoder is not currently implemented.
  106598. *
  106599. * **Decoder**
  106600. *
  106601. * 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.
  106602. *
  106603. * To update the configuration, use the following code:
  106604. * ```javascript
  106605. * DracoCompression.Configuration = {
  106606. * decoder: {
  106607. * wasmUrl: "<url to the WebAssembly library>",
  106608. * wasmBinaryUrl: "<url to the WebAssembly binary>",
  106609. * fallbackUrl: "<url to the fallback JavaScript library>",
  106610. * }
  106611. * };
  106612. * ```
  106613. *
  106614. * 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.
  106615. * Decoding will automatically fallback to the JavaScript version if WebAssembly version is not configured or if WebAssembly is not supported by the browser.
  106616. * Use `DracoCompression.DecoderAvailable` to determine if the decoder is available for the current session.
  106617. *
  106618. * To decode Draco compressed data, create a DracoCompression object and call decodeMeshAsync:
  106619. * ```javascript
  106620. * var dracoCompression = new DracoCompression();
  106621. * var vertexData = await dracoCompression.decodeMeshAsync(data, {
  106622. * [VertexBuffer.PositionKind]: 0
  106623. * });
  106624. * ```
  106625. *
  106626. * @see https://www.babylonjs-playground.com/#N3EK4B#0
  106627. */
  106628. export class DracoCompression implements IDisposable {
  106629. private static _DecoderModulePromise;
  106630. /**
  106631. * The configuration. Defaults to the following urls:
  106632. * - wasmUrl: "https://preview.babylonjs.com/draco_wasm_wrapper_gltf.js"
  106633. * - wasmBinaryUrl: "https://preview.babylonjs.com/draco_decoder_gltf.wasm"
  106634. * - fallbackUrl: "https://preview.babylonjs.com/draco_decoder_gltf.js"
  106635. */
  106636. static Configuration: IDracoCompressionConfiguration;
  106637. /**
  106638. * Returns true if the decoder is available.
  106639. */
  106640. static readonly DecoderAvailable: boolean;
  106641. /**
  106642. * Constructor
  106643. */
  106644. constructor();
  106645. /**
  106646. * Stop all async operations and release resources.
  106647. */
  106648. dispose(): void;
  106649. /**
  106650. * Decode Draco compressed mesh data to vertex data.
  106651. * @param data The ArrayBuffer or ArrayBufferView for the Draco compression data
  106652. * @param attributes A map of attributes from vertex buffer kinds to Draco unique ids
  106653. * @returns A promise that resolves with the decoded vertex data
  106654. */
  106655. decodeMeshAsync(data: ArrayBuffer | ArrayBufferView, attributes: {
  106656. [kind: string]: number;
  106657. }): Promise<VertexData>;
  106658. private static _GetDecoderModule;
  106659. private static _LoadScriptAsync;
  106660. private static _LoadFileAsync;
  106661. }
  106662. }
  106663. declare module BABYLON {
  106664. /**
  106665. * Class for building Constructive Solid Geometry
  106666. */
  106667. export class CSG {
  106668. private polygons;
  106669. /**
  106670. * The world matrix
  106671. */
  106672. matrix: Matrix;
  106673. /**
  106674. * Stores the position
  106675. */
  106676. position: Vector3;
  106677. /**
  106678. * Stores the rotation
  106679. */
  106680. rotation: Vector3;
  106681. /**
  106682. * Stores the rotation quaternion
  106683. */
  106684. rotationQuaternion: Nullable<Quaternion>;
  106685. /**
  106686. * Stores the scaling vector
  106687. */
  106688. scaling: Vector3;
  106689. /**
  106690. * Convert the Mesh to CSG
  106691. * @param mesh The Mesh to convert to CSG
  106692. * @returns A new CSG from the Mesh
  106693. */
  106694. static FromMesh(mesh: Mesh): CSG;
  106695. /**
  106696. * Construct a CSG solid from a list of `CSG.Polygon` instances.
  106697. * @param polygons Polygons used to construct a CSG solid
  106698. */
  106699. private static FromPolygons;
  106700. /**
  106701. * Clones, or makes a deep copy, of the CSG
  106702. * @returns A new CSG
  106703. */
  106704. clone(): CSG;
  106705. /**
  106706. * Unions this CSG with another CSG
  106707. * @param csg The CSG to union against this CSG
  106708. * @returns The unioned CSG
  106709. */
  106710. union(csg: CSG): CSG;
  106711. /**
  106712. * Unions this CSG with another CSG in place
  106713. * @param csg The CSG to union against this CSG
  106714. */
  106715. unionInPlace(csg: CSG): void;
  106716. /**
  106717. * Subtracts this CSG with another CSG
  106718. * @param csg The CSG to subtract against this CSG
  106719. * @returns A new CSG
  106720. */
  106721. subtract(csg: CSG): CSG;
  106722. /**
  106723. * Subtracts this CSG with another CSG in place
  106724. * @param csg The CSG to subtact against this CSG
  106725. */
  106726. subtractInPlace(csg: CSG): void;
  106727. /**
  106728. * Intersect this CSG with another CSG
  106729. * @param csg The CSG to intersect against this CSG
  106730. * @returns A new CSG
  106731. */
  106732. intersect(csg: CSG): CSG;
  106733. /**
  106734. * Intersects this CSG with another CSG in place
  106735. * @param csg The CSG to intersect against this CSG
  106736. */
  106737. intersectInPlace(csg: CSG): void;
  106738. /**
  106739. * Return a new CSG solid with solid and empty space switched. This solid is
  106740. * not modified.
  106741. * @returns A new CSG solid with solid and empty space switched
  106742. */
  106743. inverse(): CSG;
  106744. /**
  106745. * Inverses the CSG in place
  106746. */
  106747. inverseInPlace(): void;
  106748. /**
  106749. * This is used to keep meshes transformations so they can be restored
  106750. * when we build back a Babylon Mesh
  106751. * NB : All CSG operations are performed in world coordinates
  106752. * @param csg The CSG to copy the transform attributes from
  106753. * @returns This CSG
  106754. */
  106755. copyTransformAttributes(csg: CSG): CSG;
  106756. /**
  106757. * Build Raw mesh from CSG
  106758. * Coordinates here are in world space
  106759. * @param name The name of the mesh geometry
  106760. * @param scene The Scene
  106761. * @param keepSubMeshes Specifies if the submeshes should be kept
  106762. * @returns A new Mesh
  106763. */
  106764. buildMeshGeometry(name: string, scene: Scene, keepSubMeshes: boolean): Mesh;
  106765. /**
  106766. * Build Mesh from CSG taking material and transforms into account
  106767. * @param name The name of the Mesh
  106768. * @param material The material of the Mesh
  106769. * @param scene The Scene
  106770. * @param keepSubMeshes Specifies if submeshes should be kept
  106771. * @returns The new Mesh
  106772. */
  106773. toMesh(name: string, material: Nullable<Material>, scene: Scene, keepSubMeshes: boolean): Mesh;
  106774. }
  106775. }
  106776. declare module BABYLON {
  106777. /**
  106778. * Class used to create a trail following a mesh
  106779. */
  106780. export class TrailMesh extends Mesh {
  106781. private _generator;
  106782. private _autoStart;
  106783. private _running;
  106784. private _diameter;
  106785. private _length;
  106786. private _sectionPolygonPointsCount;
  106787. private _sectionVectors;
  106788. private _sectionNormalVectors;
  106789. private _beforeRenderObserver;
  106790. /**
  106791. * @constructor
  106792. * @param name The value used by scene.getMeshByName() to do a lookup.
  106793. * @param generator The mesh to generate a trail.
  106794. * @param scene The scene to add this mesh to.
  106795. * @param diameter Diameter of trailing mesh. Default is 1.
  106796. * @param length Length of trailing mesh. Default is 60.
  106797. * @param autoStart Automatically start trailing mesh. Default true.
  106798. */
  106799. constructor(name: string, generator: AbstractMesh, scene: Scene, diameter?: number, length?: number, autoStart?: boolean);
  106800. /**
  106801. * "TrailMesh"
  106802. * @returns "TrailMesh"
  106803. */
  106804. getClassName(): string;
  106805. private _createMesh;
  106806. /**
  106807. * Start trailing mesh.
  106808. */
  106809. start(): void;
  106810. /**
  106811. * Stop trailing mesh.
  106812. */
  106813. stop(): void;
  106814. /**
  106815. * Update trailing mesh geometry.
  106816. */
  106817. update(): void;
  106818. /**
  106819. * Returns a new TrailMesh object.
  106820. * @param name is a string, the name given to the new mesh
  106821. * @param newGenerator use new generator object for cloned trail mesh
  106822. * @returns a new mesh
  106823. */
  106824. clone(name: string | undefined, newGenerator: AbstractMesh): TrailMesh;
  106825. /**
  106826. * Serializes this trail mesh
  106827. * @param serializationObject object to write serialization to
  106828. */
  106829. serialize(serializationObject: any): void;
  106830. /**
  106831. * Parses a serialized trail mesh
  106832. * @param parsedMesh the serialized mesh
  106833. * @param scene the scene to create the trail mesh in
  106834. * @returns the created trail mesh
  106835. */
  106836. static Parse(parsedMesh: any, scene: Scene): TrailMesh;
  106837. }
  106838. }
  106839. declare module BABYLON {
  106840. /**
  106841. * Class containing static functions to help procedurally build meshes
  106842. */
  106843. export class RibbonBuilder {
  106844. /**
  106845. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  106846. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  106847. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  106848. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  106849. * * 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
  106850. * * 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
  106851. * * 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
  106852. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  106853. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  106854. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  106855. * * 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
  106856. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  106857. * * 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
  106858. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  106859. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  106860. * @param name defines the name of the mesh
  106861. * @param options defines the options used to create the mesh
  106862. * @param scene defines the hosting scene
  106863. * @returns the ribbon mesh
  106864. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  106865. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  106866. */
  106867. static CreateRibbon(name: string, options: {
  106868. pathArray: Vector3[][];
  106869. closeArray?: boolean;
  106870. closePath?: boolean;
  106871. offset?: number;
  106872. updatable?: boolean;
  106873. sideOrientation?: number;
  106874. frontUVs?: Vector4;
  106875. backUVs?: Vector4;
  106876. instance?: Mesh;
  106877. invertUV?: boolean;
  106878. uvs?: Vector2[];
  106879. colors?: Color4[];
  106880. }, scene?: Nullable<Scene>): Mesh;
  106881. }
  106882. }
  106883. declare module BABYLON {
  106884. /**
  106885. * Class containing static functions to help procedurally build meshes
  106886. */
  106887. export class TorusKnotBuilder {
  106888. /**
  106889. * Creates a torus knot mesh
  106890. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  106891. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  106892. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  106893. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  106894. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  106895. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  106896. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  106897. * @param name defines the name of the mesh
  106898. * @param options defines the options used to create the mesh
  106899. * @param scene defines the hosting scene
  106900. * @returns the torus knot mesh
  106901. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  106902. */
  106903. static CreateTorusKnot(name: string, options: {
  106904. radius?: number;
  106905. tube?: number;
  106906. radialSegments?: number;
  106907. tubularSegments?: number;
  106908. p?: number;
  106909. q?: number;
  106910. updatable?: boolean;
  106911. sideOrientation?: number;
  106912. frontUVs?: Vector4;
  106913. backUVs?: Vector4;
  106914. }, scene: any): Mesh;
  106915. }
  106916. }
  106917. declare module BABYLON {
  106918. /**
  106919. * Polygon
  106920. * @see https://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  106921. */
  106922. export class Polygon {
  106923. /**
  106924. * Creates a rectangle
  106925. * @param xmin bottom X coord
  106926. * @param ymin bottom Y coord
  106927. * @param xmax top X coord
  106928. * @param ymax top Y coord
  106929. * @returns points that make the resulting rectation
  106930. */
  106931. static Rectangle(xmin: number, ymin: number, xmax: number, ymax: number): Vector2[];
  106932. /**
  106933. * Creates a circle
  106934. * @param radius radius of circle
  106935. * @param cx scale in x
  106936. * @param cy scale in y
  106937. * @param numberOfSides number of sides that make up the circle
  106938. * @returns points that make the resulting circle
  106939. */
  106940. static Circle(radius: number, cx?: number, cy?: number, numberOfSides?: number): Vector2[];
  106941. /**
  106942. * Creates a polygon from input string
  106943. * @param input Input polygon data
  106944. * @returns the parsed points
  106945. */
  106946. static Parse(input: string): Vector2[];
  106947. /**
  106948. * Starts building a polygon from x and y coordinates
  106949. * @param x x coordinate
  106950. * @param y y coordinate
  106951. * @returns the started path2
  106952. */
  106953. static StartingAt(x: number, y: number): Path2;
  106954. }
  106955. /**
  106956. * Builds a polygon
  106957. * @see https://doc.babylonjs.com/how_to/polygonmeshbuilder
  106958. */
  106959. export class PolygonMeshBuilder {
  106960. private _points;
  106961. private _outlinepoints;
  106962. private _holes;
  106963. private _name;
  106964. private _scene;
  106965. private _epoints;
  106966. private _eholes;
  106967. private _addToepoint;
  106968. /**
  106969. * Babylon reference to the earcut plugin.
  106970. */
  106971. bjsEarcut: any;
  106972. /**
  106973. * Creates a PolygonMeshBuilder
  106974. * @param name name of the builder
  106975. * @param contours Path of the polygon
  106976. * @param scene scene to add to when creating the mesh
  106977. * @param earcutInjection can be used to inject your own earcut reference
  106978. */
  106979. constructor(name: string, contours: Path2 | Vector2[] | any, scene?: Scene, earcutInjection?: any);
  106980. /**
  106981. * Adds a whole within the polygon
  106982. * @param hole Array of points defining the hole
  106983. * @returns this
  106984. */
  106985. addHole(hole: Vector2[]): PolygonMeshBuilder;
  106986. /**
  106987. * Creates the polygon
  106988. * @param updatable If the mesh should be updatable
  106989. * @param depth The depth of the mesh created
  106990. * @returns the created mesh
  106991. */
  106992. build(updatable?: boolean, depth?: number): Mesh;
  106993. /**
  106994. * Creates the polygon
  106995. * @param depth The depth of the mesh created
  106996. * @returns the created VertexData
  106997. */
  106998. buildVertexData(depth?: number): VertexData;
  106999. /**
  107000. * Adds a side to the polygon
  107001. * @param positions points that make the polygon
  107002. * @param normals normals of the polygon
  107003. * @param uvs uvs of the polygon
  107004. * @param indices indices of the polygon
  107005. * @param bounds bounds of the polygon
  107006. * @param points points of the polygon
  107007. * @param depth depth of the polygon
  107008. * @param flip flip of the polygon
  107009. */
  107010. private addSide;
  107011. }
  107012. }
  107013. declare module BABYLON {
  107014. /**
  107015. * Class containing static functions to help procedurally build meshes
  107016. */
  107017. export class PolygonBuilder {
  107018. /**
  107019. * Creates a polygon mesh
  107020. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  107021. * * 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
  107022. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  107023. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  107024. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4)
  107025. * * Remember you can only change the shape positions, not their number when updating a polygon
  107026. * @param name defines the name of the mesh
  107027. * @param options defines the options used to create the mesh
  107028. * @param scene defines the hosting scene
  107029. * @param earcutInjection can be used to inject your own earcut reference
  107030. * @returns the polygon mesh
  107031. */
  107032. static CreatePolygon(name: string, options: {
  107033. shape: Vector3[];
  107034. holes?: Vector3[][];
  107035. depth?: number;
  107036. faceUV?: Vector4[];
  107037. faceColors?: Color4[];
  107038. updatable?: boolean;
  107039. sideOrientation?: number;
  107040. frontUVs?: Vector4;
  107041. backUVs?: Vector4;
  107042. }, scene: Scene, earcutInjection?: any): Mesh;
  107043. /**
  107044. * Creates an extruded polygon mesh, with depth in the Y direction.
  107045. * * 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)
  107046. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  107047. * @param name defines the name of the mesh
  107048. * @param options defines the options used to create the mesh
  107049. * @param scene defines the hosting scene
  107050. * @param earcutInjection can be used to inject your own earcut reference
  107051. * @returns the polygon mesh
  107052. */
  107053. static ExtrudePolygon(name: string, options: {
  107054. shape: Vector3[];
  107055. holes?: Vector3[][];
  107056. depth?: number;
  107057. faceUV?: Vector4[];
  107058. faceColors?: Color4[];
  107059. updatable?: boolean;
  107060. sideOrientation?: number;
  107061. frontUVs?: Vector4;
  107062. backUVs?: Vector4;
  107063. }, scene: Scene, earcutInjection?: any): Mesh;
  107064. }
  107065. }
  107066. declare module BABYLON {
  107067. /**
  107068. * Class containing static functions to help procedurally build meshes
  107069. */
  107070. export class ShapeBuilder {
  107071. /**
  107072. * 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.
  107073. * * 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.
  107074. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  107075. * * 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.
  107076. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  107077. * * 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
  107078. * * 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
  107079. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  107080. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  107081. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  107082. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  107083. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  107084. * @param name defines the name of the mesh
  107085. * @param options defines the options used to create the mesh
  107086. * @param scene defines the hosting scene
  107087. * @returns the extruded shape mesh
  107088. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  107089. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  107090. */
  107091. static ExtrudeShape(name: string, options: {
  107092. shape: Vector3[];
  107093. path: Vector3[];
  107094. scale?: number;
  107095. rotation?: number;
  107096. cap?: number;
  107097. updatable?: boolean;
  107098. sideOrientation?: number;
  107099. frontUVs?: Vector4;
  107100. backUVs?: Vector4;
  107101. instance?: Mesh;
  107102. invertUV?: boolean;
  107103. }, scene?: Nullable<Scene>): Mesh;
  107104. /**
  107105. * Creates an custom extruded shape mesh.
  107106. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  107107. * * 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.
  107108. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  107109. * * 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
  107110. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  107111. * * 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
  107112. * * It must returns a float value that will be the scale value applied to the shape on each path point
  107113. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  107114. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  107115. * * 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
  107116. * * 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
  107117. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  107118. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  107119. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  107120. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  107121. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  107122. * @param name defines the name of the mesh
  107123. * @param options defines the options used to create the mesh
  107124. * @param scene defines the hosting scene
  107125. * @returns the custom extruded shape mesh
  107126. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  107127. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  107128. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  107129. */
  107130. static ExtrudeShapeCustom(name: string, options: {
  107131. shape: Vector3[];
  107132. path: Vector3[];
  107133. scaleFunction?: any;
  107134. rotationFunction?: any;
  107135. ribbonCloseArray?: boolean;
  107136. ribbonClosePath?: boolean;
  107137. cap?: number;
  107138. updatable?: boolean;
  107139. sideOrientation?: number;
  107140. frontUVs?: Vector4;
  107141. backUVs?: Vector4;
  107142. instance?: Mesh;
  107143. invertUV?: boolean;
  107144. }, scene: Scene): Mesh;
  107145. private static _ExtrudeShapeGeneric;
  107146. }
  107147. }
  107148. declare module BABYLON {
  107149. /**
  107150. * Class containing static functions to help procedurally build meshes
  107151. */
  107152. export class LatheBuilder {
  107153. /**
  107154. * Creates lathe mesh.
  107155. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  107156. * * 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
  107157. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  107158. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  107159. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  107160. * * 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
  107161. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  107162. * * 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
  107163. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  107164. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  107165. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  107166. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  107167. * @param name defines the name of the mesh
  107168. * @param options defines the options used to create the mesh
  107169. * @param scene defines the hosting scene
  107170. * @returns the lathe mesh
  107171. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  107172. */
  107173. static CreateLathe(name: string, options: {
  107174. shape: Vector3[];
  107175. radius?: number;
  107176. tessellation?: number;
  107177. clip?: number;
  107178. arc?: number;
  107179. closed?: boolean;
  107180. updatable?: boolean;
  107181. sideOrientation?: number;
  107182. frontUVs?: Vector4;
  107183. backUVs?: Vector4;
  107184. cap?: number;
  107185. invertUV?: boolean;
  107186. }, scene: Scene): Mesh;
  107187. }
  107188. }
  107189. declare module BABYLON {
  107190. /**
  107191. * Class containing static functions to help procedurally build meshes
  107192. */
  107193. export class TubeBuilder {
  107194. /**
  107195. * Creates a tube mesh.
  107196. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  107197. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  107198. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  107199. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  107200. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  107201. * * 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)
  107202. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  107203. * * 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
  107204. * * 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
  107205. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  107206. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  107207. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  107208. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  107209. * @param name defines the name of the mesh
  107210. * @param options defines the options used to create the mesh
  107211. * @param scene defines the hosting scene
  107212. * @returns the tube mesh
  107213. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  107214. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  107215. */
  107216. static CreateTube(name: string, options: {
  107217. path: Vector3[];
  107218. radius?: number;
  107219. tessellation?: number;
  107220. radiusFunction?: {
  107221. (i: number, distance: number): number;
  107222. };
  107223. cap?: number;
  107224. arc?: number;
  107225. updatable?: boolean;
  107226. sideOrientation?: number;
  107227. frontUVs?: Vector4;
  107228. backUVs?: Vector4;
  107229. instance?: Mesh;
  107230. invertUV?: boolean;
  107231. }, scene: Scene): Mesh;
  107232. }
  107233. }
  107234. declare module BABYLON {
  107235. /**
  107236. * Class containing static functions to help procedurally build meshes
  107237. */
  107238. export class IcoSphereBuilder {
  107239. /**
  107240. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  107241. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  107242. * * 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`)
  107243. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  107244. * * 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
  107245. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  107246. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  107247. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  107248. * @param name defines the name of the mesh
  107249. * @param options defines the options used to create the mesh
  107250. * @param scene defines the hosting scene
  107251. * @returns the icosahedron mesh
  107252. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  107253. */
  107254. static CreateIcoSphere(name: string, options: {
  107255. radius?: number;
  107256. radiusX?: number;
  107257. radiusY?: number;
  107258. radiusZ?: number;
  107259. flat?: boolean;
  107260. subdivisions?: number;
  107261. sideOrientation?: number;
  107262. frontUVs?: Vector4;
  107263. backUVs?: Vector4;
  107264. updatable?: boolean;
  107265. }, scene: Scene): Mesh;
  107266. }
  107267. }
  107268. declare module BABYLON {
  107269. /**
  107270. * Class containing static functions to help procedurally build meshes
  107271. */
  107272. export class DecalBuilder {
  107273. /**
  107274. * Creates a decal mesh.
  107275. * 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
  107276. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  107277. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  107278. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  107279. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  107280. * @param name defines the name of the mesh
  107281. * @param sourceMesh defines the mesh where the decal must be applied
  107282. * @param options defines the options used to create the mesh
  107283. * @param scene defines the hosting scene
  107284. * @returns the decal mesh
  107285. * @see https://doc.babylonjs.com/how_to/decals
  107286. */
  107287. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  107288. position?: Vector3;
  107289. normal?: Vector3;
  107290. size?: Vector3;
  107291. angle?: number;
  107292. }): Mesh;
  107293. }
  107294. }
  107295. declare module BABYLON {
  107296. /**
  107297. * Class containing static functions to help procedurally build meshes
  107298. */
  107299. export class MeshBuilder {
  107300. /**
  107301. * Creates a box mesh
  107302. * * The parameter `size` sets the size (float) of each box side (default 1)
  107303. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  107304. * * 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)
  107305. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  107306. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  107307. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  107308. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  107309. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  107310. * @param name defines the name of the mesh
  107311. * @param options defines the options used to create the mesh
  107312. * @param scene defines the hosting scene
  107313. * @returns the box mesh
  107314. */
  107315. static CreateBox(name: string, options: {
  107316. size?: number;
  107317. width?: number;
  107318. height?: number;
  107319. depth?: number;
  107320. faceUV?: Vector4[];
  107321. faceColors?: Color4[];
  107322. sideOrientation?: number;
  107323. frontUVs?: Vector4;
  107324. backUVs?: Vector4;
  107325. updatable?: boolean;
  107326. }, scene?: Nullable<Scene>): Mesh;
  107327. /**
  107328. * Creates a sphere mesh
  107329. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  107330. * * 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`)
  107331. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  107332. * * 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
  107333. * * 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)
  107334. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  107335. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  107336. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  107337. * @param name defines the name of the mesh
  107338. * @param options defines the options used to create the mesh
  107339. * @param scene defines the hosting scene
  107340. * @returns the sphere mesh
  107341. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  107342. */
  107343. static CreateSphere(name: string, options: {
  107344. segments?: number;
  107345. diameter?: number;
  107346. diameterX?: number;
  107347. diameterY?: number;
  107348. diameterZ?: number;
  107349. arc?: number;
  107350. slice?: number;
  107351. sideOrientation?: number;
  107352. frontUVs?: Vector4;
  107353. backUVs?: Vector4;
  107354. updatable?: boolean;
  107355. }, scene: any): Mesh;
  107356. /**
  107357. * Creates a plane polygonal mesh. By default, this is a disc
  107358. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  107359. * * 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
  107360. * * 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
  107361. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  107362. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  107363. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  107364. * @param name defines the name of the mesh
  107365. * @param options defines the options used to create the mesh
  107366. * @param scene defines the hosting scene
  107367. * @returns the plane polygonal mesh
  107368. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  107369. */
  107370. static CreateDisc(name: string, options: {
  107371. radius?: number;
  107372. tessellation?: number;
  107373. arc?: number;
  107374. updatable?: boolean;
  107375. sideOrientation?: number;
  107376. frontUVs?: Vector4;
  107377. backUVs?: Vector4;
  107378. }, scene?: Nullable<Scene>): Mesh;
  107379. /**
  107380. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  107381. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  107382. * * 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`)
  107383. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  107384. * * 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
  107385. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  107386. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  107387. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  107388. * @param name defines the name of the mesh
  107389. * @param options defines the options used to create the mesh
  107390. * @param scene defines the hosting scene
  107391. * @returns the icosahedron mesh
  107392. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  107393. */
  107394. static CreateIcoSphere(name: string, options: {
  107395. radius?: number;
  107396. radiusX?: number;
  107397. radiusY?: number;
  107398. radiusZ?: number;
  107399. flat?: boolean;
  107400. subdivisions?: number;
  107401. sideOrientation?: number;
  107402. frontUVs?: Vector4;
  107403. backUVs?: Vector4;
  107404. updatable?: boolean;
  107405. }, scene: Scene): Mesh;
  107406. /**
  107407. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  107408. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  107409. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  107410. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  107411. * * 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
  107412. * * 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
  107413. * * 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
  107414. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  107415. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  107416. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  107417. * * 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
  107418. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  107419. * * 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
  107420. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  107421. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  107422. * @param name defines the name of the mesh
  107423. * @param options defines the options used to create the mesh
  107424. * @param scene defines the hosting scene
  107425. * @returns the ribbon mesh
  107426. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  107427. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  107428. */
  107429. static CreateRibbon(name: string, options: {
  107430. pathArray: Vector3[][];
  107431. closeArray?: boolean;
  107432. closePath?: boolean;
  107433. offset?: number;
  107434. updatable?: boolean;
  107435. sideOrientation?: number;
  107436. frontUVs?: Vector4;
  107437. backUVs?: Vector4;
  107438. instance?: Mesh;
  107439. invertUV?: boolean;
  107440. uvs?: Vector2[];
  107441. colors?: Color4[];
  107442. }, scene?: Nullable<Scene>): Mesh;
  107443. /**
  107444. * Creates a cylinder or a cone mesh
  107445. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  107446. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  107447. * * 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.
  107448. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  107449. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  107450. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  107451. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  107452. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  107453. * * 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).
  107454. * * 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
  107455. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  107456. * * 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
  107457. * * 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.
  107458. * * If `enclose` is false, a ring surface is one element.
  107459. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  107460. * * 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
  107461. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  107462. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  107463. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  107464. * @param name defines the name of the mesh
  107465. * @param options defines the options used to create the mesh
  107466. * @param scene defines the hosting scene
  107467. * @returns the cylinder mesh
  107468. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  107469. */
  107470. static CreateCylinder(name: string, options: {
  107471. height?: number;
  107472. diameterTop?: number;
  107473. diameterBottom?: number;
  107474. diameter?: number;
  107475. tessellation?: number;
  107476. subdivisions?: number;
  107477. arc?: number;
  107478. faceColors?: Color4[];
  107479. faceUV?: Vector4[];
  107480. updatable?: boolean;
  107481. hasRings?: boolean;
  107482. enclose?: boolean;
  107483. sideOrientation?: number;
  107484. frontUVs?: Vector4;
  107485. backUVs?: Vector4;
  107486. }, scene: any): Mesh;
  107487. /**
  107488. * Creates a torus mesh
  107489. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  107490. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  107491. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  107492. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  107493. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  107494. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  107495. * @param name defines the name of the mesh
  107496. * @param options defines the options used to create the mesh
  107497. * @param scene defines the hosting scene
  107498. * @returns the torus mesh
  107499. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  107500. */
  107501. static CreateTorus(name: string, options: {
  107502. diameter?: number;
  107503. thickness?: number;
  107504. tessellation?: number;
  107505. updatable?: boolean;
  107506. sideOrientation?: number;
  107507. frontUVs?: Vector4;
  107508. backUVs?: Vector4;
  107509. }, scene: any): Mesh;
  107510. /**
  107511. * Creates a torus knot mesh
  107512. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  107513. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  107514. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  107515. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  107516. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  107517. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  107518. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  107519. * @param name defines the name of the mesh
  107520. * @param options defines the options used to create the mesh
  107521. * @param scene defines the hosting scene
  107522. * @returns the torus knot mesh
  107523. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  107524. */
  107525. static CreateTorusKnot(name: string, options: {
  107526. radius?: number;
  107527. tube?: number;
  107528. radialSegments?: number;
  107529. tubularSegments?: number;
  107530. p?: number;
  107531. q?: number;
  107532. updatable?: boolean;
  107533. sideOrientation?: number;
  107534. frontUVs?: Vector4;
  107535. backUVs?: Vector4;
  107536. }, scene: any): Mesh;
  107537. /**
  107538. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  107539. * * 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
  107540. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  107541. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  107542. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  107543. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  107544. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  107545. * * 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
  107546. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  107547. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  107548. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  107549. * @param name defines the name of the new line system
  107550. * @param options defines the options used to create the line system
  107551. * @param scene defines the hosting scene
  107552. * @returns a new line system mesh
  107553. */
  107554. static CreateLineSystem(name: string, options: {
  107555. lines: Vector3[][];
  107556. updatable?: boolean;
  107557. instance?: Nullable<LinesMesh>;
  107558. colors?: Nullable<Color4[][]>;
  107559. useVertexAlpha?: boolean;
  107560. }, scene: Nullable<Scene>): LinesMesh;
  107561. /**
  107562. * Creates a line mesh
  107563. * 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
  107564. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  107565. * * The parameter `points` is an array successive Vector3
  107566. * * 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
  107567. * * The optional parameter `colors` is an array of successive Color4, one per line point
  107568. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  107569. * * When updating an instance, remember that only point positions can change, not the number of points
  107570. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  107571. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  107572. * @param name defines the name of the new line system
  107573. * @param options defines the options used to create the line system
  107574. * @param scene defines the hosting scene
  107575. * @returns a new line mesh
  107576. */
  107577. static CreateLines(name: string, options: {
  107578. points: Vector3[];
  107579. updatable?: boolean;
  107580. instance?: Nullable<LinesMesh>;
  107581. colors?: Color4[];
  107582. useVertexAlpha?: boolean;
  107583. }, scene?: Nullable<Scene>): LinesMesh;
  107584. /**
  107585. * Creates a dashed line mesh
  107586. * * 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
  107587. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  107588. * * The parameter `points` is an array successive Vector3
  107589. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  107590. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  107591. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  107592. * * 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
  107593. * * When updating an instance, remember that only point positions can change, not the number of points
  107594. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  107595. * @param name defines the name of the mesh
  107596. * @param options defines the options used to create the mesh
  107597. * @param scene defines the hosting scene
  107598. * @returns the dashed line mesh
  107599. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  107600. */
  107601. static CreateDashedLines(name: string, options: {
  107602. points: Vector3[];
  107603. dashSize?: number;
  107604. gapSize?: number;
  107605. dashNb?: number;
  107606. updatable?: boolean;
  107607. instance?: LinesMesh;
  107608. }, scene?: Nullable<Scene>): LinesMesh;
  107609. /**
  107610. * 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.
  107611. * * 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.
  107612. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  107613. * * 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.
  107614. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  107615. * * 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
  107616. * * 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
  107617. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  107618. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  107619. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  107620. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  107621. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  107622. * @param name defines the name of the mesh
  107623. * @param options defines the options used to create the mesh
  107624. * @param scene defines the hosting scene
  107625. * @returns the extruded shape mesh
  107626. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  107627. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  107628. */
  107629. static ExtrudeShape(name: string, options: {
  107630. shape: Vector3[];
  107631. path: Vector3[];
  107632. scale?: number;
  107633. rotation?: number;
  107634. cap?: number;
  107635. updatable?: boolean;
  107636. sideOrientation?: number;
  107637. frontUVs?: Vector4;
  107638. backUVs?: Vector4;
  107639. instance?: Mesh;
  107640. invertUV?: boolean;
  107641. }, scene?: Nullable<Scene>): Mesh;
  107642. /**
  107643. * Creates an custom extruded shape mesh.
  107644. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  107645. * * 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.
  107646. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  107647. * * 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
  107648. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  107649. * * 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
  107650. * * It must returns a float value that will be the scale value applied to the shape on each path point
  107651. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  107652. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  107653. * * 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
  107654. * * 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
  107655. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  107656. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  107657. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  107658. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  107659. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  107660. * @param name defines the name of the mesh
  107661. * @param options defines the options used to create the mesh
  107662. * @param scene defines the hosting scene
  107663. * @returns the custom extruded shape mesh
  107664. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  107665. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  107666. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  107667. */
  107668. static ExtrudeShapeCustom(name: string, options: {
  107669. shape: Vector3[];
  107670. path: Vector3[];
  107671. scaleFunction?: any;
  107672. rotationFunction?: any;
  107673. ribbonCloseArray?: boolean;
  107674. ribbonClosePath?: boolean;
  107675. cap?: number;
  107676. updatable?: boolean;
  107677. sideOrientation?: number;
  107678. frontUVs?: Vector4;
  107679. backUVs?: Vector4;
  107680. instance?: Mesh;
  107681. invertUV?: boolean;
  107682. }, scene: Scene): Mesh;
  107683. /**
  107684. * Creates lathe mesh.
  107685. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  107686. * * 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
  107687. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  107688. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  107689. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  107690. * * 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
  107691. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  107692. * * 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
  107693. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  107694. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  107695. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  107696. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  107697. * @param name defines the name of the mesh
  107698. * @param options defines the options used to create the mesh
  107699. * @param scene defines the hosting scene
  107700. * @returns the lathe mesh
  107701. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  107702. */
  107703. static CreateLathe(name: string, options: {
  107704. shape: Vector3[];
  107705. radius?: number;
  107706. tessellation?: number;
  107707. clip?: number;
  107708. arc?: number;
  107709. closed?: boolean;
  107710. updatable?: boolean;
  107711. sideOrientation?: number;
  107712. frontUVs?: Vector4;
  107713. backUVs?: Vector4;
  107714. cap?: number;
  107715. invertUV?: boolean;
  107716. }, scene: Scene): Mesh;
  107717. /**
  107718. * Creates a plane mesh
  107719. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  107720. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  107721. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  107722. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  107723. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  107724. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  107725. * @param name defines the name of the mesh
  107726. * @param options defines the options used to create the mesh
  107727. * @param scene defines the hosting scene
  107728. * @returns the plane mesh
  107729. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  107730. */
  107731. static CreatePlane(name: string, options: {
  107732. size?: number;
  107733. width?: number;
  107734. height?: number;
  107735. sideOrientation?: number;
  107736. frontUVs?: Vector4;
  107737. backUVs?: Vector4;
  107738. updatable?: boolean;
  107739. sourcePlane?: Plane;
  107740. }, scene: Scene): Mesh;
  107741. /**
  107742. * Creates a ground mesh
  107743. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  107744. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  107745. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  107746. * @param name defines the name of the mesh
  107747. * @param options defines the options used to create the mesh
  107748. * @param scene defines the hosting scene
  107749. * @returns the ground mesh
  107750. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  107751. */
  107752. static CreateGround(name: string, options: {
  107753. width?: number;
  107754. height?: number;
  107755. subdivisions?: number;
  107756. subdivisionsX?: number;
  107757. subdivisionsY?: number;
  107758. updatable?: boolean;
  107759. }, scene: any): Mesh;
  107760. /**
  107761. * Creates a tiled ground mesh
  107762. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  107763. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  107764. * * 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
  107765. * * 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
  107766. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  107767. * @param name defines the name of the mesh
  107768. * @param options defines the options used to create the mesh
  107769. * @param scene defines the hosting scene
  107770. * @returns the tiled ground mesh
  107771. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  107772. */
  107773. static CreateTiledGround(name: string, options: {
  107774. xmin: number;
  107775. zmin: number;
  107776. xmax: number;
  107777. zmax: number;
  107778. subdivisions?: {
  107779. w: number;
  107780. h: number;
  107781. };
  107782. precision?: {
  107783. w: number;
  107784. h: number;
  107785. };
  107786. updatable?: boolean;
  107787. }, scene: Scene): Mesh;
  107788. /**
  107789. * Creates a ground mesh from a height map
  107790. * * The parameter `url` sets the URL of the height map image resource.
  107791. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  107792. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  107793. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  107794. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  107795. * * 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.
  107796. * * 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).
  107797. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  107798. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  107799. * @param name defines the name of the mesh
  107800. * @param url defines the url to the height map
  107801. * @param options defines the options used to create the mesh
  107802. * @param scene defines the hosting scene
  107803. * @returns the ground mesh
  107804. * @see https://doc.babylonjs.com/babylon101/height_map
  107805. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  107806. */
  107807. static CreateGroundFromHeightMap(name: string, url: string, options: {
  107808. width?: number;
  107809. height?: number;
  107810. subdivisions?: number;
  107811. minHeight?: number;
  107812. maxHeight?: number;
  107813. colorFilter?: Color3;
  107814. alphaFilter?: number;
  107815. updatable?: boolean;
  107816. onReady?: (mesh: GroundMesh) => void;
  107817. }, scene: Scene): GroundMesh;
  107818. /**
  107819. * Creates a polygon mesh
  107820. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  107821. * * 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
  107822. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  107823. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  107824. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4)
  107825. * * Remember you can only change the shape positions, not their number when updating a polygon
  107826. * @param name defines the name of the mesh
  107827. * @param options defines the options used to create the mesh
  107828. * @param scene defines the hosting scene
  107829. * @param earcutInjection can be used to inject your own earcut reference
  107830. * @returns the polygon mesh
  107831. */
  107832. static CreatePolygon(name: string, options: {
  107833. shape: Vector3[];
  107834. holes?: Vector3[][];
  107835. depth?: number;
  107836. faceUV?: Vector4[];
  107837. faceColors?: Color4[];
  107838. updatable?: boolean;
  107839. sideOrientation?: number;
  107840. frontUVs?: Vector4;
  107841. backUVs?: Vector4;
  107842. }, scene: Scene, earcutInjection?: any): Mesh;
  107843. /**
  107844. * Creates an extruded polygon mesh, with depth in the Y direction.
  107845. * * 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)
  107846. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  107847. * @param name defines the name of the mesh
  107848. * @param options defines the options used to create the mesh
  107849. * @param scene defines the hosting scene
  107850. * @param earcutInjection can be used to inject your own earcut reference
  107851. * @returns the polygon mesh
  107852. */
  107853. static ExtrudePolygon(name: string, options: {
  107854. shape: Vector3[];
  107855. holes?: Vector3[][];
  107856. depth?: number;
  107857. faceUV?: Vector4[];
  107858. faceColors?: Color4[];
  107859. updatable?: boolean;
  107860. sideOrientation?: number;
  107861. frontUVs?: Vector4;
  107862. backUVs?: Vector4;
  107863. }, scene: Scene, earcutInjection?: any): Mesh;
  107864. /**
  107865. * Creates a tube mesh.
  107866. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  107867. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  107868. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  107869. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  107870. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  107871. * * 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)
  107872. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  107873. * * 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
  107874. * * 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
  107875. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  107876. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  107877. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  107878. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  107879. * @param name defines the name of the mesh
  107880. * @param options defines the options used to create the mesh
  107881. * @param scene defines the hosting scene
  107882. * @returns the tube mesh
  107883. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  107884. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  107885. */
  107886. static CreateTube(name: string, options: {
  107887. path: Vector3[];
  107888. radius?: number;
  107889. tessellation?: number;
  107890. radiusFunction?: {
  107891. (i: number, distance: number): number;
  107892. };
  107893. cap?: number;
  107894. arc?: number;
  107895. updatable?: boolean;
  107896. sideOrientation?: number;
  107897. frontUVs?: Vector4;
  107898. backUVs?: Vector4;
  107899. instance?: Mesh;
  107900. invertUV?: boolean;
  107901. }, scene: Scene): Mesh;
  107902. /**
  107903. * Creates a polyhedron mesh
  107904. * * 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
  107905. * * The parameter `size` (positive float, default 1) sets the polygon size
  107906. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  107907. * * 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`
  107908. * * 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
  107909. * * 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)`)
  107910. * * 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
  107911. * * 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
  107912. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  107913. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  107914. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  107915. * @param name defines the name of the mesh
  107916. * @param options defines the options used to create the mesh
  107917. * @param scene defines the hosting scene
  107918. * @returns the polyhedron mesh
  107919. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  107920. */
  107921. static CreatePolyhedron(name: string, options: {
  107922. type?: number;
  107923. size?: number;
  107924. sizeX?: number;
  107925. sizeY?: number;
  107926. sizeZ?: number;
  107927. custom?: any;
  107928. faceUV?: Vector4[];
  107929. faceColors?: Color4[];
  107930. flat?: boolean;
  107931. updatable?: boolean;
  107932. sideOrientation?: number;
  107933. frontUVs?: Vector4;
  107934. backUVs?: Vector4;
  107935. }, scene: Scene): Mesh;
  107936. /**
  107937. * Creates a decal mesh.
  107938. * 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
  107939. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  107940. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  107941. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  107942. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  107943. * @param name defines the name of the mesh
  107944. * @param sourceMesh defines the mesh where the decal must be applied
  107945. * @param options defines the options used to create the mesh
  107946. * @param scene defines the hosting scene
  107947. * @returns the decal mesh
  107948. * @see https://doc.babylonjs.com/how_to/decals
  107949. */
  107950. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  107951. position?: Vector3;
  107952. normal?: Vector3;
  107953. size?: Vector3;
  107954. angle?: number;
  107955. }): Mesh;
  107956. }
  107957. }
  107958. declare module BABYLON {
  107959. /**
  107960. * A simplifier interface for future simplification implementations
  107961. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  107962. */
  107963. export interface ISimplifier {
  107964. /**
  107965. * Simplification of a given mesh according to the given settings.
  107966. * Since this requires computation, it is assumed that the function runs async.
  107967. * @param settings The settings of the simplification, including quality and distance
  107968. * @param successCallback A callback that will be called after the mesh was simplified.
  107969. * @param errorCallback in case of an error, this callback will be called. optional.
  107970. */
  107971. simplify(settings: ISimplificationSettings, successCallback: (simplifiedMeshes: Mesh) => void, errorCallback?: () => void): void;
  107972. }
  107973. /**
  107974. * Expected simplification settings.
  107975. * Quality should be between 0 and 1 (1 being 100%, 0 being 0%)
  107976. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  107977. */
  107978. export interface ISimplificationSettings {
  107979. /**
  107980. * Gets or sets the expected quality
  107981. */
  107982. quality: number;
  107983. /**
  107984. * Gets or sets the distance when this optimized version should be used
  107985. */
  107986. distance: number;
  107987. /**
  107988. * Gets an already optimized mesh
  107989. */
  107990. optimizeMesh?: boolean;
  107991. }
  107992. /**
  107993. * Class used to specify simplification options
  107994. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  107995. */
  107996. export class SimplificationSettings implements ISimplificationSettings {
  107997. /** expected quality */
  107998. quality: number;
  107999. /** distance when this optimized version should be used */
  108000. distance: number;
  108001. /** already optimized mesh */
  108002. optimizeMesh?: boolean | undefined;
  108003. /**
  108004. * Creates a SimplificationSettings
  108005. * @param quality expected quality
  108006. * @param distance distance when this optimized version should be used
  108007. * @param optimizeMesh already optimized mesh
  108008. */
  108009. constructor(
  108010. /** expected quality */
  108011. quality: number,
  108012. /** distance when this optimized version should be used */
  108013. distance: number,
  108014. /** already optimized mesh */
  108015. optimizeMesh?: boolean | undefined);
  108016. }
  108017. /**
  108018. * Interface used to define a simplification task
  108019. */
  108020. export interface ISimplificationTask {
  108021. /**
  108022. * Array of settings
  108023. */
  108024. settings: Array<ISimplificationSettings>;
  108025. /**
  108026. * Simplification type
  108027. */
  108028. simplificationType: SimplificationType;
  108029. /**
  108030. * Mesh to simplify
  108031. */
  108032. mesh: Mesh;
  108033. /**
  108034. * Callback called on success
  108035. */
  108036. successCallback?: () => void;
  108037. /**
  108038. * Defines if parallel processing can be used
  108039. */
  108040. parallelProcessing: boolean;
  108041. }
  108042. /**
  108043. * Queue used to order the simplification tasks
  108044. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  108045. */
  108046. export class SimplificationQueue {
  108047. private _simplificationArray;
  108048. /**
  108049. * Gets a boolean indicating that the process is still running
  108050. */
  108051. running: boolean;
  108052. /**
  108053. * Creates a new queue
  108054. */
  108055. constructor();
  108056. /**
  108057. * Adds a new simplification task
  108058. * @param task defines a task to add
  108059. */
  108060. addTask(task: ISimplificationTask): void;
  108061. /**
  108062. * Execute next task
  108063. */
  108064. executeNext(): void;
  108065. /**
  108066. * Execute a simplification task
  108067. * @param task defines the task to run
  108068. */
  108069. runSimplification(task: ISimplificationTask): void;
  108070. private getSimplifier;
  108071. }
  108072. /**
  108073. * The implemented types of simplification
  108074. * At the moment only Quadratic Error Decimation is implemented
  108075. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  108076. */
  108077. export enum SimplificationType {
  108078. /** Quadratic error decimation */
  108079. QUADRATIC = 0
  108080. }
  108081. }
  108082. declare module BABYLON {
  108083. interface Scene {
  108084. /** @hidden (Backing field) */
  108085. _simplificationQueue: SimplificationQueue;
  108086. /**
  108087. * Gets or sets the simplification queue attached to the scene
  108088. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  108089. */
  108090. simplificationQueue: SimplificationQueue;
  108091. }
  108092. interface Mesh {
  108093. /**
  108094. * Simplify the mesh according to the given array of settings.
  108095. * Function will return immediately and will simplify async
  108096. * @param settings a collection of simplification settings
  108097. * @param parallelProcessing should all levels calculate parallel or one after the other
  108098. * @param simplificationType the type of simplification to run
  108099. * @param successCallback optional success callback to be called after the simplification finished processing all settings
  108100. * @returns the current mesh
  108101. */
  108102. simplify(settings: Array<ISimplificationSettings>, parallelProcessing?: boolean, simplificationType?: SimplificationType, successCallback?: (mesh?: Mesh, submeshIndex?: number) => void): Mesh;
  108103. }
  108104. /**
  108105. * Defines the simplification queue scene component responsible to help scheduling the various simplification task
  108106. * created in a scene
  108107. */
  108108. export class SimplicationQueueSceneComponent implements ISceneComponent {
  108109. /**
  108110. * The component name helpfull to identify the component in the list of scene components.
  108111. */
  108112. readonly name: string;
  108113. /**
  108114. * The scene the component belongs to.
  108115. */
  108116. scene: Scene;
  108117. /**
  108118. * Creates a new instance of the component for the given scene
  108119. * @param scene Defines the scene to register the component in
  108120. */
  108121. constructor(scene: Scene);
  108122. /**
  108123. * Registers the component in a given scene
  108124. */
  108125. register(): void;
  108126. /**
  108127. * Rebuilds the elements related to this component in case of
  108128. * context lost for instance.
  108129. */
  108130. rebuild(): void;
  108131. /**
  108132. * Disposes the component and the associated ressources
  108133. */
  108134. dispose(): void;
  108135. private _beforeCameraUpdate;
  108136. }
  108137. }
  108138. declare module BABYLON {
  108139. /**
  108140. * Class used to enable access to IndexedDB
  108141. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  108142. */
  108143. export class Database implements IOfflineProvider {
  108144. private _callbackManifestChecked;
  108145. private _currentSceneUrl;
  108146. private _db;
  108147. private _enableSceneOffline;
  108148. private _enableTexturesOffline;
  108149. private _manifestVersionFound;
  108150. private _mustUpdateRessources;
  108151. private _hasReachedQuota;
  108152. private _isSupported;
  108153. private _idbFactory;
  108154. /** Gets a boolean indicating if the user agent supports blob storage (this value will be updated after creating the first Database object) */
  108155. private static IsUASupportingBlobStorage;
  108156. /**
  108157. * Gets a boolean indicating if Database storate is enabled (off by default)
  108158. */
  108159. static IDBStorageEnabled: boolean;
  108160. /**
  108161. * Gets a boolean indicating if scene must be saved in the database
  108162. */
  108163. readonly enableSceneOffline: boolean;
  108164. /**
  108165. * Gets a boolean indicating if textures must be saved in the database
  108166. */
  108167. readonly enableTexturesOffline: boolean;
  108168. /**
  108169. * Creates a new Database
  108170. * @param urlToScene defines the url to load the scene
  108171. * @param callbackManifestChecked defines the callback to use when manifest is checked
  108172. * @param disableManifestCheck defines a boolean indicating that we want to skip the manifest validation (it will be considered validated and up to date)
  108173. */
  108174. constructor(urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck?: boolean);
  108175. private static _ParseURL;
  108176. private static _ReturnFullUrlLocation;
  108177. private _checkManifestFile;
  108178. /**
  108179. * Open the database and make it available
  108180. * @param successCallback defines the callback to call on success
  108181. * @param errorCallback defines the callback to call on error
  108182. */
  108183. open(successCallback: () => void, errorCallback: () => void): void;
  108184. /**
  108185. * Loads an image from the database
  108186. * @param url defines the url to load from
  108187. * @param image defines the target DOM image
  108188. */
  108189. loadImage(url: string, image: HTMLImageElement): void;
  108190. private _loadImageFromDBAsync;
  108191. private _saveImageIntoDBAsync;
  108192. private _checkVersionFromDB;
  108193. private _loadVersionFromDBAsync;
  108194. private _saveVersionIntoDBAsync;
  108195. /**
  108196. * Loads a file from database
  108197. * @param url defines the URL to load from
  108198. * @param sceneLoaded defines a callback to call on success
  108199. * @param progressCallBack defines a callback to call when progress changed
  108200. * @param errorCallback defines a callback to call on error
  108201. * @param useArrayBuffer defines a boolean to use array buffer instead of text string
  108202. */
  108203. loadFile(url: string, sceneLoaded: (data: any) => void, progressCallBack?: (data: any) => void, errorCallback?: () => void, useArrayBuffer?: boolean): void;
  108204. private _loadFileAsync;
  108205. private _saveFileAsync;
  108206. /**
  108207. * Validates if xhr data is correct
  108208. * @param xhr defines the request to validate
  108209. * @param dataType defines the expected data type
  108210. * @returns true if data is correct
  108211. */
  108212. private static _ValidateXHRData;
  108213. }
  108214. }
  108215. declare module BABYLON {
  108216. /** @hidden */
  108217. export var gpuUpdateParticlesPixelShader: {
  108218. name: string;
  108219. shader: string;
  108220. };
  108221. }
  108222. declare module BABYLON {
  108223. /** @hidden */
  108224. export var gpuUpdateParticlesVertexShader: {
  108225. name: string;
  108226. shader: string;
  108227. };
  108228. }
  108229. declare module BABYLON {
  108230. /** @hidden */
  108231. export var clipPlaneFragmentDeclaration2: {
  108232. name: string;
  108233. shader: string;
  108234. };
  108235. }
  108236. declare module BABYLON {
  108237. /** @hidden */
  108238. export var gpuRenderParticlesPixelShader: {
  108239. name: string;
  108240. shader: string;
  108241. };
  108242. }
  108243. declare module BABYLON {
  108244. /** @hidden */
  108245. export var clipPlaneVertexDeclaration2: {
  108246. name: string;
  108247. shader: string;
  108248. };
  108249. }
  108250. declare module BABYLON {
  108251. /** @hidden */
  108252. export var gpuRenderParticlesVertexShader: {
  108253. name: string;
  108254. shader: string;
  108255. };
  108256. }
  108257. declare module BABYLON {
  108258. /**
  108259. * This represents a GPU particle system in Babylon
  108260. * This is the fastest particle system in Babylon as it uses the GPU to update the individual particle data
  108261. * @see https://www.babylonjs-playground.com/#PU4WYI#4
  108262. */
  108263. export class GPUParticleSystem extends BaseParticleSystem implements IDisposable, IParticleSystem, IAnimatable {
  108264. /**
  108265. * The layer mask we are rendering the particles through.
  108266. */
  108267. layerMask: number;
  108268. private _capacity;
  108269. private _activeCount;
  108270. private _currentActiveCount;
  108271. private _accumulatedCount;
  108272. private _renderEffect;
  108273. private _updateEffect;
  108274. private _buffer0;
  108275. private _buffer1;
  108276. private _spriteBuffer;
  108277. private _updateVAO;
  108278. private _renderVAO;
  108279. private _targetIndex;
  108280. private _sourceBuffer;
  108281. private _targetBuffer;
  108282. private _engine;
  108283. private _currentRenderId;
  108284. private _started;
  108285. private _stopped;
  108286. private _timeDelta;
  108287. private _randomTexture;
  108288. private _randomTexture2;
  108289. private _attributesStrideSize;
  108290. private _updateEffectOptions;
  108291. private _randomTextureSize;
  108292. private _actualFrame;
  108293. private readonly _rawTextureWidth;
  108294. /**
  108295. * Gets a boolean indicating if the GPU particles can be rendered on current browser
  108296. */
  108297. static readonly IsSupported: boolean;
  108298. /**
  108299. * An event triggered when the system is disposed.
  108300. */
  108301. onDisposeObservable: Observable<GPUParticleSystem>;
  108302. /**
  108303. * Gets the maximum number of particles active at the same time.
  108304. * @returns The max number of active particles.
  108305. */
  108306. getCapacity(): number;
  108307. /**
  108308. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  108309. * to override the particles.
  108310. */
  108311. forceDepthWrite: boolean;
  108312. /**
  108313. * Gets or set the number of active particles
  108314. */
  108315. activeParticleCount: number;
  108316. private _preWarmDone;
  108317. /**
  108318. * Is this system ready to be used/rendered
  108319. * @return true if the system is ready
  108320. */
  108321. isReady(): boolean;
  108322. /**
  108323. * Gets if the system has been started. (Note: this will still be true after stop is called)
  108324. * @returns True if it has been started, otherwise false.
  108325. */
  108326. isStarted(): boolean;
  108327. /**
  108328. * Starts the particle system and begins to emit
  108329. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  108330. */
  108331. start(delay?: number): void;
  108332. /**
  108333. * Stops the particle system.
  108334. */
  108335. stop(): void;
  108336. /**
  108337. * Remove all active particles
  108338. */
  108339. reset(): void;
  108340. /**
  108341. * Returns the string "GPUParticleSystem"
  108342. * @returns a string containing the class name
  108343. */
  108344. getClassName(): string;
  108345. private _colorGradientsTexture;
  108346. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: RawTexture): BaseParticleSystem;
  108347. /**
  108348. * Adds a new color gradient
  108349. * @param gradient defines the gradient to use (between 0 and 1)
  108350. * @param color1 defines the color to affect to the specified gradient
  108351. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  108352. * @returns the current particle system
  108353. */
  108354. addColorGradient(gradient: number, color1: Color4, color2?: Color4): GPUParticleSystem;
  108355. /**
  108356. * Remove a specific color gradient
  108357. * @param gradient defines the gradient to remove
  108358. * @returns the current particle system
  108359. */
  108360. removeColorGradient(gradient: number): GPUParticleSystem;
  108361. private _angularSpeedGradientsTexture;
  108362. private _sizeGradientsTexture;
  108363. private _velocityGradientsTexture;
  108364. private _limitVelocityGradientsTexture;
  108365. private _dragGradientsTexture;
  108366. private _addFactorGradient;
  108367. /**
  108368. * Adds a new size gradient
  108369. * @param gradient defines the gradient to use (between 0 and 1)
  108370. * @param factor defines the size factor to affect to the specified gradient
  108371. * @returns the current particle system
  108372. */
  108373. addSizeGradient(gradient: number, factor: number): GPUParticleSystem;
  108374. /**
  108375. * Remove a specific size gradient
  108376. * @param gradient defines the gradient to remove
  108377. * @returns the current particle system
  108378. */
  108379. removeSizeGradient(gradient: number): GPUParticleSystem;
  108380. /**
  108381. * Adds a new angular speed gradient
  108382. * @param gradient defines the gradient to use (between 0 and 1)
  108383. * @param factor defines the angular speed to affect to the specified gradient
  108384. * @returns the current particle system
  108385. */
  108386. addAngularSpeedGradient(gradient: number, factor: number): GPUParticleSystem;
  108387. /**
  108388. * Remove a specific angular speed gradient
  108389. * @param gradient defines the gradient to remove
  108390. * @returns the current particle system
  108391. */
  108392. removeAngularSpeedGradient(gradient: number): GPUParticleSystem;
  108393. /**
  108394. * Adds a new velocity gradient
  108395. * @param gradient defines the gradient to use (between 0 and 1)
  108396. * @param factor defines the velocity to affect to the specified gradient
  108397. * @returns the current particle system
  108398. */
  108399. addVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  108400. /**
  108401. * Remove a specific velocity gradient
  108402. * @param gradient defines the gradient to remove
  108403. * @returns the current particle system
  108404. */
  108405. removeVelocityGradient(gradient: number): GPUParticleSystem;
  108406. /**
  108407. * Adds a new limit velocity gradient
  108408. * @param gradient defines the gradient to use (between 0 and 1)
  108409. * @param factor defines the limit velocity value to affect to the specified gradient
  108410. * @returns the current particle system
  108411. */
  108412. addLimitVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  108413. /**
  108414. * Remove a specific limit velocity gradient
  108415. * @param gradient defines the gradient to remove
  108416. * @returns the current particle system
  108417. */
  108418. removeLimitVelocityGradient(gradient: number): GPUParticleSystem;
  108419. /**
  108420. * Adds a new drag gradient
  108421. * @param gradient defines the gradient to use (between 0 and 1)
  108422. * @param factor defines the drag value to affect to the specified gradient
  108423. * @returns the current particle system
  108424. */
  108425. addDragGradient(gradient: number, factor: number): GPUParticleSystem;
  108426. /**
  108427. * Remove a specific drag gradient
  108428. * @param gradient defines the gradient to remove
  108429. * @returns the current particle system
  108430. */
  108431. removeDragGradient(gradient: number): GPUParticleSystem;
  108432. /**
  108433. * Not supported by GPUParticleSystem
  108434. * @param gradient defines the gradient to use (between 0 and 1)
  108435. * @param factor defines the emit rate value to affect to the specified gradient
  108436. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  108437. * @returns the current particle system
  108438. */
  108439. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  108440. /**
  108441. * Not supported by GPUParticleSystem
  108442. * @param gradient defines the gradient to remove
  108443. * @returns the current particle system
  108444. */
  108445. removeEmitRateGradient(gradient: number): IParticleSystem;
  108446. /**
  108447. * Not supported by GPUParticleSystem
  108448. * @param gradient defines the gradient to use (between 0 and 1)
  108449. * @param factor defines the start size value to affect to the specified gradient
  108450. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  108451. * @returns the current particle system
  108452. */
  108453. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  108454. /**
  108455. * Not supported by GPUParticleSystem
  108456. * @param gradient defines the gradient to remove
  108457. * @returns the current particle system
  108458. */
  108459. removeStartSizeGradient(gradient: number): IParticleSystem;
  108460. /**
  108461. * Not supported by GPUParticleSystem
  108462. * @param gradient defines the gradient to use (between 0 and 1)
  108463. * @param min defines the color remap minimal range
  108464. * @param max defines the color remap maximal range
  108465. * @returns the current particle system
  108466. */
  108467. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  108468. /**
  108469. * Not supported by GPUParticleSystem
  108470. * @param gradient defines the gradient to remove
  108471. * @returns the current particle system
  108472. */
  108473. removeColorRemapGradient(): IParticleSystem;
  108474. /**
  108475. * Not supported by GPUParticleSystem
  108476. * @param gradient defines the gradient to use (between 0 and 1)
  108477. * @param min defines the alpha remap minimal range
  108478. * @param max defines the alpha remap maximal range
  108479. * @returns the current particle system
  108480. */
  108481. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  108482. /**
  108483. * Not supported by GPUParticleSystem
  108484. * @param gradient defines the gradient to remove
  108485. * @returns the current particle system
  108486. */
  108487. removeAlphaRemapGradient(): IParticleSystem;
  108488. /**
  108489. * Not supported by GPUParticleSystem
  108490. * @param gradient defines the gradient to use (between 0 and 1)
  108491. * @param color defines the color to affect to the specified gradient
  108492. * @returns the current particle system
  108493. */
  108494. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  108495. /**
  108496. * Not supported by GPUParticleSystem
  108497. * @param gradient defines the gradient to remove
  108498. * @returns the current particle system
  108499. */
  108500. removeRampGradient(): IParticleSystem;
  108501. /**
  108502. * Not supported by GPUParticleSystem
  108503. * @returns the list of ramp gradients
  108504. */
  108505. getRampGradients(): Nullable<Array<Color3Gradient>>;
  108506. /**
  108507. * Not supported by GPUParticleSystem
  108508. * Gets or sets a boolean indicating that ramp gradients must be used
  108509. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  108510. */
  108511. useRampGradients: boolean;
  108512. /**
  108513. * Not supported by GPUParticleSystem
  108514. * @param gradient defines the gradient to use (between 0 and 1)
  108515. * @param factor defines the life time factor to affect to the specified gradient
  108516. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  108517. * @returns the current particle system
  108518. */
  108519. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  108520. /**
  108521. * Not supported by GPUParticleSystem
  108522. * @param gradient defines the gradient to remove
  108523. * @returns the current particle system
  108524. */
  108525. removeLifeTimeGradient(gradient: number): IParticleSystem;
  108526. /**
  108527. * Instantiates a GPU particle system.
  108528. * 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.
  108529. * @param name The name of the particle system
  108530. * @param options The options used to create the system
  108531. * @param scene The scene the particle system belongs to
  108532. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  108533. */
  108534. constructor(name: string, options: Partial<{
  108535. capacity: number;
  108536. randomTextureSize: number;
  108537. }>, scene: Scene, isAnimationSheetEnabled?: boolean);
  108538. protected _reset(): void;
  108539. private _createUpdateVAO;
  108540. private _createRenderVAO;
  108541. private _initialize;
  108542. /** @hidden */
  108543. _recreateUpdateEffect(): void;
  108544. /** @hidden */
  108545. _recreateRenderEffect(): void;
  108546. /**
  108547. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  108548. * @param preWarm defines if we are in the pre-warmimg phase
  108549. */
  108550. animate(preWarm?: boolean): void;
  108551. private _createFactorGradientTexture;
  108552. private _createSizeGradientTexture;
  108553. private _createAngularSpeedGradientTexture;
  108554. private _createVelocityGradientTexture;
  108555. private _createLimitVelocityGradientTexture;
  108556. private _createDragGradientTexture;
  108557. private _createColorGradientTexture;
  108558. /**
  108559. * Renders the particle system in its current state
  108560. * @param preWarm defines if the system should only update the particles but not render them
  108561. * @returns the current number of particles
  108562. */
  108563. render(preWarm?: boolean): number;
  108564. /**
  108565. * Rebuilds the particle system
  108566. */
  108567. rebuild(): void;
  108568. private _releaseBuffers;
  108569. private _releaseVAOs;
  108570. /**
  108571. * Disposes the particle system and free the associated resources
  108572. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  108573. */
  108574. dispose(disposeTexture?: boolean): void;
  108575. /**
  108576. * Clones the particle system.
  108577. * @param name The name of the cloned object
  108578. * @param newEmitter The new emitter to use
  108579. * @returns the cloned particle system
  108580. */
  108581. clone(name: string, newEmitter: any): GPUParticleSystem;
  108582. /**
  108583. * Serializes the particle system to a JSON object.
  108584. * @returns the JSON object
  108585. */
  108586. serialize(): any;
  108587. /**
  108588. * Parses a JSON object to create a GPU particle system.
  108589. * @param parsedParticleSystem The JSON object to parse
  108590. * @param scene The scene to create the particle system in
  108591. * @param rootUrl The root url to use to load external dependencies like texture
  108592. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  108593. * @returns the parsed GPU particle system
  108594. */
  108595. static Parse(parsedParticleSystem: any, scene: Scene, rootUrl: string, doNotStart?: boolean): GPUParticleSystem;
  108596. }
  108597. }
  108598. declare module BABYLON {
  108599. /**
  108600. * Represents a set of particle systems working together to create a specific effect
  108601. */
  108602. export class ParticleSystemSet implements IDisposable {
  108603. private _emitterCreationOptions;
  108604. private _emitterNode;
  108605. /**
  108606. * Gets the particle system list
  108607. */
  108608. systems: IParticleSystem[];
  108609. /**
  108610. * Gets the emitter node used with this set
  108611. */
  108612. readonly emitterNode: Nullable<TransformNode>;
  108613. /**
  108614. * Creates a new emitter mesh as a sphere
  108615. * @param options defines the options used to create the sphere
  108616. * @param renderingGroupId defines the renderingGroupId to use for the sphere
  108617. * @param scene defines the hosting scene
  108618. */
  108619. setEmitterAsSphere(options: {
  108620. diameter: number;
  108621. segments: number;
  108622. color: Color3;
  108623. }, renderingGroupId: number, scene: Scene): void;
  108624. /**
  108625. * Starts all particle systems of the set
  108626. * @param emitter defines an optional mesh to use as emitter for the particle systems
  108627. */
  108628. start(emitter?: AbstractMesh): void;
  108629. /**
  108630. * Release all associated resources
  108631. */
  108632. dispose(): void;
  108633. /**
  108634. * Serialize the set into a JSON compatible object
  108635. * @returns a JSON compatible representation of the set
  108636. */
  108637. serialize(): any;
  108638. /**
  108639. * Parse a new ParticleSystemSet from a serialized source
  108640. * @param data defines a JSON compatible representation of the set
  108641. * @param scene defines the hosting scene
  108642. * @param gpu defines if we want GPU particles or CPU particles
  108643. * @returns a new ParticleSystemSet
  108644. */
  108645. static Parse(data: any, scene: Scene, gpu?: boolean): ParticleSystemSet;
  108646. }
  108647. }
  108648. declare module BABYLON {
  108649. /**
  108650. * This class is made for on one-liner static method to help creating particle system set.
  108651. */
  108652. export class ParticleHelper {
  108653. /**
  108654. * Gets or sets base Assets URL
  108655. */
  108656. static BaseAssetsUrl: string;
  108657. /**
  108658. * Create a default particle system that you can tweak
  108659. * @param emitter defines the emitter to use
  108660. * @param capacity defines the system capacity (default is 500 particles)
  108661. * @param scene defines the hosting scene
  108662. * @param useGPU defines if a GPUParticleSystem must be created (default is false)
  108663. * @returns the new Particle system
  108664. */
  108665. static CreateDefault(emitter: Nullable<AbstractMesh | Vector3>, capacity?: number, scene?: Scene, useGPU?: boolean): IParticleSystem;
  108666. /**
  108667. * This is the main static method (one-liner) of this helper to create different particle systems
  108668. * @param type This string represents the type to the particle system to create
  108669. * @param scene The scene where the particle system should live
  108670. * @param gpu If the system will use gpu
  108671. * @returns the ParticleSystemSet created
  108672. */
  108673. static CreateAsync(type: string, scene: Nullable<Scene>, gpu?: boolean): Promise<ParticleSystemSet>;
  108674. /**
  108675. * Static function used to export a particle system to a ParticleSystemSet variable.
  108676. * Please note that the emitter shape is not exported
  108677. * @param systems defines the particle systems to export
  108678. * @returns the created particle system set
  108679. */
  108680. static ExportSet(systems: IParticleSystem[]): ParticleSystemSet;
  108681. }
  108682. }
  108683. declare module BABYLON {
  108684. interface Engine {
  108685. /**
  108686. * Create an effect to use with particle systems.
  108687. * Please note that some parameters like animation sheets or not being billboard are not supported in this configuration
  108688. * @param fragmentName defines the base name of the effect (The name of file without .fragment.fx)
  108689. * @param uniformsNames defines a list of attribute names
  108690. * @param samplers defines an array of string used to represent textures
  108691. * @param defines defines the string containing the defines to use to compile the shaders
  108692. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  108693. * @param onCompiled defines a function to call when the effect creation is successful
  108694. * @param onError defines a function to call when the effect creation has failed
  108695. * @returns the new Effect
  108696. */
  108697. createEffectForParticles(fragmentName: string, uniformsNames: string[], samplers: string[], defines: string, fallbacks?: EffectFallbacks, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): Effect;
  108698. }
  108699. interface Mesh {
  108700. /**
  108701. * Returns an array populated with IParticleSystem objects whose the mesh is the emitter
  108702. * @returns an array of IParticleSystem
  108703. */
  108704. getEmittedParticleSystems(): IParticleSystem[];
  108705. /**
  108706. * Returns an array populated with IParticleSystem objects whose the mesh or its children are the emitter
  108707. * @returns an array of IParticleSystem
  108708. */
  108709. getHierarchyEmittedParticleSystems(): IParticleSystem[];
  108710. }
  108711. /**
  108712. * @hidden
  108713. */
  108714. export var _IDoNeedToBeInTheBuild: number;
  108715. }
  108716. declare module BABYLON {
  108717. interface Scene {
  108718. /** @hidden (Backing field) */
  108719. _physicsEngine: Nullable<IPhysicsEngine>;
  108720. /**
  108721. * Gets the current physics engine
  108722. * @returns a IPhysicsEngine or null if none attached
  108723. */
  108724. getPhysicsEngine(): Nullable<IPhysicsEngine>;
  108725. /**
  108726. * Enables physics to the current scene
  108727. * @param gravity defines the scene's gravity for the physics engine
  108728. * @param plugin defines the physics engine to be used. defaults to OimoJS.
  108729. * @return a boolean indicating if the physics engine was initialized
  108730. */
  108731. enablePhysics(gravity: Nullable<Vector3>, plugin?: IPhysicsEnginePlugin): boolean;
  108732. /**
  108733. * Disables and disposes the physics engine associated with the scene
  108734. */
  108735. disablePhysicsEngine(): void;
  108736. /**
  108737. * Gets a boolean indicating if there is an active physics engine
  108738. * @returns a boolean indicating if there is an active physics engine
  108739. */
  108740. isPhysicsEnabled(): boolean;
  108741. /**
  108742. * Deletes a physics compound impostor
  108743. * @param compound defines the compound to delete
  108744. */
  108745. deleteCompoundImpostor(compound: any): void;
  108746. /**
  108747. * An event triggered when physic simulation is about to be run
  108748. */
  108749. onBeforePhysicsObservable: Observable<Scene>;
  108750. /**
  108751. * An event triggered when physic simulation has been done
  108752. */
  108753. onAfterPhysicsObservable: Observable<Scene>;
  108754. }
  108755. interface AbstractMesh {
  108756. /** @hidden */
  108757. _physicsImpostor: Nullable<PhysicsImpostor>;
  108758. /**
  108759. * Gets or sets impostor used for physic simulation
  108760. * @see http://doc.babylonjs.com/features/physics_engine
  108761. */
  108762. physicsImpostor: Nullable<PhysicsImpostor>;
  108763. /**
  108764. * Gets the current physics impostor
  108765. * @see http://doc.babylonjs.com/features/physics_engine
  108766. * @returns a physics impostor or null
  108767. */
  108768. getPhysicsImpostor(): Nullable<PhysicsImpostor>;
  108769. /** Apply a physic impulse to the mesh
  108770. * @param force defines the force to apply
  108771. * @param contactPoint defines where to apply the force
  108772. * @returns the current mesh
  108773. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  108774. */
  108775. applyImpulse(force: Vector3, contactPoint: Vector3): AbstractMesh;
  108776. /**
  108777. * Creates a physic joint between two meshes
  108778. * @param otherMesh defines the other mesh to use
  108779. * @param pivot1 defines the pivot to use on this mesh
  108780. * @param pivot2 defines the pivot to use on the other mesh
  108781. * @param options defines additional options (can be plugin dependent)
  108782. * @returns the current mesh
  108783. * @see https://www.babylonjs-playground.com/#0BS5U0#0
  108784. */
  108785. setPhysicsLinkWith(otherMesh: Mesh, pivot1: Vector3, pivot2: Vector3, options?: any): AbstractMesh;
  108786. /** @hidden */
  108787. _disposePhysicsObserver: Nullable<Observer<Node>>;
  108788. }
  108789. /**
  108790. * Defines the physics engine scene component responsible to manage a physics engine
  108791. */
  108792. export class PhysicsEngineSceneComponent implements ISceneComponent {
  108793. /**
  108794. * The component name helpful to identify the component in the list of scene components.
  108795. */
  108796. readonly name: string;
  108797. /**
  108798. * The scene the component belongs to.
  108799. */
  108800. scene: Scene;
  108801. /**
  108802. * Creates a new instance of the component for the given scene
  108803. * @param scene Defines the scene to register the component in
  108804. */
  108805. constructor(scene: Scene);
  108806. /**
  108807. * Registers the component in a given scene
  108808. */
  108809. register(): void;
  108810. /**
  108811. * Rebuilds the elements related to this component in case of
  108812. * context lost for instance.
  108813. */
  108814. rebuild(): void;
  108815. /**
  108816. * Disposes the component and the associated ressources
  108817. */
  108818. dispose(): void;
  108819. }
  108820. }
  108821. declare module BABYLON {
  108822. /**
  108823. * A helper for physics simulations
  108824. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  108825. */
  108826. export class PhysicsHelper {
  108827. private _scene;
  108828. private _physicsEngine;
  108829. /**
  108830. * Initializes the Physics helper
  108831. * @param scene Babylon.js scene
  108832. */
  108833. constructor(scene: Scene);
  108834. /**
  108835. * Applies a radial explosion impulse
  108836. * @param origin the origin of the explosion
  108837. * @param radiusOrEventOptions the radius or the options of radial explosion
  108838. * @param strength the explosion strength
  108839. * @param falloff possible options: Constant & Linear. Defaults to Constant
  108840. * @returns A physics radial explosion event, or null
  108841. */
  108842. applyRadialExplosionImpulse(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  108843. /**
  108844. * Applies a radial explosion force
  108845. * @param origin the origin of the explosion
  108846. * @param radiusOrEventOptions the radius or the options of radial explosion
  108847. * @param strength the explosion strength
  108848. * @param falloff possible options: Constant & Linear. Defaults to Constant
  108849. * @returns A physics radial explosion event, or null
  108850. */
  108851. applyRadialExplosionForce(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  108852. /**
  108853. * Creates a gravitational field
  108854. * @param origin the origin of the explosion
  108855. * @param radiusOrEventOptions the radius or the options of radial explosion
  108856. * @param strength the explosion strength
  108857. * @param falloff possible options: Constant & Linear. Defaults to Constant
  108858. * @returns A physics gravitational field event, or null
  108859. */
  108860. gravitationalField(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsGravitationalFieldEvent>;
  108861. /**
  108862. * Creates a physics updraft event
  108863. * @param origin the origin of the updraft
  108864. * @param radiusOrEventOptions the radius or the options of the updraft
  108865. * @param strength the strength of the updraft
  108866. * @param height the height of the updraft
  108867. * @param updraftMode possible options: Center & Perpendicular. Defaults to Center
  108868. * @returns A physics updraft event, or null
  108869. */
  108870. updraft(origin: Vector3, radiusOrEventOptions: number | PhysicsUpdraftEventOptions, strength?: number, height?: number, updraftMode?: PhysicsUpdraftMode): Nullable<PhysicsUpdraftEvent>;
  108871. /**
  108872. * Creates a physics vortex event
  108873. * @param origin the of the vortex
  108874. * @param radiusOrEventOptions the radius or the options of the vortex
  108875. * @param strength the strength of the vortex
  108876. * @param height the height of the vortex
  108877. * @returns a Physics vortex event, or null
  108878. * A physics vortex event or null
  108879. */
  108880. vortex(origin: Vector3, radiusOrEventOptions: number | PhysicsVortexEventOptions, strength?: number, height?: number): Nullable<PhysicsVortexEvent>;
  108881. }
  108882. /**
  108883. * Represents a physics radial explosion event
  108884. */
  108885. class PhysicsRadialExplosionEvent {
  108886. private _scene;
  108887. private _options;
  108888. private _sphere;
  108889. private _dataFetched;
  108890. /**
  108891. * Initializes a radial explosioin event
  108892. * @param _scene BabylonJS scene
  108893. * @param _options The options for the vortex event
  108894. */
  108895. constructor(_scene: Scene, _options: PhysicsRadialExplosionEventOptions);
  108896. /**
  108897. * Returns the data related to the radial explosion event (sphere).
  108898. * @returns The radial explosion event data
  108899. */
  108900. getData(): PhysicsRadialExplosionEventData;
  108901. /**
  108902. * Returns the force and contact point of the impostor or false, if the impostor is not affected by the force/impulse.
  108903. * @param impostor A physics imposter
  108904. * @param origin the origin of the explosion
  108905. * @returns {Nullable<PhysicsForceAndContactPoint>} A physics force and contact point, or null
  108906. */
  108907. getImpostorForceAndContactPoint(impostor: PhysicsImpostor, origin: Vector3): Nullable<PhysicsForceAndContactPoint>;
  108908. /**
  108909. * Disposes the sphere.
  108910. * @param force Specifies if the sphere should be disposed by force
  108911. */
  108912. dispose(force?: boolean): void;
  108913. /*** Helpers ***/
  108914. private _prepareSphere;
  108915. private _intersectsWithSphere;
  108916. }
  108917. /**
  108918. * Represents a gravitational field event
  108919. */
  108920. class PhysicsGravitationalFieldEvent {
  108921. private _physicsHelper;
  108922. private _scene;
  108923. private _origin;
  108924. private _options;
  108925. private _tickCallback;
  108926. private _sphere;
  108927. private _dataFetched;
  108928. /**
  108929. * Initializes the physics gravitational field event
  108930. * @param _physicsHelper A physics helper
  108931. * @param _scene BabylonJS scene
  108932. * @param _origin The origin position of the gravitational field event
  108933. * @param _options The options for the vortex event
  108934. */
  108935. constructor(_physicsHelper: PhysicsHelper, _scene: Scene, _origin: Vector3, _options: PhysicsRadialExplosionEventOptions);
  108936. /**
  108937. * Returns the data related to the gravitational field event (sphere).
  108938. * @returns A gravitational field event
  108939. */
  108940. getData(): PhysicsGravitationalFieldEventData;
  108941. /**
  108942. * Enables the gravitational field.
  108943. */
  108944. enable(): void;
  108945. /**
  108946. * Disables the gravitational field.
  108947. */
  108948. disable(): void;
  108949. /**
  108950. * Disposes the sphere.
  108951. * @param force The force to dispose from the gravitational field event
  108952. */
  108953. dispose(force?: boolean): void;
  108954. private _tick;
  108955. }
  108956. /**
  108957. * Represents a physics updraft event
  108958. */
  108959. class PhysicsUpdraftEvent {
  108960. private _scene;
  108961. private _origin;
  108962. private _options;
  108963. private _physicsEngine;
  108964. private _originTop;
  108965. private _originDirection;
  108966. private _tickCallback;
  108967. private _cylinder;
  108968. private _cylinderPosition;
  108969. private _dataFetched;
  108970. /**
  108971. * Initializes the physics updraft event
  108972. * @param _scene BabylonJS scene
  108973. * @param _origin The origin position of the updraft
  108974. * @param _options The options for the updraft event
  108975. */
  108976. constructor(_scene: Scene, _origin: Vector3, _options: PhysicsUpdraftEventOptions);
  108977. /**
  108978. * Returns the data related to the updraft event (cylinder).
  108979. * @returns A physics updraft event
  108980. */
  108981. getData(): PhysicsUpdraftEventData;
  108982. /**
  108983. * Enables the updraft.
  108984. */
  108985. enable(): void;
  108986. /**
  108987. * Disables the updraft.
  108988. */
  108989. disable(): void;
  108990. /**
  108991. * Disposes the cylinder.
  108992. * @param force Specifies if the updraft should be disposed by force
  108993. */
  108994. dispose(force?: boolean): void;
  108995. private getImpostorForceAndContactPoint;
  108996. private _tick;
  108997. /*** Helpers ***/
  108998. private _prepareCylinder;
  108999. private _intersectsWithCylinder;
  109000. }
  109001. /**
  109002. * Represents a physics vortex event
  109003. */
  109004. class PhysicsVortexEvent {
  109005. private _scene;
  109006. private _origin;
  109007. private _options;
  109008. private _physicsEngine;
  109009. private _originTop;
  109010. private _tickCallback;
  109011. private _cylinder;
  109012. private _cylinderPosition;
  109013. private _dataFetched;
  109014. /**
  109015. * Initializes the physics vortex event
  109016. * @param _scene The BabylonJS scene
  109017. * @param _origin The origin position of the vortex
  109018. * @param _options The options for the vortex event
  109019. */
  109020. constructor(_scene: Scene, _origin: Vector3, _options: PhysicsVortexEventOptions);
  109021. /**
  109022. * Returns the data related to the vortex event (cylinder).
  109023. * @returns The physics vortex event data
  109024. */
  109025. getData(): PhysicsVortexEventData;
  109026. /**
  109027. * Enables the vortex.
  109028. */
  109029. enable(): void;
  109030. /**
  109031. * Disables the cortex.
  109032. */
  109033. disable(): void;
  109034. /**
  109035. * Disposes the sphere.
  109036. * @param force
  109037. */
  109038. dispose(force?: boolean): void;
  109039. private getImpostorForceAndContactPoint;
  109040. private _tick;
  109041. /*** Helpers ***/
  109042. private _prepareCylinder;
  109043. private _intersectsWithCylinder;
  109044. }
  109045. /**
  109046. * Options fot the radial explosion event
  109047. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  109048. */
  109049. export class PhysicsRadialExplosionEventOptions {
  109050. /**
  109051. * The radius of the sphere for the radial explosion.
  109052. */
  109053. radius: number;
  109054. /**
  109055. * The strenth of the explosion.
  109056. */
  109057. strength: number;
  109058. /**
  109059. * The strenght of the force in correspondence to the distance of the affected object
  109060. */
  109061. falloff: PhysicsRadialImpulseFalloff;
  109062. /**
  109063. * Sphere options for the radial explosion.
  109064. */
  109065. sphere: {
  109066. segments: number;
  109067. diameter: number;
  109068. };
  109069. }
  109070. /**
  109071. * Options fot the updraft event
  109072. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  109073. */
  109074. export class PhysicsUpdraftEventOptions {
  109075. /**
  109076. * The radius of the cylinder for the vortex
  109077. */
  109078. radius: number;
  109079. /**
  109080. * The strenth of the updraft.
  109081. */
  109082. strength: number;
  109083. /**
  109084. * The height of the cylinder for the updraft.
  109085. */
  109086. height: number;
  109087. /**
  109088. * The mode for the the updraft.
  109089. */
  109090. updraftMode: PhysicsUpdraftMode;
  109091. }
  109092. /**
  109093. * Options fot the vortex event
  109094. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  109095. */
  109096. export class PhysicsVortexEventOptions {
  109097. /**
  109098. * The radius of the cylinder for the vortex
  109099. */
  109100. radius: number;
  109101. /**
  109102. * The strenth of the vortex.
  109103. */
  109104. strength: number;
  109105. /**
  109106. * The height of the cylinder for the vortex.
  109107. */
  109108. height: number;
  109109. /**
  109110. * At which distance, relative to the radius the centripetal forces should kick in? Range: 0-1
  109111. */
  109112. centripetalForceThreshold: number;
  109113. /**
  109114. * This multiplier determines with how much force the objects will be pushed sideways/around the vortex, when below the treshold.
  109115. */
  109116. centripetalForceMultiplier: number;
  109117. /**
  109118. * This multiplier determines with how much force the objects will be pushed sideways/around the vortex, when above the treshold.
  109119. */
  109120. centrifugalForceMultiplier: number;
  109121. /**
  109122. * This multiplier determines with how much force the objects will be pushed upwards, when in the vortex.
  109123. */
  109124. updraftForceMultiplier: number;
  109125. }
  109126. /**
  109127. * The strenght of the force in correspondence to the distance of the affected object
  109128. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  109129. */
  109130. export enum PhysicsRadialImpulseFalloff {
  109131. /** Defines that impulse is constant in strength across it's whole radius */
  109132. Constant = 0,
  109133. /** Defines that impulse gets weaker if it's further from the origin */
  109134. Linear = 1
  109135. }
  109136. /**
  109137. * The strength of the force in correspondence to the distance of the affected object
  109138. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  109139. */
  109140. export enum PhysicsUpdraftMode {
  109141. /** Defines that the upstream forces will pull towards the top center of the cylinder */
  109142. Center = 0,
  109143. /** Defines that once a impostor is inside the cylinder, it will shoot out perpendicular from the ground of the cylinder */
  109144. Perpendicular = 1
  109145. }
  109146. /**
  109147. * Interface for a physics force and contact point
  109148. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  109149. */
  109150. export interface PhysicsForceAndContactPoint {
  109151. /**
  109152. * The force applied at the contact point
  109153. */
  109154. force: Vector3;
  109155. /**
  109156. * The contact point
  109157. */
  109158. contactPoint: Vector3;
  109159. }
  109160. /**
  109161. * Interface for radial explosion event data
  109162. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  109163. */
  109164. export interface PhysicsRadialExplosionEventData {
  109165. /**
  109166. * A sphere used for the radial explosion event
  109167. */
  109168. sphere: Mesh;
  109169. }
  109170. /**
  109171. * Interface for gravitational field event data
  109172. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  109173. */
  109174. export interface PhysicsGravitationalFieldEventData {
  109175. /**
  109176. * A sphere mesh used for the gravitational field event
  109177. */
  109178. sphere: Mesh;
  109179. }
  109180. /**
  109181. * Interface for updraft event data
  109182. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  109183. */
  109184. export interface PhysicsUpdraftEventData {
  109185. /**
  109186. * A cylinder used for the updraft event
  109187. */
  109188. cylinder: Mesh;
  109189. }
  109190. /**
  109191. * Interface for vortex event data
  109192. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  109193. */
  109194. export interface PhysicsVortexEventData {
  109195. /**
  109196. * A cylinder used for the vortex event
  109197. */
  109198. cylinder: Mesh;
  109199. }
  109200. }
  109201. declare module BABYLON {
  109202. /**
  109203. * AmmoJS Physics plugin
  109204. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  109205. * @see https://github.com/kripken/ammo.js/
  109206. */
  109207. export class AmmoJSPlugin implements IPhysicsEnginePlugin {
  109208. private _useDeltaForWorldStep;
  109209. /**
  109210. * Reference to the Ammo library
  109211. */
  109212. bjsAMMO: any;
  109213. /**
  109214. * Created ammoJS world which physics bodies are added to
  109215. */
  109216. world: any;
  109217. /**
  109218. * Name of the plugin
  109219. */
  109220. name: string;
  109221. private _timeStep;
  109222. private _fixedTimeStep;
  109223. private _maxSteps;
  109224. private _tmpQuaternion;
  109225. private _tmpAmmoTransform;
  109226. private _tmpAmmoQuaternion;
  109227. private _tmpAmmoConcreteContactResultCallback;
  109228. private _collisionConfiguration;
  109229. private _dispatcher;
  109230. private _overlappingPairCache;
  109231. private _solver;
  109232. private _softBodySolver;
  109233. private _tmpAmmoVectorA;
  109234. private _tmpAmmoVectorB;
  109235. private _tmpAmmoVectorC;
  109236. private _tmpAmmoVectorD;
  109237. private _tmpContactCallbackResult;
  109238. private _tmpAmmoVectorRCA;
  109239. private _tmpAmmoVectorRCB;
  109240. private _raycastResult;
  109241. private static readonly DISABLE_COLLISION_FLAG;
  109242. private static readonly KINEMATIC_FLAG;
  109243. private static readonly DISABLE_DEACTIVATION_FLAG;
  109244. /**
  109245. * Initializes the ammoJS plugin
  109246. * @param _useDeltaForWorldStep if the time between frames should be used when calculating physics steps (Default: true)
  109247. * @param ammoInjection can be used to inject your own ammo reference
  109248. */
  109249. constructor(_useDeltaForWorldStep?: boolean, ammoInjection?: any);
  109250. /**
  109251. * Sets the gravity of the physics world (m/(s^2))
  109252. * @param gravity Gravity to set
  109253. */
  109254. setGravity(gravity: Vector3): void;
  109255. /**
  109256. * Amount of time to step forward on each frame (only used if useDeltaForWorldStep is false in the constructor)
  109257. * @param timeStep timestep to use in seconds
  109258. */
  109259. setTimeStep(timeStep: number): void;
  109260. /**
  109261. * 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)
  109262. * @param fixedTimeStep fixedTimeStep to use in seconds
  109263. */
  109264. setFixedTimeStep(fixedTimeStep: number): void;
  109265. /**
  109266. * Sets the maximum number of steps by the physics engine per frame (Default: 5)
  109267. * @param maxSteps the maximum number of steps by the physics engine per frame
  109268. */
  109269. setMaxSteps(maxSteps: number): void;
  109270. /**
  109271. * Gets the current timestep (only used if useDeltaForWorldStep is false in the constructor)
  109272. * @returns the current timestep in seconds
  109273. */
  109274. getTimeStep(): number;
  109275. private _isImpostorInContact;
  109276. private _isImpostorPairInContact;
  109277. private _stepSimulation;
  109278. /**
  109279. * Moves the physics simulation forward delta seconds and updates the given physics imposters
  109280. * Prior to the step the imposters physics location is set to the position of the babylon meshes
  109281. * After the step the babylon meshes are set to the position of the physics imposters
  109282. * @param delta amount of time to step forward
  109283. * @param impostors array of imposters to update before/after the step
  109284. */
  109285. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  109286. /**
  109287. * Update babylon mesh to match physics world object
  109288. * @param impostor imposter to match
  109289. */
  109290. private _afterSoftStep;
  109291. /**
  109292. * Update babylon mesh vertices vertices to match physics world softbody or cloth
  109293. * @param impostor imposter to match
  109294. */
  109295. private _ropeStep;
  109296. /**
  109297. * Update babylon mesh vertices vertices to match physics world softbody or cloth
  109298. * @param impostor imposter to match
  109299. */
  109300. private _softbodyOrClothStep;
  109301. private _tmpVector;
  109302. private _tmpMatrix;
  109303. /**
  109304. * Applies an impulse on the imposter
  109305. * @param impostor imposter to apply impulse to
  109306. * @param force amount of force to be applied to the imposter
  109307. * @param contactPoint the location to apply the impulse on the imposter
  109308. */
  109309. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  109310. /**
  109311. * Applies a force on the imposter
  109312. * @param impostor imposter to apply force
  109313. * @param force amount of force to be applied to the imposter
  109314. * @param contactPoint the location to apply the force on the imposter
  109315. */
  109316. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  109317. /**
  109318. * Creates a physics body using the plugin
  109319. * @param impostor the imposter to create the physics body on
  109320. */
  109321. generatePhysicsBody(impostor: PhysicsImpostor): void;
  109322. /**
  109323. * Removes the physics body from the imposter and disposes of the body's memory
  109324. * @param impostor imposter to remove the physics body from
  109325. */
  109326. removePhysicsBody(impostor: PhysicsImpostor): void;
  109327. /**
  109328. * Generates a joint
  109329. * @param impostorJoint the imposter joint to create the joint with
  109330. */
  109331. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  109332. /**
  109333. * Removes a joint
  109334. * @param impostorJoint the imposter joint to remove the joint from
  109335. */
  109336. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  109337. private _addMeshVerts;
  109338. /**
  109339. * Initialise the soft body vertices to match its object's (mesh) vertices
  109340. * Softbody vertices (nodes) are in world space and to match this
  109341. * The object's position and rotation is set to zero and so its vertices are also then set in world space
  109342. * @param impostor to create the softbody for
  109343. */
  109344. private _softVertexData;
  109345. /**
  109346. * Create an impostor's soft body
  109347. * @param impostor to create the softbody for
  109348. */
  109349. private _createSoftbody;
  109350. /**
  109351. * Create cloth for an impostor
  109352. * @param impostor to create the softbody for
  109353. */
  109354. private _createCloth;
  109355. /**
  109356. * Create rope for an impostor
  109357. * @param impostor to create the softbody for
  109358. */
  109359. private _createRope;
  109360. private _addHullVerts;
  109361. private _createShape;
  109362. /**
  109363. * Sets the physics body position/rotation from the babylon mesh's position/rotation
  109364. * @param impostor imposter containing the physics body and babylon object
  109365. */
  109366. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  109367. /**
  109368. * Sets the babylon object's position/rotation from the physics body's position/rotation
  109369. * @param impostor imposter containing the physics body and babylon object
  109370. * @param newPosition new position
  109371. * @param newRotation new rotation
  109372. */
  109373. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  109374. /**
  109375. * If this plugin is supported
  109376. * @returns true if its supported
  109377. */
  109378. isSupported(): boolean;
  109379. /**
  109380. * Sets the linear velocity of the physics body
  109381. * @param impostor imposter to set the velocity on
  109382. * @param velocity velocity to set
  109383. */
  109384. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  109385. /**
  109386. * Sets the angular velocity of the physics body
  109387. * @param impostor imposter to set the velocity on
  109388. * @param velocity velocity to set
  109389. */
  109390. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  109391. /**
  109392. * gets the linear velocity
  109393. * @param impostor imposter to get linear velocity from
  109394. * @returns linear velocity
  109395. */
  109396. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  109397. /**
  109398. * gets the angular velocity
  109399. * @param impostor imposter to get angular velocity from
  109400. * @returns angular velocity
  109401. */
  109402. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  109403. /**
  109404. * Sets the mass of physics body
  109405. * @param impostor imposter to set the mass on
  109406. * @param mass mass to set
  109407. */
  109408. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  109409. /**
  109410. * Gets the mass of the physics body
  109411. * @param impostor imposter to get the mass from
  109412. * @returns mass
  109413. */
  109414. getBodyMass(impostor: PhysicsImpostor): number;
  109415. /**
  109416. * Gets friction of the impostor
  109417. * @param impostor impostor to get friction from
  109418. * @returns friction value
  109419. */
  109420. getBodyFriction(impostor: PhysicsImpostor): number;
  109421. /**
  109422. * Sets friction of the impostor
  109423. * @param impostor impostor to set friction on
  109424. * @param friction friction value
  109425. */
  109426. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  109427. /**
  109428. * Gets restitution of the impostor
  109429. * @param impostor impostor to get restitution from
  109430. * @returns restitution value
  109431. */
  109432. getBodyRestitution(impostor: PhysicsImpostor): number;
  109433. /**
  109434. * Sets resitution of the impostor
  109435. * @param impostor impostor to set resitution on
  109436. * @param restitution resitution value
  109437. */
  109438. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  109439. /**
  109440. * Gets pressure inside the impostor
  109441. * @param impostor impostor to get pressure from
  109442. * @returns pressure value
  109443. */
  109444. getBodyPressure(impostor: PhysicsImpostor): number;
  109445. /**
  109446. * Sets pressure inside a soft body impostor
  109447. * Cloth and rope must remain 0 pressure
  109448. * @param impostor impostor to set pressure on
  109449. * @param pressure pressure value
  109450. */
  109451. setBodyPressure(impostor: PhysicsImpostor, pressure: number): void;
  109452. /**
  109453. * Gets stiffness of the impostor
  109454. * @param impostor impostor to get stiffness from
  109455. * @returns pressure value
  109456. */
  109457. getBodyStiffness(impostor: PhysicsImpostor): number;
  109458. /**
  109459. * Sets stiffness of the impostor
  109460. * @param impostor impostor to set stiffness on
  109461. * @param stiffness stiffness value from 0 to 1
  109462. */
  109463. setBodyStiffness(impostor: PhysicsImpostor, stiffness: number): void;
  109464. /**
  109465. * Gets velocityIterations of the impostor
  109466. * @param impostor impostor to get velocity iterations from
  109467. * @returns velocityIterations value
  109468. */
  109469. getBodyVelocityIterations(impostor: PhysicsImpostor): number;
  109470. /**
  109471. * Sets velocityIterations of the impostor
  109472. * @param impostor impostor to set velocity iterations on
  109473. * @param velocityIterations velocityIterations value
  109474. */
  109475. setBodyVelocityIterations(impostor: PhysicsImpostor, velocityIterations: number): void;
  109476. /**
  109477. * Gets positionIterations of the impostor
  109478. * @param impostor impostor to get position iterations from
  109479. * @returns positionIterations value
  109480. */
  109481. getBodyPositionIterations(impostor: PhysicsImpostor): number;
  109482. /**
  109483. * Sets positionIterations of the impostor
  109484. * @param impostor impostor to set position on
  109485. * @param positionIterations positionIterations value
  109486. */
  109487. setBodyPositionIterations(impostor: PhysicsImpostor, positionIterations: number): void;
  109488. /**
  109489. * Append an anchor to a cloth object
  109490. * @param impostor is the cloth impostor to add anchor to
  109491. * @param otherImpostor is the rigid impostor to anchor to
  109492. * @param width ratio across width from 0 to 1
  109493. * @param height ratio up height from 0 to 1
  109494. * @param influence the elasticity between cloth impostor and anchor from 0, very stretchy to 1, little strech
  109495. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  109496. */
  109497. appendAnchor(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, width: number, height: number, influence?: number, noCollisionBetweenLinkedBodies?: boolean): void;
  109498. /**
  109499. * Append an hook to a rope object
  109500. * @param impostor is the rope impostor to add hook to
  109501. * @param otherImpostor is the rigid impostor to hook to
  109502. * @param length ratio along the rope from 0 to 1
  109503. * @param influence the elasticity between soft impostor and anchor from 0, very stretchy to 1, little strech
  109504. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  109505. */
  109506. appendHook(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, length: number, influence?: number, noCollisionBetweenLinkedBodies?: boolean): void;
  109507. /**
  109508. * Sleeps the physics body and stops it from being active
  109509. * @param impostor impostor to sleep
  109510. */
  109511. sleepBody(impostor: PhysicsImpostor): void;
  109512. /**
  109513. * Activates the physics body
  109514. * @param impostor impostor to activate
  109515. */
  109516. wakeUpBody(impostor: PhysicsImpostor): void;
  109517. /**
  109518. * Updates the distance parameters of the joint
  109519. * @param joint joint to update
  109520. * @param maxDistance maximum distance of the joint
  109521. * @param minDistance minimum distance of the joint
  109522. */
  109523. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  109524. /**
  109525. * Sets a motor on the joint
  109526. * @param joint joint to set motor on
  109527. * @param speed speed of the motor
  109528. * @param maxForce maximum force of the motor
  109529. * @param motorIndex index of the motor
  109530. */
  109531. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  109532. /**
  109533. * Sets the motors limit
  109534. * @param joint joint to set limit on
  109535. * @param upperLimit upper limit
  109536. * @param lowerLimit lower limit
  109537. */
  109538. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  109539. /**
  109540. * Syncs the position and rotation of a mesh with the impostor
  109541. * @param mesh mesh to sync
  109542. * @param impostor impostor to update the mesh with
  109543. */
  109544. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  109545. /**
  109546. * Gets the radius of the impostor
  109547. * @param impostor impostor to get radius from
  109548. * @returns the radius
  109549. */
  109550. getRadius(impostor: PhysicsImpostor): number;
  109551. /**
  109552. * Gets the box size of the impostor
  109553. * @param impostor impostor to get box size from
  109554. * @param result the resulting box size
  109555. */
  109556. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  109557. /**
  109558. * Disposes of the impostor
  109559. */
  109560. dispose(): void;
  109561. /**
  109562. * Does a raycast in the physics world
  109563. * @param from when should the ray start?
  109564. * @param to when should the ray end?
  109565. * @returns PhysicsRaycastResult
  109566. */
  109567. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  109568. }
  109569. }
  109570. declare module BABYLON {
  109571. /** @hidden */
  109572. export var blackAndWhitePixelShader: {
  109573. name: string;
  109574. shader: string;
  109575. };
  109576. }
  109577. declare module BABYLON {
  109578. /**
  109579. * Post process used to render in black and white
  109580. */
  109581. export class BlackAndWhitePostProcess extends PostProcess {
  109582. /**
  109583. * Linear about to convert he result to black and white (default: 1)
  109584. */
  109585. degree: number;
  109586. /**
  109587. * Creates a black and white post process
  109588. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#black-and-white
  109589. * @param name The name of the effect.
  109590. * @param options The required width/height ratio to downsize to before computing the render pass.
  109591. * @param camera The camera to apply the render pass to.
  109592. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  109593. * @param engine The engine which the post process will be applied. (default: current engine)
  109594. * @param reusable If the post process can be reused on the same frame. (default: false)
  109595. */
  109596. constructor(name: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  109597. }
  109598. }
  109599. declare module BABYLON {
  109600. /**
  109601. * This represents a set of one or more post processes in Babylon.
  109602. * A post process can be used to apply a shader to a texture after it is rendered.
  109603. * @example https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  109604. */
  109605. export class PostProcessRenderEffect {
  109606. private _postProcesses;
  109607. private _getPostProcesses;
  109608. private _singleInstance;
  109609. private _cameras;
  109610. private _indicesForCamera;
  109611. /**
  109612. * Name of the effect
  109613. * @hidden
  109614. */
  109615. _name: string;
  109616. /**
  109617. * Instantiates a post process render effect.
  109618. * A post process can be used to apply a shader to a texture after it is rendered.
  109619. * @param engine The engine the effect is tied to
  109620. * @param name The name of the effect
  109621. * @param getPostProcesses A function that returns a set of post processes which the effect will run in order to be run.
  109622. * @param singleInstance False if this post process can be run on multiple cameras. (default: true)
  109623. */
  109624. constructor(engine: Engine, name: string, getPostProcesses: () => Nullable<PostProcess | Array<PostProcess>>, singleInstance?: boolean);
  109625. /**
  109626. * Checks if all the post processes in the effect are supported.
  109627. */
  109628. readonly isSupported: boolean;
  109629. /**
  109630. * Updates the current state of the effect
  109631. * @hidden
  109632. */
  109633. _update(): void;
  109634. /**
  109635. * Attaches the effect on cameras
  109636. * @param cameras The camera to attach to.
  109637. * @hidden
  109638. */
  109639. _attachCameras(cameras: Camera): void;
  109640. /**
  109641. * Attaches the effect on cameras
  109642. * @param cameras The camera to attach to.
  109643. * @hidden
  109644. */
  109645. _attachCameras(cameras: Camera[]): void;
  109646. /**
  109647. * Detatches the effect on cameras
  109648. * @param cameras The camera to detatch from.
  109649. * @hidden
  109650. */
  109651. _detachCameras(cameras: Camera): void;
  109652. /**
  109653. * Detatches the effect on cameras
  109654. * @param cameras The camera to detatch from.
  109655. * @hidden
  109656. */
  109657. _detachCameras(cameras: Camera[]): void;
  109658. /**
  109659. * Enables the effect on given cameras
  109660. * @param cameras The camera to enable.
  109661. * @hidden
  109662. */
  109663. _enable(cameras: Camera): void;
  109664. /**
  109665. * Enables the effect on given cameras
  109666. * @param cameras The camera to enable.
  109667. * @hidden
  109668. */
  109669. _enable(cameras: Nullable<Camera[]>): void;
  109670. /**
  109671. * Disables the effect on the given cameras
  109672. * @param cameras The camera to disable.
  109673. * @hidden
  109674. */
  109675. _disable(cameras: Camera): void;
  109676. /**
  109677. * Disables the effect on the given cameras
  109678. * @param cameras The camera to disable.
  109679. * @hidden
  109680. */
  109681. _disable(cameras: Nullable<Camera[]>): void;
  109682. /**
  109683. * Gets a list of the post processes contained in the effect.
  109684. * @param camera The camera to get the post processes on.
  109685. * @returns The list of the post processes in the effect.
  109686. */
  109687. getPostProcesses(camera?: Camera): Nullable<Array<PostProcess>>;
  109688. }
  109689. }
  109690. declare module BABYLON {
  109691. /** @hidden */
  109692. export var extractHighlightsPixelShader: {
  109693. name: string;
  109694. shader: string;
  109695. };
  109696. }
  109697. declare module BABYLON {
  109698. /**
  109699. * 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.
  109700. */
  109701. export class ExtractHighlightsPostProcess extends PostProcess {
  109702. /**
  109703. * The luminance threshold, pixels below this value will be set to black.
  109704. */
  109705. threshold: number;
  109706. /** @hidden */
  109707. _exposure: number;
  109708. /**
  109709. * Post process which has the input texture to be used when performing highlight extraction
  109710. * @hidden
  109711. */
  109712. _inputPostProcess: Nullable<PostProcess>;
  109713. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  109714. }
  109715. }
  109716. declare module BABYLON {
  109717. /** @hidden */
  109718. export var bloomMergePixelShader: {
  109719. name: string;
  109720. shader: string;
  109721. };
  109722. }
  109723. declare module BABYLON {
  109724. /**
  109725. * The BloomMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  109726. */
  109727. export class BloomMergePostProcess extends PostProcess {
  109728. /** Weight of the bloom to be added to the original input. */
  109729. weight: number;
  109730. /**
  109731. * Creates a new instance of @see BloomMergePostProcess
  109732. * @param name The name of the effect.
  109733. * @param originalFromInput Post process which's input will be used for the merge.
  109734. * @param blurred Blurred highlights post process which's output will be used.
  109735. * @param weight Weight of the bloom to be added to the original input.
  109736. * @param options The required width/height ratio to downsize to before computing the render pass.
  109737. * @param camera The camera to apply the render pass to.
  109738. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  109739. * @param engine The engine which the post process will be applied. (default: current engine)
  109740. * @param reusable If the post process can be reused on the same frame. (default: false)
  109741. * @param textureType Type of textures used when performing the post process. (default: 0)
  109742. * @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)
  109743. */
  109744. constructor(name: string, originalFromInput: PostProcess, blurred: PostProcess,
  109745. /** Weight of the bloom to be added to the original input. */
  109746. weight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  109747. }
  109748. }
  109749. declare module BABYLON {
  109750. /**
  109751. * The bloom effect spreads bright areas of an image to simulate artifacts seen in cameras
  109752. */
  109753. export class BloomEffect extends PostProcessRenderEffect {
  109754. private bloomScale;
  109755. /**
  109756. * @hidden Internal
  109757. */
  109758. _effects: Array<PostProcess>;
  109759. /**
  109760. * @hidden Internal
  109761. */
  109762. _downscale: ExtractHighlightsPostProcess;
  109763. private _blurX;
  109764. private _blurY;
  109765. private _merge;
  109766. /**
  109767. * The luminance threshold to find bright areas of the image to bloom.
  109768. */
  109769. threshold: number;
  109770. /**
  109771. * The strength of the bloom.
  109772. */
  109773. weight: number;
  109774. /**
  109775. * Specifies the size of the bloom blur kernel, relative to the final output size
  109776. */
  109777. kernel: number;
  109778. /**
  109779. * Creates a new instance of @see BloomEffect
  109780. * @param scene The scene the effect belongs to.
  109781. * @param bloomScale The ratio of the blur texture to the input texture that should be used to compute the bloom.
  109782. * @param bloomKernel The size of the kernel to be used when applying the blur.
  109783. * @param bloomWeight The the strength of bloom.
  109784. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  109785. * @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)
  109786. */
  109787. constructor(scene: Scene, bloomScale: number, bloomWeight: number, bloomKernel: number, pipelineTextureType?: number, blockCompilation?: boolean);
  109788. /**
  109789. * Disposes each of the internal effects for a given camera.
  109790. * @param camera The camera to dispose the effect on.
  109791. */
  109792. disposeEffects(camera: Camera): void;
  109793. /**
  109794. * @hidden Internal
  109795. */
  109796. _updateEffects(): void;
  109797. /**
  109798. * Internal
  109799. * @returns if all the contained post processes are ready.
  109800. * @hidden
  109801. */
  109802. _isReady(): boolean;
  109803. }
  109804. }
  109805. declare module BABYLON {
  109806. /** @hidden */
  109807. export var chromaticAberrationPixelShader: {
  109808. name: string;
  109809. shader: string;
  109810. };
  109811. }
  109812. declare module BABYLON {
  109813. /**
  109814. * The ChromaticAberrationPostProcess separates the rgb channels in an image to produce chromatic distortion around the edges of the screen
  109815. */
  109816. export class ChromaticAberrationPostProcess extends PostProcess {
  109817. /**
  109818. * The amount of seperation of rgb channels (default: 30)
  109819. */
  109820. aberrationAmount: number;
  109821. /**
  109822. * The amount the effect will increase for pixels closer to the edge of the screen. (default: 0)
  109823. */
  109824. radialIntensity: number;
  109825. /**
  109826. * 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))
  109827. */
  109828. direction: Vector2;
  109829. /**
  109830. * 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))
  109831. */
  109832. centerPosition: Vector2;
  109833. /**
  109834. * Creates a new instance ChromaticAberrationPostProcess
  109835. * @param name The name of the effect.
  109836. * @param screenWidth The width of the screen to apply the effect on.
  109837. * @param screenHeight The height of the screen to apply the effect on.
  109838. * @param options The required width/height ratio to downsize to before computing the render pass.
  109839. * @param camera The camera to apply the render pass to.
  109840. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  109841. * @param engine The engine which the post process will be applied. (default: current engine)
  109842. * @param reusable If the post process can be reused on the same frame. (default: false)
  109843. * @param textureType Type of textures used when performing the post process. (default: 0)
  109844. * @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)
  109845. */
  109846. constructor(name: string, screenWidth: number, screenHeight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  109847. }
  109848. }
  109849. declare module BABYLON {
  109850. /** @hidden */
  109851. export var circleOfConfusionPixelShader: {
  109852. name: string;
  109853. shader: string;
  109854. };
  109855. }
  109856. declare module BABYLON {
  109857. /**
  109858. * The CircleOfConfusionPostProcess computes the circle of confusion value for each pixel given required lens parameters. See https://en.wikipedia.org/wiki/Circle_of_confusion
  109859. */
  109860. export class CircleOfConfusionPostProcess extends PostProcess {
  109861. /**
  109862. * 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.
  109863. */
  109864. lensSize: number;
  109865. /**
  109866. * F-Stop of the effect's camera. The diamater of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  109867. */
  109868. fStop: number;
  109869. /**
  109870. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  109871. */
  109872. focusDistance: number;
  109873. /**
  109874. * Focal length of the effect's camera in scene units/1000 (eg. millimeter). (default: 50)
  109875. */
  109876. focalLength: number;
  109877. private _depthTexture;
  109878. /**
  109879. * Creates a new instance CircleOfConfusionPostProcess
  109880. * @param name The name of the effect.
  109881. * @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.
  109882. * @param options The required width/height ratio to downsize to before computing the render pass.
  109883. * @param camera The camera to apply the render pass to.
  109884. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  109885. * @param engine The engine which the post process will be applied. (default: current engine)
  109886. * @param reusable If the post process can be reused on the same frame. (default: false)
  109887. * @param textureType Type of textures used when performing the post process. (default: 0)
  109888. * @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)
  109889. */
  109890. constructor(name: string, depthTexture: Nullable<RenderTargetTexture>, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  109891. /**
  109892. * 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.
  109893. */
  109894. depthTexture: RenderTargetTexture;
  109895. }
  109896. }
  109897. declare module BABYLON {
  109898. /** @hidden */
  109899. export var colorCorrectionPixelShader: {
  109900. name: string;
  109901. shader: string;
  109902. };
  109903. }
  109904. declare module BABYLON {
  109905. /**
  109906. *
  109907. * This post-process allows the modification of rendered colors by using
  109908. * a 'look-up table' (LUT). This effect is also called Color Grading.
  109909. *
  109910. * The object needs to be provided an url to a texture containing the color
  109911. * look-up table: the texture must be 256 pixels wide and 16 pixels high.
  109912. * Use an image editing software to tweak the LUT to match your needs.
  109913. *
  109914. * For an example of a color LUT, see here:
  109915. * @see http://udn.epicgames.com/Three/rsrc/Three/ColorGrading/RGBTable16x1.png
  109916. * For explanations on color grading, see here:
  109917. * @see http://udn.epicgames.com/Three/ColorGrading.html
  109918. *
  109919. */
  109920. export class ColorCorrectionPostProcess extends PostProcess {
  109921. private _colorTableTexture;
  109922. constructor(name: string, colorTableUrl: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  109923. }
  109924. }
  109925. declare module BABYLON {
  109926. /** @hidden */
  109927. export var convolutionPixelShader: {
  109928. name: string;
  109929. shader: string;
  109930. };
  109931. }
  109932. declare module BABYLON {
  109933. /**
  109934. * The ConvolutionPostProcess applies a 3x3 kernel to every pixel of the
  109935. * input texture to perform effects such as edge detection or sharpening
  109936. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  109937. */
  109938. export class ConvolutionPostProcess extends PostProcess {
  109939. /** Array of 9 values corrisponding to the 3x3 kernel to be applied */
  109940. kernel: number[];
  109941. /**
  109942. * Creates a new instance ConvolutionPostProcess
  109943. * @param name The name of the effect.
  109944. * @param kernel Array of 9 values corrisponding to the 3x3 kernel to be applied
  109945. * @param options The required width/height ratio to downsize to before computing the render pass.
  109946. * @param camera The camera to apply the render pass to.
  109947. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  109948. * @param engine The engine which the post process will be applied. (default: current engine)
  109949. * @param reusable If the post process can be reused on the same frame. (default: false)
  109950. * @param textureType Type of textures used when performing the post process. (default: 0)
  109951. */
  109952. constructor(name: string,
  109953. /** Array of 9 values corrisponding to the 3x3 kernel to be applied */
  109954. kernel: number[], options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  109955. /**
  109956. * Edge detection 0 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  109957. */
  109958. static EdgeDetect0Kernel: number[];
  109959. /**
  109960. * Edge detection 1 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  109961. */
  109962. static EdgeDetect1Kernel: number[];
  109963. /**
  109964. * Edge detection 2 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  109965. */
  109966. static EdgeDetect2Kernel: number[];
  109967. /**
  109968. * Kernel to sharpen an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  109969. */
  109970. static SharpenKernel: number[];
  109971. /**
  109972. * Kernel to emboss an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  109973. */
  109974. static EmbossKernel: number[];
  109975. /**
  109976. * Kernel to blur an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  109977. */
  109978. static GaussianKernel: number[];
  109979. }
  109980. }
  109981. declare module BABYLON {
  109982. /**
  109983. * The DepthOfFieldBlurPostProcess applied a blur in a give direction.
  109984. * This blur differs from the standard BlurPostProcess as it attempts to avoid blurring pixels
  109985. * based on samples that have a large difference in distance than the center pixel.
  109986. * See section 2.6.2 http://fileadmin.cs.lth.se/cs/education/edan35/lectures/12dof.pdf
  109987. */
  109988. export class DepthOfFieldBlurPostProcess extends BlurPostProcess {
  109989. direction: Vector2;
  109990. /**
  109991. * Creates a new instance CircleOfConfusionPostProcess
  109992. * @param name The name of the effect.
  109993. * @param scene The scene the effect belongs to.
  109994. * @param direction The direction the blur should be applied.
  109995. * @param kernel The size of the kernel used to blur.
  109996. * @param options The required width/height ratio to downsize to before computing the render pass.
  109997. * @param camera The camera to apply the render pass to.
  109998. * @param circleOfConfusion The circle of confusion + depth map to be used to avoid blurring accross edges
  109999. * @param imageToBlur The image to apply the blur to (default: Current rendered frame)
  110000. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  110001. * @param engine The engine which the post process will be applied. (default: current engine)
  110002. * @param reusable If the post process can be reused on the same frame. (default: false)
  110003. * @param textureType Type of textures used when performing the post process. (default: 0)
  110004. * @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)
  110005. */
  110006. 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);
  110007. }
  110008. }
  110009. declare module BABYLON {
  110010. /** @hidden */
  110011. export var depthOfFieldMergePixelShader: {
  110012. name: string;
  110013. shader: string;
  110014. };
  110015. }
  110016. declare module BABYLON {
  110017. /**
  110018. * Options to be set when merging outputs from the default pipeline.
  110019. */
  110020. export class DepthOfFieldMergePostProcessOptions {
  110021. /**
  110022. * The original image to merge on top of
  110023. */
  110024. originalFromInput: PostProcess;
  110025. /**
  110026. * Parameters to perform the merge of the depth of field effect
  110027. */
  110028. depthOfField?: {
  110029. circleOfConfusion: PostProcess;
  110030. blurSteps: Array<PostProcess>;
  110031. };
  110032. /**
  110033. * Parameters to perform the merge of bloom effect
  110034. */
  110035. bloom?: {
  110036. blurred: PostProcess;
  110037. weight: number;
  110038. };
  110039. }
  110040. /**
  110041. * The DepthOfFieldMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  110042. */
  110043. export class DepthOfFieldMergePostProcess extends PostProcess {
  110044. private blurSteps;
  110045. /**
  110046. * Creates a new instance of DepthOfFieldMergePostProcess
  110047. * @param name The name of the effect.
  110048. * @param originalFromInput Post process which's input will be used for the merge.
  110049. * @param circleOfConfusion Circle of confusion post process which's output will be used to blur each pixel.
  110050. * @param blurSteps Blur post processes from low to high which will be mixed with the original image.
  110051. * @param options The required width/height ratio to downsize to before computing the render pass.
  110052. * @param camera The camera to apply the render pass to.
  110053. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  110054. * @param engine The engine which the post process will be applied. (default: current engine)
  110055. * @param reusable If the post process can be reused on the same frame. (default: false)
  110056. * @param textureType Type of textures used when performing the post process. (default: 0)
  110057. * @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)
  110058. */
  110059. 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);
  110060. /**
  110061. * Updates the effect with the current post process compile time values and recompiles the shader.
  110062. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  110063. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  110064. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  110065. * @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
  110066. * @param onCompiled Called when the shader has been compiled.
  110067. * @param onError Called if there is an error when compiling a shader.
  110068. */
  110069. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  110070. }
  110071. }
  110072. declare module BABYLON {
  110073. /**
  110074. * Specifies the level of max blur that should be applied when using the depth of field effect
  110075. */
  110076. export enum DepthOfFieldEffectBlurLevel {
  110077. /**
  110078. * Subtle blur
  110079. */
  110080. Low = 0,
  110081. /**
  110082. * Medium blur
  110083. */
  110084. Medium = 1,
  110085. /**
  110086. * Large blur
  110087. */
  110088. High = 2
  110089. }
  110090. /**
  110091. * The depth of field effect applies a blur to objects that are closer or further from where the camera is focusing.
  110092. */
  110093. export class DepthOfFieldEffect extends PostProcessRenderEffect {
  110094. private _circleOfConfusion;
  110095. /**
  110096. * @hidden Internal, blurs from high to low
  110097. */
  110098. _depthOfFieldBlurX: Array<DepthOfFieldBlurPostProcess>;
  110099. private _depthOfFieldBlurY;
  110100. private _dofMerge;
  110101. /**
  110102. * @hidden Internal post processes in depth of field effect
  110103. */
  110104. _effects: Array<PostProcess>;
  110105. /**
  110106. * The focal the length of the camera used in the effect in scene units/1000 (eg. millimeter)
  110107. */
  110108. focalLength: number;
  110109. /**
  110110. * F-Stop of the effect's camera. The diameter of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  110111. */
  110112. fStop: number;
  110113. /**
  110114. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  110115. */
  110116. focusDistance: number;
  110117. /**
  110118. * 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.
  110119. */
  110120. lensSize: number;
  110121. /**
  110122. * Creates a new instance DepthOfFieldEffect
  110123. * @param scene The scene the effect belongs to.
  110124. * @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.
  110125. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  110126. * @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)
  110127. */
  110128. constructor(scene: Scene, depthTexture: Nullable<RenderTargetTexture>, blurLevel?: DepthOfFieldEffectBlurLevel, pipelineTextureType?: number, blockCompilation?: boolean);
  110129. /**
  110130. * 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.
  110131. */
  110132. depthTexture: RenderTargetTexture;
  110133. /**
  110134. * Disposes each of the internal effects for a given camera.
  110135. * @param camera The camera to dispose the effect on.
  110136. */
  110137. disposeEffects(camera: Camera): void;
  110138. /**
  110139. * @hidden Internal
  110140. */
  110141. _updateEffects(): void;
  110142. /**
  110143. * Internal
  110144. * @returns if all the contained post processes are ready.
  110145. * @hidden
  110146. */
  110147. _isReady(): boolean;
  110148. }
  110149. }
  110150. declare module BABYLON {
  110151. /** @hidden */
  110152. export var displayPassPixelShader: {
  110153. name: string;
  110154. shader: string;
  110155. };
  110156. }
  110157. declare module BABYLON {
  110158. /**
  110159. * DisplayPassPostProcess which produces an output the same as it's input
  110160. */
  110161. export class DisplayPassPostProcess extends PostProcess {
  110162. /**
  110163. * Creates the DisplayPassPostProcess
  110164. * @param name The name of the effect.
  110165. * @param options The required width/height ratio to downsize to before computing the render pass.
  110166. * @param camera The camera to apply the render pass to.
  110167. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  110168. * @param engine The engine which the post process will be applied. (default: current engine)
  110169. * @param reusable If the post process can be reused on the same frame. (default: false)
  110170. */
  110171. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  110172. }
  110173. }
  110174. declare module BABYLON {
  110175. /** @hidden */
  110176. export var filterPixelShader: {
  110177. name: string;
  110178. shader: string;
  110179. };
  110180. }
  110181. declare module BABYLON {
  110182. /**
  110183. * Applies a kernel filter to the image
  110184. */
  110185. export class FilterPostProcess extends PostProcess {
  110186. /** The matrix to be applied to the image */
  110187. kernelMatrix: Matrix;
  110188. /**
  110189. *
  110190. * @param name The name of the effect.
  110191. * @param kernelMatrix The matrix to be applied to the image
  110192. * @param options The required width/height ratio to downsize to before computing the render pass.
  110193. * @param camera The camera to apply the render pass to.
  110194. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  110195. * @param engine The engine which the post process will be applied. (default: current engine)
  110196. * @param reusable If the post process can be reused on the same frame. (default: false)
  110197. */
  110198. constructor(name: string,
  110199. /** The matrix to be applied to the image */
  110200. kernelMatrix: Matrix, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  110201. }
  110202. }
  110203. declare module BABYLON {
  110204. /** @hidden */
  110205. export var fxaaPixelShader: {
  110206. name: string;
  110207. shader: string;
  110208. };
  110209. }
  110210. declare module BABYLON {
  110211. /** @hidden */
  110212. export var fxaaVertexShader: {
  110213. name: string;
  110214. shader: string;
  110215. };
  110216. }
  110217. declare module BABYLON {
  110218. /**
  110219. * Fxaa post process
  110220. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#fxaa
  110221. */
  110222. export class FxaaPostProcess extends PostProcess {
  110223. /** @hidden */
  110224. texelWidth: number;
  110225. /** @hidden */
  110226. texelHeight: number;
  110227. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  110228. private _getDefines;
  110229. }
  110230. }
  110231. declare module BABYLON {
  110232. /** @hidden */
  110233. export var grainPixelShader: {
  110234. name: string;
  110235. shader: string;
  110236. };
  110237. }
  110238. declare module BABYLON {
  110239. /**
  110240. * The GrainPostProcess adds noise to the image at mid luminance levels
  110241. */
  110242. export class GrainPostProcess extends PostProcess {
  110243. /**
  110244. * The intensity of the grain added (default: 30)
  110245. */
  110246. intensity: number;
  110247. /**
  110248. * If the grain should be randomized on every frame
  110249. */
  110250. animated: boolean;
  110251. /**
  110252. * Creates a new instance of @see GrainPostProcess
  110253. * @param name The name of the effect.
  110254. * @param options The required width/height ratio to downsize to before computing the render pass.
  110255. * @param camera The camera to apply the render pass to.
  110256. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  110257. * @param engine The engine which the post process will be applied. (default: current engine)
  110258. * @param reusable If the post process can be reused on the same frame. (default: false)
  110259. * @param textureType Type of textures used when performing the post process. (default: 0)
  110260. * @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)
  110261. */
  110262. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  110263. }
  110264. }
  110265. declare module BABYLON {
  110266. /** @hidden */
  110267. export var highlightsPixelShader: {
  110268. name: string;
  110269. shader: string;
  110270. };
  110271. }
  110272. declare module BABYLON {
  110273. /**
  110274. * Extracts highlights from the image
  110275. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  110276. */
  110277. export class HighlightsPostProcess extends PostProcess {
  110278. /**
  110279. * Extracts highlights from the image
  110280. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  110281. * @param name The name of the effect.
  110282. * @param options The required width/height ratio to downsize to before computing the render pass.
  110283. * @param camera The camera to apply the render pass to.
  110284. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  110285. * @param engine The engine which the post process will be applied. (default: current engine)
  110286. * @param reusable If the post process can be reused on the same frame. (default: false)
  110287. * @param textureType Type of texture for the post process (default: Engine.TEXTURETYPE_UNSIGNED_INT)
  110288. */
  110289. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  110290. }
  110291. }
  110292. declare module BABYLON {
  110293. /** @hidden */
  110294. export var mrtFragmentDeclaration: {
  110295. name: string;
  110296. shader: string;
  110297. };
  110298. }
  110299. declare module BABYLON {
  110300. /** @hidden */
  110301. export var geometryPixelShader: {
  110302. name: string;
  110303. shader: string;
  110304. };
  110305. }
  110306. declare module BABYLON {
  110307. /** @hidden */
  110308. export var geometryVertexShader: {
  110309. name: string;
  110310. shader: string;
  110311. };
  110312. }
  110313. declare module BABYLON {
  110314. /**
  110315. * This renderer is helpfull to fill one of the render target with a geometry buffer.
  110316. */
  110317. export class GeometryBufferRenderer {
  110318. /**
  110319. * Constant used to retrieve the position texture index in the G-Buffer textures array
  110320. * using getIndex(GeometryBufferRenderer.POSITION_TEXTURE_INDEX)
  110321. */
  110322. static readonly POSITION_TEXTURE_TYPE: number;
  110323. /**
  110324. * Constant used to retrieve the velocity texture index in the G-Buffer textures array
  110325. * using getIndex(GeometryBufferRenderer.VELOCITY_TEXTURE_INDEX)
  110326. */
  110327. static readonly VELOCITY_TEXTURE_TYPE: number;
  110328. /**
  110329. * Dictionary used to store the previous transformation matrices of each rendered mesh
  110330. * in order to compute objects velocities when enableVelocity is set to "true"
  110331. * @hidden
  110332. */
  110333. _previousTransformationMatrices: {
  110334. [index: number]: Matrix;
  110335. };
  110336. private _scene;
  110337. private _multiRenderTarget;
  110338. private _ratio;
  110339. private _enablePosition;
  110340. private _enableVelocity;
  110341. private _positionIndex;
  110342. private _velocityIndex;
  110343. protected _effect: Effect;
  110344. protected _cachedDefines: string;
  110345. /**
  110346. * Set the render list (meshes to be rendered) used in the G buffer.
  110347. */
  110348. renderList: Mesh[];
  110349. /**
  110350. * Gets wether or not G buffer are supported by the running hardware.
  110351. * This requires draw buffer supports
  110352. */
  110353. readonly isSupported: boolean;
  110354. /**
  110355. * Returns the index of the given texture type in the G-Buffer textures array
  110356. * @param textureType The texture type constant. For example GeometryBufferRenderer.POSITION_TEXTURE_INDEX
  110357. * @returns the index of the given texture type in the G-Buffer textures array
  110358. */
  110359. getTextureIndex(textureType: number): number;
  110360. /**
  110361. * Gets a boolean indicating if objects positions are enabled for the G buffer.
  110362. */
  110363. /**
  110364. * Sets whether or not objects positions are enabled for the G buffer.
  110365. */
  110366. enablePosition: boolean;
  110367. /**
  110368. * Gets a boolean indicating if objects velocities are enabled for the G buffer.
  110369. */
  110370. /**
  110371. * Sets wether or not objects velocities are enabled for the G buffer.
  110372. */
  110373. enableVelocity: boolean;
  110374. /**
  110375. * Gets the scene associated with the buffer.
  110376. */
  110377. readonly scene: Scene;
  110378. /**
  110379. * Gets the ratio used by the buffer during its creation.
  110380. * How big is the buffer related to the main canvas.
  110381. */
  110382. readonly ratio: number;
  110383. /** @hidden */
  110384. static _SceneComponentInitialization: (scene: Scene) => void;
  110385. /**
  110386. * Creates a new G Buffer for the scene
  110387. * @param scene The scene the buffer belongs to
  110388. * @param ratio How big is the buffer related to the main canvas.
  110389. */
  110390. constructor(scene: Scene, ratio?: number);
  110391. /**
  110392. * Checks wether everything is ready to render a submesh to the G buffer.
  110393. * @param subMesh the submesh to check readiness for
  110394. * @param useInstances is the mesh drawn using instance or not
  110395. * @returns true if ready otherwise false
  110396. */
  110397. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  110398. /**
  110399. * Gets the current underlying G Buffer.
  110400. * @returns the buffer
  110401. */
  110402. getGBuffer(): MultiRenderTarget;
  110403. /**
  110404. * Gets the number of samples used to render the buffer (anti aliasing).
  110405. */
  110406. /**
  110407. * Sets the number of samples used to render the buffer (anti aliasing).
  110408. */
  110409. samples: number;
  110410. /**
  110411. * Disposes the renderer and frees up associated resources.
  110412. */
  110413. dispose(): void;
  110414. protected _createRenderTargets(): void;
  110415. }
  110416. }
  110417. declare module BABYLON {
  110418. interface Scene {
  110419. /** @hidden (Backing field) */
  110420. _geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  110421. /**
  110422. * Gets or Sets the current geometry buffer associated to the scene.
  110423. */
  110424. geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  110425. /**
  110426. * Enables a GeometryBufferRender and associates it with the scene
  110427. * @param ratio defines the scaling ratio to apply to the renderer (1 by default which means same resolution)
  110428. * @returns the GeometryBufferRenderer
  110429. */
  110430. enableGeometryBufferRenderer(ratio?: number): Nullable<GeometryBufferRenderer>;
  110431. /**
  110432. * Disables the GeometryBufferRender associated with the scene
  110433. */
  110434. disableGeometryBufferRenderer(): void;
  110435. }
  110436. /**
  110437. * Defines the Geometry Buffer scene component responsible to manage a G-Buffer useful
  110438. * in several rendering techniques.
  110439. */
  110440. export class GeometryBufferRendererSceneComponent implements ISceneComponent {
  110441. /**
  110442. * The component name helpful to identify the component in the list of scene components.
  110443. */
  110444. readonly name: string;
  110445. /**
  110446. * The scene the component belongs to.
  110447. */
  110448. scene: Scene;
  110449. /**
  110450. * Creates a new instance of the component for the given scene
  110451. * @param scene Defines the scene to register the component in
  110452. */
  110453. constructor(scene: Scene);
  110454. /**
  110455. * Registers the component in a given scene
  110456. */
  110457. register(): void;
  110458. /**
  110459. * Rebuilds the elements related to this component in case of
  110460. * context lost for instance.
  110461. */
  110462. rebuild(): void;
  110463. /**
  110464. * Disposes the component and the associated ressources
  110465. */
  110466. dispose(): void;
  110467. private _gatherRenderTargets;
  110468. }
  110469. }
  110470. declare module BABYLON {
  110471. /** @hidden */
  110472. export var motionBlurPixelShader: {
  110473. name: string;
  110474. shader: string;
  110475. };
  110476. }
  110477. declare module BABYLON {
  110478. /**
  110479. * The Motion Blur Post Process which blurs an image based on the objects velocity in scene.
  110480. * Velocity can be affected by each object's rotation, position and scale depending on the transformation speed.
  110481. * As an example, all you have to do is to create the post-process:
  110482. * var mb = new BABYLON.MotionBlurPostProcess(
  110483. * 'mb', // The name of the effect.
  110484. * scene, // The scene containing the objects to blur according to their velocity.
  110485. * 1.0, // The required width/height ratio to downsize to before computing the render pass.
  110486. * camera // The camera to apply the render pass to.
  110487. * );
  110488. * Then, all objects moving, rotating and/or scaling will be blurred depending on the transformation speed.
  110489. */
  110490. export class MotionBlurPostProcess extends PostProcess {
  110491. /**
  110492. * Defines how much the image is blurred by the movement. Default value is equal to 1
  110493. */
  110494. motionStrength: number;
  110495. /**
  110496. * Gets the number of iterations are used for motion blur quality. Default value is equal to 32
  110497. */
  110498. /**
  110499. * Sets the number of iterations to be used for motion blur quality
  110500. */
  110501. motionBlurSamples: number;
  110502. private _motionBlurSamples;
  110503. private _geometryBufferRenderer;
  110504. /**
  110505. * Creates a new instance MotionBlurPostProcess
  110506. * @param name The name of the effect.
  110507. * @param scene The scene containing the objects to blur according to their velocity.
  110508. * @param options The required width/height ratio to downsize to before computing the render pass.
  110509. * @param camera The camera to apply the render pass to.
  110510. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  110511. * @param engine The engine which the post process will be applied. (default: current engine)
  110512. * @param reusable If the post process can be reused on the same frame. (default: false)
  110513. * @param textureType Type of textures used when performing the post process. (default: 0)
  110514. * @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)
  110515. */
  110516. constructor(name: string, scene: Scene, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  110517. /**
  110518. * Disposes the post process.
  110519. * @param camera The camera to dispose the post process on.
  110520. */
  110521. dispose(camera?: Camera): void;
  110522. }
  110523. }
  110524. declare module BABYLON {
  110525. /** @hidden */
  110526. export var refractionPixelShader: {
  110527. name: string;
  110528. shader: string;
  110529. };
  110530. }
  110531. declare module BABYLON {
  110532. /**
  110533. * Post process which applies a refractin texture
  110534. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  110535. */
  110536. export class RefractionPostProcess extends PostProcess {
  110537. /** the base color of the refraction (used to taint the rendering) */
  110538. color: Color3;
  110539. /** simulated refraction depth */
  110540. depth: number;
  110541. /** the coefficient of the base color (0 to remove base color tainting) */
  110542. colorLevel: number;
  110543. private _refTexture;
  110544. private _ownRefractionTexture;
  110545. /**
  110546. * Gets or sets the refraction texture
  110547. * Please note that you are responsible for disposing the texture if you set it manually
  110548. */
  110549. refractionTexture: Texture;
  110550. /**
  110551. * Initializes the RefractionPostProcess
  110552. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  110553. * @param name The name of the effect.
  110554. * @param refractionTextureUrl Url of the refraction texture to use
  110555. * @param color the base color of the refraction (used to taint the rendering)
  110556. * @param depth simulated refraction depth
  110557. * @param colorLevel the coefficient of the base color (0 to remove base color tainting)
  110558. * @param camera The camera to apply the render pass to.
  110559. * @param options The required width/height ratio to downsize to before computing the render pass.
  110560. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  110561. * @param engine The engine which the post process will be applied. (default: current engine)
  110562. * @param reusable If the post process can be reused on the same frame. (default: false)
  110563. */
  110564. constructor(name: string, refractionTextureUrl: string,
  110565. /** the base color of the refraction (used to taint the rendering) */
  110566. color: Color3,
  110567. /** simulated refraction depth */
  110568. depth: number,
  110569. /** the coefficient of the base color (0 to remove base color tainting) */
  110570. colorLevel: number, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  110571. /**
  110572. * Disposes of the post process
  110573. * @param camera Camera to dispose post process on
  110574. */
  110575. dispose(camera: Camera): void;
  110576. }
  110577. }
  110578. declare module BABYLON {
  110579. /** @hidden */
  110580. export var sharpenPixelShader: {
  110581. name: string;
  110582. shader: string;
  110583. };
  110584. }
  110585. declare module BABYLON {
  110586. /**
  110587. * The SharpenPostProcess applies a sharpen kernel to every pixel
  110588. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  110589. */
  110590. export class SharpenPostProcess extends PostProcess {
  110591. /**
  110592. * How much of the original color should be applied. Setting this to 0 will display edge detection. (default: 1)
  110593. */
  110594. colorAmount: number;
  110595. /**
  110596. * How much sharpness should be applied (default: 0.3)
  110597. */
  110598. edgeAmount: number;
  110599. /**
  110600. * Creates a new instance ConvolutionPostProcess
  110601. * @param name The name of the effect.
  110602. * @param options The required width/height ratio to downsize to before computing the render pass.
  110603. * @param camera The camera to apply the render pass to.
  110604. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  110605. * @param engine The engine which the post process will be applied. (default: current engine)
  110606. * @param reusable If the post process can be reused on the same frame. (default: false)
  110607. * @param textureType Type of textures used when performing the post process. (default: 0)
  110608. * @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)
  110609. */
  110610. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  110611. }
  110612. }
  110613. declare module BABYLON {
  110614. /**
  110615. * PostProcessRenderPipeline
  110616. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  110617. */
  110618. export class PostProcessRenderPipeline {
  110619. private engine;
  110620. private _renderEffects;
  110621. private _renderEffectsForIsolatedPass;
  110622. /**
  110623. * List of inspectable custom properties (used by the Inspector)
  110624. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  110625. */
  110626. inspectableCustomProperties: IInspectable[];
  110627. /**
  110628. * @hidden
  110629. */
  110630. protected _cameras: Camera[];
  110631. /** @hidden */
  110632. _name: string;
  110633. /**
  110634. * Gets pipeline name
  110635. */
  110636. readonly name: string;
  110637. /**
  110638. * Initializes a PostProcessRenderPipeline
  110639. * @param engine engine to add the pipeline to
  110640. * @param name name of the pipeline
  110641. */
  110642. constructor(engine: Engine, name: string);
  110643. /**
  110644. * Gets the class name
  110645. * @returns "PostProcessRenderPipeline"
  110646. */
  110647. getClassName(): string;
  110648. /**
  110649. * If all the render effects in the pipeline are supported
  110650. */
  110651. readonly isSupported: boolean;
  110652. /**
  110653. * Adds an effect to the pipeline
  110654. * @param renderEffect the effect to add
  110655. */
  110656. addEffect(renderEffect: PostProcessRenderEffect): void;
  110657. /** @hidden */
  110658. _rebuild(): void;
  110659. /** @hidden */
  110660. _enableEffect(renderEffectName: string, cameras: Camera): void;
  110661. /** @hidden */
  110662. _enableEffect(renderEffectName: string, cameras: Camera[]): void;
  110663. /** @hidden */
  110664. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  110665. /** @hidden */
  110666. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  110667. /** @hidden */
  110668. _attachCameras(cameras: Camera, unique: boolean): void;
  110669. /** @hidden */
  110670. _attachCameras(cameras: Camera[], unique: boolean): void;
  110671. /** @hidden */
  110672. _detachCameras(cameras: Camera): void;
  110673. /** @hidden */
  110674. _detachCameras(cameras: Nullable<Camera[]>): void;
  110675. /** @hidden */
  110676. _update(): void;
  110677. /** @hidden */
  110678. _reset(): void;
  110679. protected _enableMSAAOnFirstPostProcess(sampleCount: number): boolean;
  110680. /**
  110681. * Disposes of the pipeline
  110682. */
  110683. dispose(): void;
  110684. }
  110685. }
  110686. declare module BABYLON {
  110687. /**
  110688. * PostProcessRenderPipelineManager class
  110689. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  110690. */
  110691. export class PostProcessRenderPipelineManager {
  110692. private _renderPipelines;
  110693. /**
  110694. * Initializes a PostProcessRenderPipelineManager
  110695. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  110696. */
  110697. constructor();
  110698. /**
  110699. * Gets the list of supported render pipelines
  110700. */
  110701. readonly supportedPipelines: PostProcessRenderPipeline[];
  110702. /**
  110703. * Adds a pipeline to the manager
  110704. * @param renderPipeline The pipeline to add
  110705. */
  110706. addPipeline(renderPipeline: PostProcessRenderPipeline): void;
  110707. /**
  110708. * Attaches a camera to the pipeline
  110709. * @param renderPipelineName The name of the pipeline to attach to
  110710. * @param cameras the camera to attach
  110711. * @param unique if the camera can be attached multiple times to the pipeline
  110712. */
  110713. attachCamerasToRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera, unique?: boolean): void;
  110714. /**
  110715. * Detaches a camera from the pipeline
  110716. * @param renderPipelineName The name of the pipeline to detach from
  110717. * @param cameras the camera to detach
  110718. */
  110719. detachCamerasFromRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera): void;
  110720. /**
  110721. * Enables an effect by name on a pipeline
  110722. * @param renderPipelineName the name of the pipeline to enable the effect in
  110723. * @param renderEffectName the name of the effect to enable
  110724. * @param cameras the cameras that the effect should be enabled on
  110725. */
  110726. enableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  110727. /**
  110728. * Disables an effect by name on a pipeline
  110729. * @param renderPipelineName the name of the pipeline to disable the effect in
  110730. * @param renderEffectName the name of the effect to disable
  110731. * @param cameras the cameras that the effect should be disabled on
  110732. */
  110733. disableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  110734. /**
  110735. * Updates the state of all contained render pipelines and disposes of any non supported pipelines
  110736. */
  110737. update(): void;
  110738. /** @hidden */
  110739. _rebuild(): void;
  110740. /**
  110741. * Disposes of the manager and pipelines
  110742. */
  110743. dispose(): void;
  110744. }
  110745. }
  110746. declare module BABYLON {
  110747. interface Scene {
  110748. /** @hidden (Backing field) */
  110749. _postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  110750. /**
  110751. * Gets the postprocess render pipeline manager
  110752. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  110753. * @see http://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  110754. */
  110755. readonly postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  110756. }
  110757. /**
  110758. * Defines the Render Pipeline scene component responsible to rendering pipelines
  110759. */
  110760. export class PostProcessRenderPipelineManagerSceneComponent implements ISceneComponent {
  110761. /**
  110762. * The component name helpfull to identify the component in the list of scene components.
  110763. */
  110764. readonly name: string;
  110765. /**
  110766. * The scene the component belongs to.
  110767. */
  110768. scene: Scene;
  110769. /**
  110770. * Creates a new instance of the component for the given scene
  110771. * @param scene Defines the scene to register the component in
  110772. */
  110773. constructor(scene: Scene);
  110774. /**
  110775. * Registers the component in a given scene
  110776. */
  110777. register(): void;
  110778. /**
  110779. * Rebuilds the elements related to this component in case of
  110780. * context lost for instance.
  110781. */
  110782. rebuild(): void;
  110783. /**
  110784. * Disposes the component and the associated ressources
  110785. */
  110786. dispose(): void;
  110787. private _gatherRenderTargets;
  110788. }
  110789. }
  110790. declare module BABYLON {
  110791. /**
  110792. * The default rendering pipeline can be added to a scene to apply common post processing effects such as anti-aliasing or depth of field.
  110793. * See https://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  110794. */
  110795. export class DefaultRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  110796. private _scene;
  110797. private _camerasToBeAttached;
  110798. /**
  110799. * ID of the sharpen post process,
  110800. */
  110801. private readonly SharpenPostProcessId;
  110802. /**
  110803. * @ignore
  110804. * ID of the image processing post process;
  110805. */
  110806. readonly ImageProcessingPostProcessId: string;
  110807. /**
  110808. * @ignore
  110809. * ID of the Fast Approximate Anti-Aliasing post process;
  110810. */
  110811. readonly FxaaPostProcessId: string;
  110812. /**
  110813. * ID of the chromatic aberration post process,
  110814. */
  110815. private readonly ChromaticAberrationPostProcessId;
  110816. /**
  110817. * ID of the grain post process
  110818. */
  110819. private readonly GrainPostProcessId;
  110820. /**
  110821. * Sharpen post process which will apply a sharpen convolution to enhance edges
  110822. */
  110823. sharpen: SharpenPostProcess;
  110824. private _sharpenEffect;
  110825. private bloom;
  110826. /**
  110827. * Depth of field effect, applies a blur based on how far away objects are from the focus distance.
  110828. */
  110829. depthOfField: DepthOfFieldEffect;
  110830. /**
  110831. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  110832. */
  110833. fxaa: FxaaPostProcess;
  110834. /**
  110835. * Image post processing pass used to perform operations such as tone mapping or color grading.
  110836. */
  110837. imageProcessing: ImageProcessingPostProcess;
  110838. /**
  110839. * Chromatic aberration post process which will shift rgb colors in the image
  110840. */
  110841. chromaticAberration: ChromaticAberrationPostProcess;
  110842. private _chromaticAberrationEffect;
  110843. /**
  110844. * Grain post process which add noise to the image
  110845. */
  110846. grain: GrainPostProcess;
  110847. private _grainEffect;
  110848. /**
  110849. * Glow post process which adds a glow to emissive areas of the image
  110850. */
  110851. private _glowLayer;
  110852. /**
  110853. * Animations which can be used to tweak settings over a period of time
  110854. */
  110855. animations: Animation[];
  110856. private _imageProcessingConfigurationObserver;
  110857. private _sharpenEnabled;
  110858. private _bloomEnabled;
  110859. private _depthOfFieldEnabled;
  110860. private _depthOfFieldBlurLevel;
  110861. private _fxaaEnabled;
  110862. private _imageProcessingEnabled;
  110863. private _defaultPipelineTextureType;
  110864. private _bloomScale;
  110865. private _chromaticAberrationEnabled;
  110866. private _grainEnabled;
  110867. private _buildAllowed;
  110868. /**
  110869. * Gets active scene
  110870. */
  110871. readonly scene: Scene;
  110872. /**
  110873. * Enable or disable the sharpen process from the pipeline
  110874. */
  110875. sharpenEnabled: boolean;
  110876. private _resizeObserver;
  110877. private _hardwareScaleLevel;
  110878. private _bloomKernel;
  110879. /**
  110880. * Specifies the size of the bloom blur kernel, relative to the final output size
  110881. */
  110882. bloomKernel: number;
  110883. /**
  110884. * Specifies the weight of the bloom in the final rendering
  110885. */
  110886. private _bloomWeight;
  110887. /**
  110888. * Specifies the luma threshold for the area that will be blurred by the bloom
  110889. */
  110890. private _bloomThreshold;
  110891. private _hdr;
  110892. /**
  110893. * The strength of the bloom.
  110894. */
  110895. bloomWeight: number;
  110896. /**
  110897. * The strength of the bloom.
  110898. */
  110899. bloomThreshold: number;
  110900. /**
  110901. * The scale of the bloom, lower value will provide better performance.
  110902. */
  110903. bloomScale: number;
  110904. /**
  110905. * Enable or disable the bloom from the pipeline
  110906. */
  110907. bloomEnabled: boolean;
  110908. private _rebuildBloom;
  110909. /**
  110910. * If the depth of field is enabled.
  110911. */
  110912. depthOfFieldEnabled: boolean;
  110913. /**
  110914. * Blur level of the depth of field effect. (Higher blur will effect performance)
  110915. */
  110916. depthOfFieldBlurLevel: DepthOfFieldEffectBlurLevel;
  110917. /**
  110918. * If the anti aliasing is enabled.
  110919. */
  110920. fxaaEnabled: boolean;
  110921. private _samples;
  110922. /**
  110923. * MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  110924. */
  110925. samples: number;
  110926. /**
  110927. * If image processing is enabled.
  110928. */
  110929. imageProcessingEnabled: boolean;
  110930. /**
  110931. * If glow layer is enabled. (Adds a glow effect to emmissive materials)
  110932. */
  110933. glowLayerEnabled: boolean;
  110934. /**
  110935. * Enable or disable the chromaticAberration process from the pipeline
  110936. */
  110937. chromaticAberrationEnabled: boolean;
  110938. /**
  110939. * Enable or disable the grain process from the pipeline
  110940. */
  110941. grainEnabled: boolean;
  110942. /**
  110943. * @constructor
  110944. * @param name - The rendering pipeline name (default: "")
  110945. * @param hdr - If high dynamic range textures should be used (default: true)
  110946. * @param scene - The scene linked to this pipeline (default: the last created scene)
  110947. * @param cameras - The array of cameras that the rendering pipeline will be attached to (default: scene.cameras)
  110948. * @param automaticBuild - if false, you will have to manually call prepare() to update the pipeline (default: true)
  110949. */
  110950. constructor(name?: string, hdr?: boolean, scene?: Scene, cameras?: Camera[], automaticBuild?: boolean);
  110951. /**
  110952. * Get the class name
  110953. * @returns "DefaultRenderingPipeline"
  110954. */
  110955. getClassName(): string;
  110956. /**
  110957. * Force the compilation of the entire pipeline.
  110958. */
  110959. prepare(): void;
  110960. private _hasCleared;
  110961. private _prevPostProcess;
  110962. private _prevPrevPostProcess;
  110963. private _setAutoClearAndTextureSharing;
  110964. private _depthOfFieldSceneObserver;
  110965. private _buildPipeline;
  110966. private _disposePostProcesses;
  110967. /**
  110968. * Adds a camera to the pipeline
  110969. * @param camera the camera to be added
  110970. */
  110971. addCamera(camera: Camera): void;
  110972. /**
  110973. * Removes a camera from the pipeline
  110974. * @param camera the camera to remove
  110975. */
  110976. removeCamera(camera: Camera): void;
  110977. /**
  110978. * Dispose of the pipeline and stop all post processes
  110979. */
  110980. dispose(): void;
  110981. /**
  110982. * Serialize the rendering pipeline (Used when exporting)
  110983. * @returns the serialized object
  110984. */
  110985. serialize(): any;
  110986. /**
  110987. * Parse the serialized pipeline
  110988. * @param source Source pipeline.
  110989. * @param scene The scene to load the pipeline to.
  110990. * @param rootUrl The URL of the serialized pipeline.
  110991. * @returns An instantiated pipeline from the serialized object.
  110992. */
  110993. static Parse(source: any, scene: Scene, rootUrl: string): DefaultRenderingPipeline;
  110994. }
  110995. }
  110996. declare module BABYLON {
  110997. /** @hidden */
  110998. export var lensHighlightsPixelShader: {
  110999. name: string;
  111000. shader: string;
  111001. };
  111002. }
  111003. declare module BABYLON {
  111004. /** @hidden */
  111005. export var depthOfFieldPixelShader: {
  111006. name: string;
  111007. shader: string;
  111008. };
  111009. }
  111010. declare module BABYLON {
  111011. /**
  111012. * BABYLON.JS Chromatic Aberration GLSL Shader
  111013. * Author: Olivier Guyot
  111014. * Separates very slightly R, G and B colors on the edges of the screen
  111015. * Inspired by Francois Tarlier & Martins Upitis
  111016. */
  111017. export class LensRenderingPipeline extends PostProcessRenderPipeline {
  111018. /**
  111019. * @ignore
  111020. * The chromatic aberration PostProcess id in the pipeline
  111021. */
  111022. LensChromaticAberrationEffect: string;
  111023. /**
  111024. * @ignore
  111025. * The highlights enhancing PostProcess id in the pipeline
  111026. */
  111027. HighlightsEnhancingEffect: string;
  111028. /**
  111029. * @ignore
  111030. * The depth-of-field PostProcess id in the pipeline
  111031. */
  111032. LensDepthOfFieldEffect: string;
  111033. private _scene;
  111034. private _depthTexture;
  111035. private _grainTexture;
  111036. private _chromaticAberrationPostProcess;
  111037. private _highlightsPostProcess;
  111038. private _depthOfFieldPostProcess;
  111039. private _edgeBlur;
  111040. private _grainAmount;
  111041. private _chromaticAberration;
  111042. private _distortion;
  111043. private _highlightsGain;
  111044. private _highlightsThreshold;
  111045. private _dofDistance;
  111046. private _dofAperture;
  111047. private _dofDarken;
  111048. private _dofPentagon;
  111049. private _blurNoise;
  111050. /**
  111051. * @constructor
  111052. *
  111053. * Effect parameters are as follow:
  111054. * {
  111055. * chromatic_aberration: number; // from 0 to x (1 for realism)
  111056. * edge_blur: number; // from 0 to x (1 for realism)
  111057. * distortion: number; // from 0 to x (1 for realism)
  111058. * grain_amount: number; // from 0 to 1
  111059. * grain_texture: BABYLON.Texture; // texture to use for grain effect; if unset, use random B&W noise
  111060. * dof_focus_distance: number; // depth-of-field: focus distance; unset to disable (disabled by default)
  111061. * dof_aperture: number; // depth-of-field: focus blur bias (default: 1)
  111062. * dof_darken: number; // depth-of-field: darken that which is out of focus (from 0 to 1, disabled by default)
  111063. * dof_pentagon: boolean; // depth-of-field: makes a pentagon-like "bokeh" effect
  111064. * dof_gain: number; // depth-of-field: highlights gain; unset to disable (disabled by default)
  111065. * dof_threshold: number; // depth-of-field: highlights threshold (default: 1)
  111066. * blur_noise: boolean; // add a little bit of noise to the blur (default: true)
  111067. * }
  111068. * Note: if an effect parameter is unset, effect is disabled
  111069. *
  111070. * @param name The rendering pipeline name
  111071. * @param parameters - An object containing all parameters (see above)
  111072. * @param scene The scene linked to this pipeline
  111073. * @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)
  111074. * @param cameras The array of cameras that the rendering pipeline will be attached to
  111075. */
  111076. constructor(name: string, parameters: any, scene: Scene, ratio?: number, cameras?: Camera[]);
  111077. /**
  111078. * Get the class name
  111079. * @returns "LensRenderingPipeline"
  111080. */
  111081. getClassName(): string;
  111082. /**
  111083. * Gets associated scene
  111084. */
  111085. readonly scene: Scene;
  111086. /**
  111087. * Gets or sets the edge blur
  111088. */
  111089. edgeBlur: number;
  111090. /**
  111091. * Gets or sets the grain amount
  111092. */
  111093. grainAmount: number;
  111094. /**
  111095. * Gets or sets the chromatic aberration amount
  111096. */
  111097. chromaticAberration: number;
  111098. /**
  111099. * Gets or sets the depth of field aperture
  111100. */
  111101. dofAperture: number;
  111102. /**
  111103. * Gets or sets the edge distortion
  111104. */
  111105. edgeDistortion: number;
  111106. /**
  111107. * Gets or sets the depth of field distortion
  111108. */
  111109. dofDistortion: number;
  111110. /**
  111111. * Gets or sets the darken out of focus amount
  111112. */
  111113. darkenOutOfFocus: number;
  111114. /**
  111115. * Gets or sets a boolean indicating if blur noise is enabled
  111116. */
  111117. blurNoise: boolean;
  111118. /**
  111119. * Gets or sets a boolean indicating if pentagon bokeh is enabled
  111120. */
  111121. pentagonBokeh: boolean;
  111122. /**
  111123. * Gets or sets the highlight grain amount
  111124. */
  111125. highlightsGain: number;
  111126. /**
  111127. * Gets or sets the highlight threshold
  111128. */
  111129. highlightsThreshold: number;
  111130. /**
  111131. * Sets the amount of blur at the edges
  111132. * @param amount blur amount
  111133. */
  111134. setEdgeBlur(amount: number): void;
  111135. /**
  111136. * Sets edge blur to 0
  111137. */
  111138. disableEdgeBlur(): void;
  111139. /**
  111140. * Sets the amout of grain
  111141. * @param amount Amount of grain
  111142. */
  111143. setGrainAmount(amount: number): void;
  111144. /**
  111145. * Set grain amount to 0
  111146. */
  111147. disableGrain(): void;
  111148. /**
  111149. * Sets the chromatic aberration amount
  111150. * @param amount amount of chromatic aberration
  111151. */
  111152. setChromaticAberration(amount: number): void;
  111153. /**
  111154. * Sets chromatic aberration amount to 0
  111155. */
  111156. disableChromaticAberration(): void;
  111157. /**
  111158. * Sets the EdgeDistortion amount
  111159. * @param amount amount of EdgeDistortion
  111160. */
  111161. setEdgeDistortion(amount: number): void;
  111162. /**
  111163. * Sets edge distortion to 0
  111164. */
  111165. disableEdgeDistortion(): void;
  111166. /**
  111167. * Sets the FocusDistance amount
  111168. * @param amount amount of FocusDistance
  111169. */
  111170. setFocusDistance(amount: number): void;
  111171. /**
  111172. * Disables depth of field
  111173. */
  111174. disableDepthOfField(): void;
  111175. /**
  111176. * Sets the Aperture amount
  111177. * @param amount amount of Aperture
  111178. */
  111179. setAperture(amount: number): void;
  111180. /**
  111181. * Sets the DarkenOutOfFocus amount
  111182. * @param amount amount of DarkenOutOfFocus
  111183. */
  111184. setDarkenOutOfFocus(amount: number): void;
  111185. private _pentagonBokehIsEnabled;
  111186. /**
  111187. * Creates a pentagon bokeh effect
  111188. */
  111189. enablePentagonBokeh(): void;
  111190. /**
  111191. * Disables the pentagon bokeh effect
  111192. */
  111193. disablePentagonBokeh(): void;
  111194. /**
  111195. * Enables noise blur
  111196. */
  111197. enableNoiseBlur(): void;
  111198. /**
  111199. * Disables noise blur
  111200. */
  111201. disableNoiseBlur(): void;
  111202. /**
  111203. * Sets the HighlightsGain amount
  111204. * @param amount amount of HighlightsGain
  111205. */
  111206. setHighlightsGain(amount: number): void;
  111207. /**
  111208. * Sets the HighlightsThreshold amount
  111209. * @param amount amount of HighlightsThreshold
  111210. */
  111211. setHighlightsThreshold(amount: number): void;
  111212. /**
  111213. * Disables highlights
  111214. */
  111215. disableHighlights(): void;
  111216. /**
  111217. * Removes the internal pipeline assets and detaches the pipeline from the scene cameras
  111218. * @param disableDepthRender If the scens depth rendering should be disabled (default: false)
  111219. */
  111220. dispose(disableDepthRender?: boolean): void;
  111221. private _createChromaticAberrationPostProcess;
  111222. private _createHighlightsPostProcess;
  111223. private _createDepthOfFieldPostProcess;
  111224. private _createGrainTexture;
  111225. }
  111226. }
  111227. declare module BABYLON {
  111228. /** @hidden */
  111229. export var ssao2PixelShader: {
  111230. name: string;
  111231. shader: string;
  111232. };
  111233. }
  111234. declare module BABYLON {
  111235. /** @hidden */
  111236. export var ssaoCombinePixelShader: {
  111237. name: string;
  111238. shader: string;
  111239. };
  111240. }
  111241. declare module BABYLON {
  111242. /**
  111243. * Render pipeline to produce ssao effect
  111244. */
  111245. export class SSAO2RenderingPipeline extends PostProcessRenderPipeline {
  111246. /**
  111247. * @ignore
  111248. * The PassPostProcess id in the pipeline that contains the original scene color
  111249. */
  111250. SSAOOriginalSceneColorEffect: string;
  111251. /**
  111252. * @ignore
  111253. * The SSAO PostProcess id in the pipeline
  111254. */
  111255. SSAORenderEffect: string;
  111256. /**
  111257. * @ignore
  111258. * The horizontal blur PostProcess id in the pipeline
  111259. */
  111260. SSAOBlurHRenderEffect: string;
  111261. /**
  111262. * @ignore
  111263. * The vertical blur PostProcess id in the pipeline
  111264. */
  111265. SSAOBlurVRenderEffect: string;
  111266. /**
  111267. * @ignore
  111268. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  111269. */
  111270. SSAOCombineRenderEffect: string;
  111271. /**
  111272. * The output strength of the SSAO post-process. Default value is 1.0.
  111273. */
  111274. totalStrength: number;
  111275. /**
  111276. * Maximum depth value to still render AO. A smooth falloff makes the dimming more natural, so there will be no abrupt shading change.
  111277. */
  111278. maxZ: number;
  111279. /**
  111280. * In order to save performances, SSAO radius is clamped on close geometry. This ratio changes by how much
  111281. */
  111282. minZAspect: number;
  111283. private _samples;
  111284. /**
  111285. * Number of samples used for the SSAO calculations. Default value is 8
  111286. */
  111287. samples: number;
  111288. private _textureSamples;
  111289. /**
  111290. * Number of samples to use for antialiasing
  111291. */
  111292. textureSamples: number;
  111293. /**
  111294. * Ratio object used for SSAO ratio and blur ratio
  111295. */
  111296. private _ratio;
  111297. /**
  111298. * Dynamically generated sphere sampler.
  111299. */
  111300. private _sampleSphere;
  111301. /**
  111302. * Blur filter offsets
  111303. */
  111304. private _samplerOffsets;
  111305. private _expensiveBlur;
  111306. /**
  111307. * If bilateral blur should be used
  111308. */
  111309. expensiveBlur: boolean;
  111310. /**
  111311. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 2.0
  111312. */
  111313. radius: number;
  111314. /**
  111315. * The base color of the SSAO post-process
  111316. * The final result is "base + ssao" between [0, 1]
  111317. */
  111318. base: number;
  111319. /**
  111320. * Support test.
  111321. */
  111322. static readonly IsSupported: boolean;
  111323. private _scene;
  111324. private _depthTexture;
  111325. private _normalTexture;
  111326. private _randomTexture;
  111327. private _originalColorPostProcess;
  111328. private _ssaoPostProcess;
  111329. private _blurHPostProcess;
  111330. private _blurVPostProcess;
  111331. private _ssaoCombinePostProcess;
  111332. private _firstUpdate;
  111333. /**
  111334. * Gets active scene
  111335. */
  111336. readonly scene: Scene;
  111337. /**
  111338. * @constructor
  111339. * @param name The rendering pipeline name
  111340. * @param scene The scene linked to this pipeline
  111341. * @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 }
  111342. * @param cameras The array of cameras that the rendering pipeline will be attached to
  111343. */
  111344. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[]);
  111345. /**
  111346. * Get the class name
  111347. * @returns "SSAO2RenderingPipeline"
  111348. */
  111349. getClassName(): string;
  111350. /**
  111351. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  111352. */
  111353. dispose(disableGeometryBufferRenderer?: boolean): void;
  111354. private _createBlurPostProcess;
  111355. /** @hidden */
  111356. _rebuild(): void;
  111357. private _bits;
  111358. private _radicalInverse_VdC;
  111359. private _hammersley;
  111360. private _hemisphereSample_uniform;
  111361. private _generateHemisphere;
  111362. private _createSSAOPostProcess;
  111363. private _createSSAOCombinePostProcess;
  111364. private _createRandomTexture;
  111365. /**
  111366. * Serialize the rendering pipeline (Used when exporting)
  111367. * @returns the serialized object
  111368. */
  111369. serialize(): any;
  111370. /**
  111371. * Parse the serialized pipeline
  111372. * @param source Source pipeline.
  111373. * @param scene The scene to load the pipeline to.
  111374. * @param rootUrl The URL of the serialized pipeline.
  111375. * @returns An instantiated pipeline from the serialized object.
  111376. */
  111377. static Parse(source: any, scene: Scene, rootUrl: string): SSAO2RenderingPipeline;
  111378. }
  111379. }
  111380. declare module BABYLON {
  111381. /** @hidden */
  111382. export var ssaoPixelShader: {
  111383. name: string;
  111384. shader: string;
  111385. };
  111386. }
  111387. declare module BABYLON {
  111388. /**
  111389. * Render pipeline to produce ssao effect
  111390. */
  111391. export class SSAORenderingPipeline extends PostProcessRenderPipeline {
  111392. /**
  111393. * @ignore
  111394. * The PassPostProcess id in the pipeline that contains the original scene color
  111395. */
  111396. SSAOOriginalSceneColorEffect: string;
  111397. /**
  111398. * @ignore
  111399. * The SSAO PostProcess id in the pipeline
  111400. */
  111401. SSAORenderEffect: string;
  111402. /**
  111403. * @ignore
  111404. * The horizontal blur PostProcess id in the pipeline
  111405. */
  111406. SSAOBlurHRenderEffect: string;
  111407. /**
  111408. * @ignore
  111409. * The vertical blur PostProcess id in the pipeline
  111410. */
  111411. SSAOBlurVRenderEffect: string;
  111412. /**
  111413. * @ignore
  111414. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  111415. */
  111416. SSAOCombineRenderEffect: string;
  111417. /**
  111418. * The output strength of the SSAO post-process. Default value is 1.0.
  111419. */
  111420. totalStrength: number;
  111421. /**
  111422. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 0.0006
  111423. */
  111424. radius: number;
  111425. /**
  111426. * Related to fallOff, used to interpolate SSAO samples (first interpolate function input) based on the occlusion difference of each pixel
  111427. * Must not be equal to fallOff and superior to fallOff.
  111428. * Default value is 0.0075
  111429. */
  111430. area: number;
  111431. /**
  111432. * Related to area, used to interpolate SSAO samples (second interpolate function input) based on the occlusion difference of each pixel
  111433. * Must not be equal to area and inferior to area.
  111434. * Default value is 0.000001
  111435. */
  111436. fallOff: number;
  111437. /**
  111438. * The base color of the SSAO post-process
  111439. * The final result is "base + ssao" between [0, 1]
  111440. */
  111441. base: number;
  111442. private _scene;
  111443. private _depthTexture;
  111444. private _randomTexture;
  111445. private _originalColorPostProcess;
  111446. private _ssaoPostProcess;
  111447. private _blurHPostProcess;
  111448. private _blurVPostProcess;
  111449. private _ssaoCombinePostProcess;
  111450. private _firstUpdate;
  111451. /**
  111452. * Gets active scene
  111453. */
  111454. readonly scene: Scene;
  111455. /**
  111456. * @constructor
  111457. * @param name - The rendering pipeline name
  111458. * @param scene - The scene linked to this pipeline
  111459. * @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 }
  111460. * @param cameras - The array of cameras that the rendering pipeline will be attached to
  111461. */
  111462. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[]);
  111463. /**
  111464. * Get the class name
  111465. * @returns "SSAORenderingPipeline"
  111466. */
  111467. getClassName(): string;
  111468. /**
  111469. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  111470. */
  111471. dispose(disableDepthRender?: boolean): void;
  111472. private _createBlurPostProcess;
  111473. /** @hidden */
  111474. _rebuild(): void;
  111475. private _createSSAOPostProcess;
  111476. private _createSSAOCombinePostProcess;
  111477. private _createRandomTexture;
  111478. }
  111479. }
  111480. declare module BABYLON {
  111481. /** @hidden */
  111482. export var standardPixelShader: {
  111483. name: string;
  111484. shader: string;
  111485. };
  111486. }
  111487. declare module BABYLON {
  111488. /**
  111489. * Standard rendering pipeline
  111490. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  111491. * @see https://doc.babylonjs.com/how_to/using_standard_rendering_pipeline
  111492. */
  111493. export class StandardRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  111494. /**
  111495. * Public members
  111496. */
  111497. /**
  111498. * Post-process which contains the original scene color before the pipeline applies all the effects
  111499. */
  111500. originalPostProcess: Nullable<PostProcess>;
  111501. /**
  111502. * Post-process used to down scale an image x4
  111503. */
  111504. downSampleX4PostProcess: Nullable<PostProcess>;
  111505. /**
  111506. * Post-process used to calculate the illuminated surfaces controlled by a threshold
  111507. */
  111508. brightPassPostProcess: Nullable<PostProcess>;
  111509. /**
  111510. * Post-process array storing all the horizontal blur post-processes used by the pipeline
  111511. */
  111512. blurHPostProcesses: PostProcess[];
  111513. /**
  111514. * Post-process array storing all the vertical blur post-processes used by the pipeline
  111515. */
  111516. blurVPostProcesses: PostProcess[];
  111517. /**
  111518. * Post-process used to add colors of 2 textures (typically brightness + real scene color)
  111519. */
  111520. textureAdderPostProcess: Nullable<PostProcess>;
  111521. /**
  111522. * Post-process used to create volumetric lighting effect
  111523. */
  111524. volumetricLightPostProcess: Nullable<PostProcess>;
  111525. /**
  111526. * Post-process used to smooth the previous volumetric light post-process on the X axis
  111527. */
  111528. volumetricLightSmoothXPostProcess: Nullable<BlurPostProcess>;
  111529. /**
  111530. * Post-process used to smooth the previous volumetric light post-process on the Y axis
  111531. */
  111532. volumetricLightSmoothYPostProcess: Nullable<BlurPostProcess>;
  111533. /**
  111534. * Post-process used to merge the volumetric light effect and the real scene color
  111535. */
  111536. volumetricLightMergePostProces: Nullable<PostProcess>;
  111537. /**
  111538. * Post-process used to store the final volumetric light post-process (attach/detach for debug purpose)
  111539. */
  111540. volumetricLightFinalPostProcess: Nullable<PostProcess>;
  111541. /**
  111542. * Base post-process used to calculate the average luminance of the final image for HDR
  111543. */
  111544. luminancePostProcess: Nullable<PostProcess>;
  111545. /**
  111546. * Post-processes used to create down sample post-processes in order to get
  111547. * the average luminance of the final image for HDR
  111548. * Array of length "StandardRenderingPipeline.LuminanceSteps"
  111549. */
  111550. luminanceDownSamplePostProcesses: PostProcess[];
  111551. /**
  111552. * Post-process used to create a HDR effect (light adaptation)
  111553. */
  111554. hdrPostProcess: Nullable<PostProcess>;
  111555. /**
  111556. * Post-process used to store the final texture adder post-process (attach/detach for debug purpose)
  111557. */
  111558. textureAdderFinalPostProcess: Nullable<PostProcess>;
  111559. /**
  111560. * Post-process used to store the final lens flare post-process (attach/detach for debug purpose)
  111561. */
  111562. lensFlareFinalPostProcess: Nullable<PostProcess>;
  111563. /**
  111564. * Post-process used to merge the final HDR post-process and the real scene color
  111565. */
  111566. hdrFinalPostProcess: Nullable<PostProcess>;
  111567. /**
  111568. * Post-process used to create a lens flare effect
  111569. */
  111570. lensFlarePostProcess: Nullable<PostProcess>;
  111571. /**
  111572. * Post-process that merges the result of the lens flare post-process and the real scene color
  111573. */
  111574. lensFlareComposePostProcess: Nullable<PostProcess>;
  111575. /**
  111576. * Post-process used to create a motion blur effect
  111577. */
  111578. motionBlurPostProcess: Nullable<PostProcess>;
  111579. /**
  111580. * Post-process used to create a depth of field effect
  111581. */
  111582. depthOfFieldPostProcess: Nullable<PostProcess>;
  111583. /**
  111584. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  111585. */
  111586. fxaaPostProcess: Nullable<FxaaPostProcess>;
  111587. /**
  111588. * Represents the brightness threshold in order to configure the illuminated surfaces
  111589. */
  111590. brightThreshold: number;
  111591. /**
  111592. * Configures the blur intensity used for surexposed surfaces are highlighted surfaces (light halo)
  111593. */
  111594. blurWidth: number;
  111595. /**
  111596. * Sets if the blur for highlighted surfaces must be only horizontal
  111597. */
  111598. horizontalBlur: boolean;
  111599. /**
  111600. * Sets the overall exposure used by the pipeline
  111601. */
  111602. exposure: number;
  111603. /**
  111604. * Texture used typically to simulate "dirty" on camera lens
  111605. */
  111606. lensTexture: Nullable<Texture>;
  111607. /**
  111608. * Represents the offset coefficient based on Rayleigh principle. Typically in interval [-0.2, 0.2]
  111609. */
  111610. volumetricLightCoefficient: number;
  111611. /**
  111612. * The overall power of volumetric lights, typically in interval [0, 10] maximum
  111613. */
  111614. volumetricLightPower: number;
  111615. /**
  111616. * Used the set the blur intensity to smooth the volumetric lights
  111617. */
  111618. volumetricLightBlurScale: number;
  111619. /**
  111620. * Light (spot or directional) used to generate the volumetric lights rays
  111621. * The source light must have a shadow generate so the pipeline can get its
  111622. * depth map
  111623. */
  111624. sourceLight: Nullable<SpotLight | DirectionalLight>;
  111625. /**
  111626. * For eye adaptation, represents the minimum luminance the eye can see
  111627. */
  111628. hdrMinimumLuminance: number;
  111629. /**
  111630. * For eye adaptation, represents the decrease luminance speed
  111631. */
  111632. hdrDecreaseRate: number;
  111633. /**
  111634. * For eye adaptation, represents the increase luminance speed
  111635. */
  111636. hdrIncreaseRate: number;
  111637. /**
  111638. * Lens color texture used by the lens flare effect. Mandatory if lens flare effect enabled
  111639. */
  111640. lensColorTexture: Nullable<Texture>;
  111641. /**
  111642. * The overall strengh for the lens flare effect
  111643. */
  111644. lensFlareStrength: number;
  111645. /**
  111646. * Dispersion coefficient for lens flare ghosts
  111647. */
  111648. lensFlareGhostDispersal: number;
  111649. /**
  111650. * Main lens flare halo width
  111651. */
  111652. lensFlareHaloWidth: number;
  111653. /**
  111654. * Based on the lens distortion effect, defines how much the lens flare result
  111655. * is distorted
  111656. */
  111657. lensFlareDistortionStrength: number;
  111658. /**
  111659. * Lens star texture must be used to simulate rays on the flares and is available
  111660. * in the documentation
  111661. */
  111662. lensStarTexture: Nullable<Texture>;
  111663. /**
  111664. * As the "lensTexture" (can be the same texture or different), it is used to apply the lens
  111665. * flare effect by taking account of the dirt texture
  111666. */
  111667. lensFlareDirtTexture: Nullable<Texture>;
  111668. /**
  111669. * Represents the focal length for the depth of field effect
  111670. */
  111671. depthOfFieldDistance: number;
  111672. /**
  111673. * Represents the blur intensity for the blurred part of the depth of field effect
  111674. */
  111675. depthOfFieldBlurWidth: number;
  111676. /**
  111677. * For motion blur, defines how much the image is blurred by the movement
  111678. */
  111679. motionStrength: number;
  111680. /**
  111681. * List of animations for the pipeline (IAnimatable implementation)
  111682. */
  111683. animations: Animation[];
  111684. /**
  111685. * Private members
  111686. */
  111687. private _scene;
  111688. private _currentDepthOfFieldSource;
  111689. private _basePostProcess;
  111690. private _hdrCurrentLuminance;
  111691. private _floatTextureType;
  111692. private _ratio;
  111693. private _bloomEnabled;
  111694. private _depthOfFieldEnabled;
  111695. private _vlsEnabled;
  111696. private _lensFlareEnabled;
  111697. private _hdrEnabled;
  111698. private _motionBlurEnabled;
  111699. private _fxaaEnabled;
  111700. private _motionBlurSamples;
  111701. private _volumetricLightStepsCount;
  111702. private _samples;
  111703. /**
  111704. * @ignore
  111705. * Specifies if the bloom pipeline is enabled
  111706. */
  111707. BloomEnabled: boolean;
  111708. /**
  111709. * @ignore
  111710. * Specifies if the depth of field pipeline is enabed
  111711. */
  111712. DepthOfFieldEnabled: boolean;
  111713. /**
  111714. * @ignore
  111715. * Specifies if the lens flare pipeline is enabed
  111716. */
  111717. LensFlareEnabled: boolean;
  111718. /**
  111719. * @ignore
  111720. * Specifies if the HDR pipeline is enabled
  111721. */
  111722. HDREnabled: boolean;
  111723. /**
  111724. * @ignore
  111725. * Specifies if the volumetric lights scattering effect is enabled
  111726. */
  111727. VLSEnabled: boolean;
  111728. /**
  111729. * @ignore
  111730. * Specifies if the motion blur effect is enabled
  111731. */
  111732. MotionBlurEnabled: boolean;
  111733. /**
  111734. * Specifies if anti-aliasing is enabled
  111735. */
  111736. fxaaEnabled: boolean;
  111737. /**
  111738. * Specifies the number of steps used to calculate the volumetric lights
  111739. * Typically in interval [50, 200]
  111740. */
  111741. volumetricLightStepsCount: number;
  111742. /**
  111743. * Specifies the number of samples used for the motion blur effect
  111744. * Typically in interval [16, 64]
  111745. */
  111746. motionBlurSamples: number;
  111747. /**
  111748. * Specifies MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  111749. */
  111750. samples: number;
  111751. /**
  111752. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  111753. * @constructor
  111754. * @param name The rendering pipeline name
  111755. * @param scene The scene linked to this pipeline
  111756. * @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)
  111757. * @param originalPostProcess the custom original color post-process. Must be "reusable". Can be null.
  111758. * @param cameras The array of cameras that the rendering pipeline will be attached to
  111759. */
  111760. constructor(name: string, scene: Scene, ratio: number, originalPostProcess?: Nullable<PostProcess>, cameras?: Camera[]);
  111761. private _buildPipeline;
  111762. private _createDownSampleX4PostProcess;
  111763. private _createBrightPassPostProcess;
  111764. private _createBlurPostProcesses;
  111765. private _createTextureAdderPostProcess;
  111766. private _createVolumetricLightPostProcess;
  111767. private _createLuminancePostProcesses;
  111768. private _createHdrPostProcess;
  111769. private _createLensFlarePostProcess;
  111770. private _createDepthOfFieldPostProcess;
  111771. private _createMotionBlurPostProcess;
  111772. private _getDepthTexture;
  111773. private _disposePostProcesses;
  111774. /**
  111775. * Dispose of the pipeline and stop all post processes
  111776. */
  111777. dispose(): void;
  111778. /**
  111779. * Serialize the rendering pipeline (Used when exporting)
  111780. * @returns the serialized object
  111781. */
  111782. serialize(): any;
  111783. /**
  111784. * Parse the serialized pipeline
  111785. * @param source Source pipeline.
  111786. * @param scene The scene to load the pipeline to.
  111787. * @param rootUrl The URL of the serialized pipeline.
  111788. * @returns An instantiated pipeline from the serialized object.
  111789. */
  111790. static Parse(source: any, scene: Scene, rootUrl: string): StandardRenderingPipeline;
  111791. /**
  111792. * Luminance steps
  111793. */
  111794. static LuminanceSteps: number;
  111795. }
  111796. }
  111797. declare module BABYLON {
  111798. /** @hidden */
  111799. export var tonemapPixelShader: {
  111800. name: string;
  111801. shader: string;
  111802. };
  111803. }
  111804. declare module BABYLON {
  111805. /** Defines operator used for tonemapping */
  111806. export enum TonemappingOperator {
  111807. /** Hable */
  111808. Hable = 0,
  111809. /** Reinhard */
  111810. Reinhard = 1,
  111811. /** HejiDawson */
  111812. HejiDawson = 2,
  111813. /** Photographic */
  111814. Photographic = 3
  111815. }
  111816. /**
  111817. * Defines a post process to apply tone mapping
  111818. */
  111819. export class TonemapPostProcess extends PostProcess {
  111820. private _operator;
  111821. /** Defines the required exposure adjustement */
  111822. exposureAdjustment: number;
  111823. /**
  111824. * Creates a new TonemapPostProcess
  111825. * @param name defines the name of the postprocess
  111826. * @param _operator defines the operator to use
  111827. * @param exposureAdjustment defines the required exposure adjustement
  111828. * @param camera defines the camera to use (can be null)
  111829. * @param samplingMode defines the required sampling mode (BABYLON.Texture.BILINEAR_SAMPLINGMODE by default)
  111830. * @param engine defines the hosting engine (can be ignore if camera is set)
  111831. * @param textureFormat defines the texture format to use (BABYLON.Engine.TEXTURETYPE_UNSIGNED_INT by default)
  111832. */
  111833. constructor(name: string, _operator: TonemappingOperator,
  111834. /** Defines the required exposure adjustement */
  111835. exposureAdjustment: number, camera: Camera, samplingMode?: number, engine?: Engine, textureFormat?: number);
  111836. }
  111837. }
  111838. declare module BABYLON {
  111839. /** @hidden */
  111840. export var depthVertexShader: {
  111841. name: string;
  111842. shader: string;
  111843. };
  111844. }
  111845. declare module BABYLON {
  111846. /** @hidden */
  111847. export var volumetricLightScatteringPixelShader: {
  111848. name: string;
  111849. shader: string;
  111850. };
  111851. }
  111852. declare module BABYLON {
  111853. /** @hidden */
  111854. export var volumetricLightScatteringPassPixelShader: {
  111855. name: string;
  111856. shader: string;
  111857. };
  111858. }
  111859. declare module BABYLON {
  111860. /**
  111861. * Inspired by http://http.developer.nvidia.com/GPUGems3/gpugems3_ch13.html
  111862. */
  111863. export class VolumetricLightScatteringPostProcess extends PostProcess {
  111864. private _volumetricLightScatteringPass;
  111865. private _volumetricLightScatteringRTT;
  111866. private _viewPort;
  111867. private _screenCoordinates;
  111868. private _cachedDefines;
  111869. /**
  111870. * If not undefined, the mesh position is computed from the attached node position
  111871. */
  111872. attachedNode: {
  111873. position: Vector3;
  111874. };
  111875. /**
  111876. * Custom position of the mesh. Used if "useCustomMeshPosition" is set to "true"
  111877. */
  111878. customMeshPosition: Vector3;
  111879. /**
  111880. * Set if the post-process should use a custom position for the light source (true) or the internal mesh position (false)
  111881. */
  111882. useCustomMeshPosition: boolean;
  111883. /**
  111884. * If the post-process should inverse the light scattering direction
  111885. */
  111886. invert: boolean;
  111887. /**
  111888. * The internal mesh used by the post-process
  111889. */
  111890. mesh: Mesh;
  111891. /**
  111892. * @hidden
  111893. * VolumetricLightScatteringPostProcess.useDiffuseColor is no longer used, use the mesh material directly instead
  111894. */
  111895. useDiffuseColor: boolean;
  111896. /**
  111897. * Array containing the excluded meshes not rendered in the internal pass
  111898. */
  111899. excludedMeshes: AbstractMesh[];
  111900. /**
  111901. * Controls the overall intensity of the post-process
  111902. */
  111903. exposure: number;
  111904. /**
  111905. * Dissipates each sample's contribution in range [0, 1]
  111906. */
  111907. decay: number;
  111908. /**
  111909. * Controls the overall intensity of each sample
  111910. */
  111911. weight: number;
  111912. /**
  111913. * Controls the density of each sample
  111914. */
  111915. density: number;
  111916. /**
  111917. * @constructor
  111918. * @param name The post-process name
  111919. * @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)
  111920. * @param camera The camera that the post-process will be attached to
  111921. * @param mesh The mesh used to create the light scattering
  111922. * @param samples The post-process quality, default 100
  111923. * @param samplingModeThe post-process filtering mode
  111924. * @param engine The babylon engine
  111925. * @param reusable If the post-process is reusable
  111926. * @param scene The constructor needs a scene reference to initialize internal components. If "camera" is null a "scene" must be provided
  111927. */
  111928. constructor(name: string, ratio: any, camera: Camera, mesh?: Mesh, samples?: number, samplingMode?: number, engine?: Engine, reusable?: boolean, scene?: Scene);
  111929. /**
  111930. * Returns the string "VolumetricLightScatteringPostProcess"
  111931. * @returns "VolumetricLightScatteringPostProcess"
  111932. */
  111933. getClassName(): string;
  111934. private _isReady;
  111935. /**
  111936. * Sets the new light position for light scattering effect
  111937. * @param position The new custom light position
  111938. */
  111939. setCustomMeshPosition(position: Vector3): void;
  111940. /**
  111941. * Returns the light position for light scattering effect
  111942. * @return Vector3 The custom light position
  111943. */
  111944. getCustomMeshPosition(): Vector3;
  111945. /**
  111946. * Disposes the internal assets and detaches the post-process from the camera
  111947. */
  111948. dispose(camera: Camera): void;
  111949. /**
  111950. * Returns the render target texture used by the post-process
  111951. * @return the render target texture used by the post-process
  111952. */
  111953. getPass(): RenderTargetTexture;
  111954. private _meshExcluded;
  111955. private _createPass;
  111956. private _updateMeshScreenCoordinates;
  111957. /**
  111958. * Creates a default mesh for the Volumeric Light Scattering post-process
  111959. * @param name The mesh name
  111960. * @param scene The scene where to create the mesh
  111961. * @return the default mesh
  111962. */
  111963. static CreateDefaultMesh(name: string, scene: Scene): Mesh;
  111964. }
  111965. }
  111966. declare module BABYLON {
  111967. interface Scene {
  111968. /** @hidden (Backing field) */
  111969. _boundingBoxRenderer: BoundingBoxRenderer;
  111970. /** @hidden (Backing field) */
  111971. _forceShowBoundingBoxes: boolean;
  111972. /**
  111973. * Gets or sets a boolean indicating if all bounding boxes must be rendered
  111974. */
  111975. forceShowBoundingBoxes: boolean;
  111976. /**
  111977. * Gets the bounding box renderer associated with the scene
  111978. * @returns a BoundingBoxRenderer
  111979. */
  111980. getBoundingBoxRenderer(): BoundingBoxRenderer;
  111981. }
  111982. interface AbstractMesh {
  111983. /** @hidden (Backing field) */
  111984. _showBoundingBox: boolean;
  111985. /**
  111986. * Gets or sets a boolean indicating if the bounding box must be rendered as well (false by default)
  111987. */
  111988. showBoundingBox: boolean;
  111989. }
  111990. /**
  111991. * Component responsible of rendering the bounding box of the meshes in a scene.
  111992. * This is usually used through the mesh.showBoundingBox or the scene.forceShowBoundingBoxes properties
  111993. */
  111994. export class BoundingBoxRenderer implements ISceneComponent {
  111995. /**
  111996. * The component name helpfull to identify the component in the list of scene components.
  111997. */
  111998. readonly name: string;
  111999. /**
  112000. * The scene the component belongs to.
  112001. */
  112002. scene: Scene;
  112003. /**
  112004. * Color of the bounding box lines placed in front of an object
  112005. */
  112006. frontColor: Color3;
  112007. /**
  112008. * Color of the bounding box lines placed behind an object
  112009. */
  112010. backColor: Color3;
  112011. /**
  112012. * Defines if the renderer should show the back lines or not
  112013. */
  112014. showBackLines: boolean;
  112015. /**
  112016. * @hidden
  112017. */
  112018. renderList: SmartArray<BoundingBox>;
  112019. private _colorShader;
  112020. private _vertexBuffers;
  112021. private _indexBuffer;
  112022. /**
  112023. * Instantiates a new bounding box renderer in a scene.
  112024. * @param scene the scene the renderer renders in
  112025. */
  112026. constructor(scene: Scene);
  112027. /**
  112028. * Registers the component in a given scene
  112029. */
  112030. register(): void;
  112031. private _evaluateSubMesh;
  112032. private _activeMesh;
  112033. private _prepareRessources;
  112034. private _createIndexBuffer;
  112035. /**
  112036. * Rebuilds the elements related to this component in case of
  112037. * context lost for instance.
  112038. */
  112039. rebuild(): void;
  112040. /**
  112041. * @hidden
  112042. */
  112043. reset(): void;
  112044. /**
  112045. * Render the bounding boxes of a specific rendering group
  112046. * @param renderingGroupId defines the rendering group to render
  112047. */
  112048. render(renderingGroupId: number): void;
  112049. /**
  112050. * In case of occlusion queries, we can render the occlusion bounding box through this method
  112051. * @param mesh Define the mesh to render the occlusion bounding box for
  112052. */
  112053. renderOcclusionBoundingBox(mesh: AbstractMesh): void;
  112054. /**
  112055. * Dispose and release the resources attached to this renderer.
  112056. */
  112057. dispose(): void;
  112058. }
  112059. }
  112060. declare module BABYLON {
  112061. /** @hidden */
  112062. export var depthPixelShader: {
  112063. name: string;
  112064. shader: string;
  112065. };
  112066. }
  112067. declare module BABYLON {
  112068. /**
  112069. * This represents a depth renderer in Babylon.
  112070. * A depth renderer will render to it's depth map every frame which can be displayed or used in post processing
  112071. */
  112072. export class DepthRenderer {
  112073. private _scene;
  112074. private _depthMap;
  112075. private _effect;
  112076. private _cachedDefines;
  112077. private _camera;
  112078. /**
  112079. * Specifiess that the depth renderer will only be used within
  112080. * the camera it is created for.
  112081. * This can help forcing its rendering during the camera processing.
  112082. */
  112083. useOnlyInActiveCamera: boolean;
  112084. /** @hidden */
  112085. static _SceneComponentInitialization: (scene: Scene) => void;
  112086. /**
  112087. * Instantiates a depth renderer
  112088. * @param scene The scene the renderer belongs to
  112089. * @param type The texture type of the depth map (default: Engine.TEXTURETYPE_FLOAT)
  112090. * @param camera The camera to be used to render the depth map (default: scene's active camera)
  112091. */
  112092. constructor(scene: Scene, type?: number, camera?: Nullable<Camera>);
  112093. /**
  112094. * Creates the depth rendering effect and checks if the effect is ready.
  112095. * @param subMesh The submesh to be used to render the depth map of
  112096. * @param useInstances If multiple world instances should be used
  112097. * @returns if the depth renderer is ready to render the depth map
  112098. */
  112099. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  112100. /**
  112101. * Gets the texture which the depth map will be written to.
  112102. * @returns The depth map texture
  112103. */
  112104. getDepthMap(): RenderTargetTexture;
  112105. /**
  112106. * Disposes of the depth renderer.
  112107. */
  112108. dispose(): void;
  112109. }
  112110. }
  112111. declare module BABYLON {
  112112. interface Scene {
  112113. /** @hidden (Backing field) */
  112114. _depthRenderer: {
  112115. [id: string]: DepthRenderer;
  112116. };
  112117. /**
  112118. * Creates a depth renderer a given camera which contains a depth map which can be used for post processing.
  112119. * @param camera The camera to create the depth renderer on (default: scene's active camera)
  112120. * @returns the created depth renderer
  112121. */
  112122. enableDepthRenderer(camera?: Nullable<Camera>): DepthRenderer;
  112123. /**
  112124. * Disables a depth renderer for a given camera
  112125. * @param camera The camera to disable the depth renderer on (default: scene's active camera)
  112126. */
  112127. disableDepthRenderer(camera?: Nullable<Camera>): void;
  112128. }
  112129. /**
  112130. * Defines the Depth Renderer scene component responsible to manage a depth buffer useful
  112131. * in several rendering techniques.
  112132. */
  112133. export class DepthRendererSceneComponent implements ISceneComponent {
  112134. /**
  112135. * The component name helpfull to identify the component in the list of scene components.
  112136. */
  112137. readonly name: string;
  112138. /**
  112139. * The scene the component belongs to.
  112140. */
  112141. scene: Scene;
  112142. /**
  112143. * Creates a new instance of the component for the given scene
  112144. * @param scene Defines the scene to register the component in
  112145. */
  112146. constructor(scene: Scene);
  112147. /**
  112148. * Registers the component in a given scene
  112149. */
  112150. register(): void;
  112151. /**
  112152. * Rebuilds the elements related to this component in case of
  112153. * context lost for instance.
  112154. */
  112155. rebuild(): void;
  112156. /**
  112157. * Disposes the component and the associated ressources
  112158. */
  112159. dispose(): void;
  112160. private _gatherRenderTargets;
  112161. private _gatherActiveCameraRenderTargets;
  112162. }
  112163. }
  112164. declare module BABYLON {
  112165. /** @hidden */
  112166. export var outlinePixelShader: {
  112167. name: string;
  112168. shader: string;
  112169. };
  112170. }
  112171. declare module BABYLON {
  112172. /** @hidden */
  112173. export var outlineVertexShader: {
  112174. name: string;
  112175. shader: string;
  112176. };
  112177. }
  112178. declare module BABYLON {
  112179. interface Scene {
  112180. /** @hidden */
  112181. _outlineRenderer: OutlineRenderer;
  112182. /**
  112183. * Gets the outline renderer associated with the scene
  112184. * @returns a OutlineRenderer
  112185. */
  112186. getOutlineRenderer(): OutlineRenderer;
  112187. }
  112188. interface AbstractMesh {
  112189. /** @hidden (Backing field) */
  112190. _renderOutline: boolean;
  112191. /**
  112192. * Gets or sets a boolean indicating if the outline must be rendered as well
  112193. * @see https://www.babylonjs-playground.com/#10WJ5S#3
  112194. */
  112195. renderOutline: boolean;
  112196. /** @hidden (Backing field) */
  112197. _renderOverlay: boolean;
  112198. /**
  112199. * Gets or sets a boolean indicating if the overlay must be rendered as well
  112200. * @see https://www.babylonjs-playground.com/#10WJ5S#2
  112201. */
  112202. renderOverlay: boolean;
  112203. }
  112204. /**
  112205. * This class is responsible to draw bothe outline/overlay of meshes.
  112206. * It should not be used directly but through the available method on mesh.
  112207. */
  112208. export class OutlineRenderer implements ISceneComponent {
  112209. /**
  112210. * Stencil value used to avoid outline being seen within the mesh when the mesh is transparent
  112211. */
  112212. private static _StencilReference;
  112213. /**
  112214. * The name of the component. Each component must have a unique name.
  112215. */
  112216. name: string;
  112217. /**
  112218. * The scene the component belongs to.
  112219. */
  112220. scene: Scene;
  112221. /**
  112222. * Defines a zOffset to prevent zFighting between the overlay and the mesh.
  112223. */
  112224. zOffset: number;
  112225. private _engine;
  112226. private _effect;
  112227. private _cachedDefines;
  112228. private _savedDepthWrite;
  112229. /**
  112230. * Instantiates a new outline renderer. (There could be only one per scene).
  112231. * @param scene Defines the scene it belongs to
  112232. */
  112233. constructor(scene: Scene);
  112234. /**
  112235. * Register the component to one instance of a scene.
  112236. */
  112237. register(): void;
  112238. /**
  112239. * Rebuilds the elements related to this component in case of
  112240. * context lost for instance.
  112241. */
  112242. rebuild(): void;
  112243. /**
  112244. * Disposes the component and the associated ressources.
  112245. */
  112246. dispose(): void;
  112247. /**
  112248. * Renders the outline in the canvas.
  112249. * @param subMesh Defines the sumesh to render
  112250. * @param batch Defines the batch of meshes in case of instances
  112251. * @param useOverlay Defines if the rendering is for the overlay or the outline
  112252. */
  112253. render(subMesh: SubMesh, batch: _InstancesBatch, useOverlay?: boolean): void;
  112254. /**
  112255. * Returns whether or not the outline renderer is ready for a given submesh.
  112256. * All the dependencies e.g. submeshes, texture, effect... mus be ready
  112257. * @param subMesh Defines the submesh to check readyness for
  112258. * @param useInstances Defines wheter wee are trying to render instances or not
  112259. * @returns true if ready otherwise false
  112260. */
  112261. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  112262. private _beforeRenderingMesh;
  112263. private _afterRenderingMesh;
  112264. }
  112265. }
  112266. declare module BABYLON {
  112267. /**
  112268. * Defines the list of states available for a task inside a AssetsManager
  112269. */
  112270. export enum AssetTaskState {
  112271. /**
  112272. * Initialization
  112273. */
  112274. INIT = 0,
  112275. /**
  112276. * Running
  112277. */
  112278. RUNNING = 1,
  112279. /**
  112280. * Done
  112281. */
  112282. DONE = 2,
  112283. /**
  112284. * Error
  112285. */
  112286. ERROR = 3
  112287. }
  112288. /**
  112289. * Define an abstract asset task used with a AssetsManager class to load assets into a scene
  112290. */
  112291. export abstract class AbstractAssetTask {
  112292. /**
  112293. * Task name
  112294. */ name: string;
  112295. /**
  112296. * Callback called when the task is successful
  112297. */
  112298. onSuccess: (task: any) => void;
  112299. /**
  112300. * Callback called when the task is not successful
  112301. */
  112302. onError: (task: any, message?: string, exception?: any) => void;
  112303. /**
  112304. * Creates a new AssetsManager
  112305. * @param name defines the name of the task
  112306. */
  112307. constructor(
  112308. /**
  112309. * Task name
  112310. */ name: string);
  112311. private _isCompleted;
  112312. private _taskState;
  112313. private _errorObject;
  112314. /**
  112315. * Get if the task is completed
  112316. */
  112317. readonly isCompleted: boolean;
  112318. /**
  112319. * Gets the current state of the task
  112320. */
  112321. readonly taskState: AssetTaskState;
  112322. /**
  112323. * Gets the current error object (if task is in error)
  112324. */
  112325. readonly errorObject: {
  112326. message?: string;
  112327. exception?: any;
  112328. };
  112329. /**
  112330. * Internal only
  112331. * @hidden
  112332. */
  112333. _setErrorObject(message?: string, exception?: any): void;
  112334. /**
  112335. * Execute the current task
  112336. * @param scene defines the scene where you want your assets to be loaded
  112337. * @param onSuccess is a callback called when the task is successfully executed
  112338. * @param onError is a callback called if an error occurs
  112339. */
  112340. run(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  112341. /**
  112342. * Execute the current task
  112343. * @param scene defines the scene where you want your assets to be loaded
  112344. * @param onSuccess is a callback called when the task is successfully executed
  112345. * @param onError is a callback called if an error occurs
  112346. */
  112347. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  112348. /**
  112349. * Reset will set the task state back to INIT, so the next load call of the assets manager will execute this task again.
  112350. * This can be used with failed tasks that have the reason for failure fixed.
  112351. */
  112352. reset(): void;
  112353. private onErrorCallback;
  112354. private onDoneCallback;
  112355. }
  112356. /**
  112357. * Define the interface used by progress events raised during assets loading
  112358. */
  112359. export interface IAssetsProgressEvent {
  112360. /**
  112361. * Defines the number of remaining tasks to process
  112362. */
  112363. remainingCount: number;
  112364. /**
  112365. * Defines the total number of tasks
  112366. */
  112367. totalCount: number;
  112368. /**
  112369. * Defines the task that was just processed
  112370. */
  112371. task: AbstractAssetTask;
  112372. }
  112373. /**
  112374. * Class used to share progress information about assets loading
  112375. */
  112376. export class AssetsProgressEvent implements IAssetsProgressEvent {
  112377. /**
  112378. * Defines the number of remaining tasks to process
  112379. */
  112380. remainingCount: number;
  112381. /**
  112382. * Defines the total number of tasks
  112383. */
  112384. totalCount: number;
  112385. /**
  112386. * Defines the task that was just processed
  112387. */
  112388. task: AbstractAssetTask;
  112389. /**
  112390. * Creates a AssetsProgressEvent
  112391. * @param remainingCount defines the number of remaining tasks to process
  112392. * @param totalCount defines the total number of tasks
  112393. * @param task defines the task that was just processed
  112394. */
  112395. constructor(remainingCount: number, totalCount: number, task: AbstractAssetTask);
  112396. }
  112397. /**
  112398. * Define a task used by AssetsManager to load meshes
  112399. */
  112400. export class MeshAssetTask extends AbstractAssetTask {
  112401. /**
  112402. * Defines the name of the task
  112403. */
  112404. name: string;
  112405. /**
  112406. * Defines the list of mesh's names you want to load
  112407. */
  112408. meshesNames: any;
  112409. /**
  112410. * Defines the root url to use as a base to load your meshes and associated resources
  112411. */
  112412. rootUrl: string;
  112413. /**
  112414. * Defines the filename of the scene to load from
  112415. */
  112416. sceneFilename: string;
  112417. /**
  112418. * Gets the list of loaded meshes
  112419. */
  112420. loadedMeshes: Array<AbstractMesh>;
  112421. /**
  112422. * Gets the list of loaded particle systems
  112423. */
  112424. loadedParticleSystems: Array<IParticleSystem>;
  112425. /**
  112426. * Gets the list of loaded skeletons
  112427. */
  112428. loadedSkeletons: Array<Skeleton>;
  112429. /**
  112430. * Gets the list of loaded animation groups
  112431. */
  112432. loadedAnimationGroups: Array<AnimationGroup>;
  112433. /**
  112434. * Callback called when the task is successful
  112435. */
  112436. onSuccess: (task: MeshAssetTask) => void;
  112437. /**
  112438. * Callback called when the task is successful
  112439. */
  112440. onError: (task: MeshAssetTask, message?: string, exception?: any) => void;
  112441. /**
  112442. * Creates a new MeshAssetTask
  112443. * @param name defines the name of the task
  112444. * @param meshesNames defines the list of mesh's names you want to load
  112445. * @param rootUrl defines the root url to use as a base to load your meshes and associated resources
  112446. * @param sceneFilename defines the filename of the scene to load from
  112447. */
  112448. constructor(
  112449. /**
  112450. * Defines the name of the task
  112451. */
  112452. name: string,
  112453. /**
  112454. * Defines the list of mesh's names you want to load
  112455. */
  112456. meshesNames: any,
  112457. /**
  112458. * Defines the root url to use as a base to load your meshes and associated resources
  112459. */
  112460. rootUrl: string,
  112461. /**
  112462. * Defines the filename of the scene to load from
  112463. */
  112464. sceneFilename: string);
  112465. /**
  112466. * Execute the current task
  112467. * @param scene defines the scene where you want your assets to be loaded
  112468. * @param onSuccess is a callback called when the task is successfully executed
  112469. * @param onError is a callback called if an error occurs
  112470. */
  112471. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  112472. }
  112473. /**
  112474. * Define a task used by AssetsManager to load text content
  112475. */
  112476. export class TextFileAssetTask extends AbstractAssetTask {
  112477. /**
  112478. * Defines the name of the task
  112479. */
  112480. name: string;
  112481. /**
  112482. * Defines the location of the file to load
  112483. */
  112484. url: string;
  112485. /**
  112486. * Gets the loaded text string
  112487. */
  112488. text: string;
  112489. /**
  112490. * Callback called when the task is successful
  112491. */
  112492. onSuccess: (task: TextFileAssetTask) => void;
  112493. /**
  112494. * Callback called when the task is successful
  112495. */
  112496. onError: (task: TextFileAssetTask, message?: string, exception?: any) => void;
  112497. /**
  112498. * Creates a new TextFileAssetTask object
  112499. * @param name defines the name of the task
  112500. * @param url defines the location of the file to load
  112501. */
  112502. constructor(
  112503. /**
  112504. * Defines the name of the task
  112505. */
  112506. name: string,
  112507. /**
  112508. * Defines the location of the file to load
  112509. */
  112510. url: string);
  112511. /**
  112512. * Execute the current task
  112513. * @param scene defines the scene where you want your assets to be loaded
  112514. * @param onSuccess is a callback called when the task is successfully executed
  112515. * @param onError is a callback called if an error occurs
  112516. */
  112517. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  112518. }
  112519. /**
  112520. * Define a task used by AssetsManager to load binary data
  112521. */
  112522. export class BinaryFileAssetTask extends AbstractAssetTask {
  112523. /**
  112524. * Defines the name of the task
  112525. */
  112526. name: string;
  112527. /**
  112528. * Defines the location of the file to load
  112529. */
  112530. url: string;
  112531. /**
  112532. * Gets the lodaded data (as an array buffer)
  112533. */
  112534. data: ArrayBuffer;
  112535. /**
  112536. * Callback called when the task is successful
  112537. */
  112538. onSuccess: (task: BinaryFileAssetTask) => void;
  112539. /**
  112540. * Callback called when the task is successful
  112541. */
  112542. onError: (task: BinaryFileAssetTask, message?: string, exception?: any) => void;
  112543. /**
  112544. * Creates a new BinaryFileAssetTask object
  112545. * @param name defines the name of the new task
  112546. * @param url defines the location of the file to load
  112547. */
  112548. constructor(
  112549. /**
  112550. * Defines the name of the task
  112551. */
  112552. name: string,
  112553. /**
  112554. * Defines the location of the file to load
  112555. */
  112556. url: string);
  112557. /**
  112558. * Execute the current task
  112559. * @param scene defines the scene where you want your assets to be loaded
  112560. * @param onSuccess is a callback called when the task is successfully executed
  112561. * @param onError is a callback called if an error occurs
  112562. */
  112563. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  112564. }
  112565. /**
  112566. * Define a task used by AssetsManager to load images
  112567. */
  112568. export class ImageAssetTask extends AbstractAssetTask {
  112569. /**
  112570. * Defines the name of the task
  112571. */
  112572. name: string;
  112573. /**
  112574. * Defines the location of the image to load
  112575. */
  112576. url: string;
  112577. /**
  112578. * Gets the loaded images
  112579. */
  112580. image: HTMLImageElement;
  112581. /**
  112582. * Callback called when the task is successful
  112583. */
  112584. onSuccess: (task: ImageAssetTask) => void;
  112585. /**
  112586. * Callback called when the task is successful
  112587. */
  112588. onError: (task: ImageAssetTask, message?: string, exception?: any) => void;
  112589. /**
  112590. * Creates a new ImageAssetTask
  112591. * @param name defines the name of the task
  112592. * @param url defines the location of the image to load
  112593. */
  112594. constructor(
  112595. /**
  112596. * Defines the name of the task
  112597. */
  112598. name: string,
  112599. /**
  112600. * Defines the location of the image to load
  112601. */
  112602. url: string);
  112603. /**
  112604. * Execute the current task
  112605. * @param scene defines the scene where you want your assets to be loaded
  112606. * @param onSuccess is a callback called when the task is successfully executed
  112607. * @param onError is a callback called if an error occurs
  112608. */
  112609. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  112610. }
  112611. /**
  112612. * Defines the interface used by texture loading tasks
  112613. */
  112614. export interface ITextureAssetTask<TEX extends BaseTexture> {
  112615. /**
  112616. * Gets the loaded texture
  112617. */
  112618. texture: TEX;
  112619. }
  112620. /**
  112621. * Define a task used by AssetsManager to load 2D textures
  112622. */
  112623. export class TextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<Texture> {
  112624. /**
  112625. * Defines the name of the task
  112626. */
  112627. name: string;
  112628. /**
  112629. * Defines the location of the file to load
  112630. */
  112631. url: string;
  112632. /**
  112633. * Defines if mipmap should not be generated (default is false)
  112634. */
  112635. noMipmap?: boolean | undefined;
  112636. /**
  112637. * Defines if texture must be inverted on Y axis (default is false)
  112638. */
  112639. invertY?: boolean | undefined;
  112640. /**
  112641. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  112642. */
  112643. samplingMode: number;
  112644. /**
  112645. * Gets the loaded texture
  112646. */
  112647. texture: Texture;
  112648. /**
  112649. * Callback called when the task is successful
  112650. */
  112651. onSuccess: (task: TextureAssetTask) => void;
  112652. /**
  112653. * Callback called when the task is successful
  112654. */
  112655. onError: (task: TextureAssetTask, message?: string, exception?: any) => void;
  112656. /**
  112657. * Creates a new TextureAssetTask object
  112658. * @param name defines the name of the task
  112659. * @param url defines the location of the file to load
  112660. * @param noMipmap defines if mipmap should not be generated (default is false)
  112661. * @param invertY defines if texture must be inverted on Y axis (default is false)
  112662. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  112663. */
  112664. constructor(
  112665. /**
  112666. * Defines the name of the task
  112667. */
  112668. name: string,
  112669. /**
  112670. * Defines the location of the file to load
  112671. */
  112672. url: string,
  112673. /**
  112674. * Defines if mipmap should not be generated (default is false)
  112675. */
  112676. noMipmap?: boolean | undefined,
  112677. /**
  112678. * Defines if texture must be inverted on Y axis (default is false)
  112679. */
  112680. invertY?: boolean | undefined,
  112681. /**
  112682. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  112683. */
  112684. samplingMode?: number);
  112685. /**
  112686. * Execute the current task
  112687. * @param scene defines the scene where you want your assets to be loaded
  112688. * @param onSuccess is a callback called when the task is successfully executed
  112689. * @param onError is a callback called if an error occurs
  112690. */
  112691. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  112692. }
  112693. /**
  112694. * Define a task used by AssetsManager to load cube textures
  112695. */
  112696. export class CubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<CubeTexture> {
  112697. /**
  112698. * Defines the name of the task
  112699. */
  112700. name: string;
  112701. /**
  112702. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  112703. */
  112704. url: string;
  112705. /**
  112706. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  112707. */
  112708. extensions?: string[] | undefined;
  112709. /**
  112710. * Defines if mipmaps should not be generated (default is false)
  112711. */
  112712. noMipmap?: boolean | undefined;
  112713. /**
  112714. * Defines the explicit list of files (undefined by default)
  112715. */
  112716. files?: string[] | undefined;
  112717. /**
  112718. * Gets the loaded texture
  112719. */
  112720. texture: CubeTexture;
  112721. /**
  112722. * Callback called when the task is successful
  112723. */
  112724. onSuccess: (task: CubeTextureAssetTask) => void;
  112725. /**
  112726. * Callback called when the task is successful
  112727. */
  112728. onError: (task: CubeTextureAssetTask, message?: string, exception?: any) => void;
  112729. /**
  112730. * Creates a new CubeTextureAssetTask
  112731. * @param name defines the name of the task
  112732. * @param url defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  112733. * @param extensions defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  112734. * @param noMipmap defines if mipmaps should not be generated (default is false)
  112735. * @param files defines the explicit list of files (undefined by default)
  112736. */
  112737. constructor(
  112738. /**
  112739. * Defines the name of the task
  112740. */
  112741. name: string,
  112742. /**
  112743. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  112744. */
  112745. url: string,
  112746. /**
  112747. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  112748. */
  112749. extensions?: string[] | undefined,
  112750. /**
  112751. * Defines if mipmaps should not be generated (default is false)
  112752. */
  112753. noMipmap?: boolean | undefined,
  112754. /**
  112755. * Defines the explicit list of files (undefined by default)
  112756. */
  112757. files?: string[] | undefined);
  112758. /**
  112759. * Execute the current task
  112760. * @param scene defines the scene where you want your assets to be loaded
  112761. * @param onSuccess is a callback called when the task is successfully executed
  112762. * @param onError is a callback called if an error occurs
  112763. */
  112764. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  112765. }
  112766. /**
  112767. * Define a task used by AssetsManager to load HDR cube textures
  112768. */
  112769. export class HDRCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<HDRCubeTexture> {
  112770. /**
  112771. * Defines the name of the task
  112772. */
  112773. name: string;
  112774. /**
  112775. * Defines the location of the file to load
  112776. */
  112777. url: string;
  112778. /**
  112779. * Defines the desired size (the more it increases the longer the generation will be)
  112780. */
  112781. size: number;
  112782. /**
  112783. * Defines if mipmaps should not be generated (default is false)
  112784. */
  112785. noMipmap: boolean;
  112786. /**
  112787. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  112788. */
  112789. generateHarmonics: boolean;
  112790. /**
  112791. * 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)
  112792. */
  112793. gammaSpace: boolean;
  112794. /**
  112795. * Internal Use Only
  112796. */
  112797. reserved: boolean;
  112798. /**
  112799. * Gets the loaded texture
  112800. */
  112801. texture: HDRCubeTexture;
  112802. /**
  112803. * Callback called when the task is successful
  112804. */
  112805. onSuccess: (task: HDRCubeTextureAssetTask) => void;
  112806. /**
  112807. * Callback called when the task is successful
  112808. */
  112809. onError: (task: HDRCubeTextureAssetTask, message?: string, exception?: any) => void;
  112810. /**
  112811. * Creates a new HDRCubeTextureAssetTask object
  112812. * @param name defines the name of the task
  112813. * @param url defines the location of the file to load
  112814. * @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.
  112815. * @param noMipmap defines if mipmaps should not be generated (default is false)
  112816. * @param generateHarmonics specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  112817. * @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)
  112818. * @param reserved Internal use only
  112819. */
  112820. constructor(
  112821. /**
  112822. * Defines the name of the task
  112823. */
  112824. name: string,
  112825. /**
  112826. * Defines the location of the file to load
  112827. */
  112828. url: string,
  112829. /**
  112830. * Defines the desired size (the more it increases the longer the generation will be)
  112831. */
  112832. size: number,
  112833. /**
  112834. * Defines if mipmaps should not be generated (default is false)
  112835. */
  112836. noMipmap?: boolean,
  112837. /**
  112838. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  112839. */
  112840. generateHarmonics?: boolean,
  112841. /**
  112842. * 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)
  112843. */
  112844. gammaSpace?: boolean,
  112845. /**
  112846. * Internal Use Only
  112847. */
  112848. reserved?: boolean);
  112849. /**
  112850. * Execute the current task
  112851. * @param scene defines the scene where you want your assets to be loaded
  112852. * @param onSuccess is a callback called when the task is successfully executed
  112853. * @param onError is a callback called if an error occurs
  112854. */
  112855. run(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  112856. }
  112857. /**
  112858. * This class can be used to easily import assets into a scene
  112859. * @see http://doc.babylonjs.com/how_to/how_to_use_assetsmanager
  112860. */
  112861. export class AssetsManager {
  112862. private _scene;
  112863. private _isLoading;
  112864. protected _tasks: AbstractAssetTask[];
  112865. protected _waitingTasksCount: number;
  112866. protected _totalTasksCount: number;
  112867. /**
  112868. * Callback called when all tasks are processed
  112869. */
  112870. onFinish: (tasks: AbstractAssetTask[]) => void;
  112871. /**
  112872. * Callback called when a task is successful
  112873. */
  112874. onTaskSuccess: (task: AbstractAssetTask) => void;
  112875. /**
  112876. * Callback called when a task had an error
  112877. */
  112878. onTaskError: (task: AbstractAssetTask) => void;
  112879. /**
  112880. * Callback called when a task is done (whatever the result is)
  112881. */
  112882. onProgress: (remainingCount: number, totalCount: number, task: AbstractAssetTask) => void;
  112883. /**
  112884. * Observable called when all tasks are processed
  112885. */
  112886. onTaskSuccessObservable: Observable<AbstractAssetTask>;
  112887. /**
  112888. * Observable called when a task had an error
  112889. */
  112890. onTaskErrorObservable: Observable<AbstractAssetTask>;
  112891. /**
  112892. * Observable called when all tasks were executed
  112893. */
  112894. onTasksDoneObservable: Observable<AbstractAssetTask[]>;
  112895. /**
  112896. * Observable called when a task is done (whatever the result is)
  112897. */
  112898. onProgressObservable: Observable<IAssetsProgressEvent>;
  112899. /**
  112900. * Gets or sets a boolean defining if the AssetsManager should use the default loading screen
  112901. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  112902. */
  112903. useDefaultLoadingScreen: boolean;
  112904. /**
  112905. * Creates a new AssetsManager
  112906. * @param scene defines the scene to work on
  112907. */
  112908. constructor(scene: Scene);
  112909. /**
  112910. * Add a MeshAssetTask to the list of active tasks
  112911. * @param taskName defines the name of the new task
  112912. * @param meshesNames defines the name of meshes to load
  112913. * @param rootUrl defines the root url to use to locate files
  112914. * @param sceneFilename defines the filename of the scene file
  112915. * @returns a new MeshAssetTask object
  112916. */
  112917. addMeshTask(taskName: string, meshesNames: any, rootUrl: string, sceneFilename: string): MeshAssetTask;
  112918. /**
  112919. * Add a TextFileAssetTask to the list of active tasks
  112920. * @param taskName defines the name of the new task
  112921. * @param url defines the url of the file to load
  112922. * @returns a new TextFileAssetTask object
  112923. */
  112924. addTextFileTask(taskName: string, url: string): TextFileAssetTask;
  112925. /**
  112926. * Add a BinaryFileAssetTask to the list of active tasks
  112927. * @param taskName defines the name of the new task
  112928. * @param url defines the url of the file to load
  112929. * @returns a new BinaryFileAssetTask object
  112930. */
  112931. addBinaryFileTask(taskName: string, url: string): BinaryFileAssetTask;
  112932. /**
  112933. * Add a ImageAssetTask to the list of active tasks
  112934. * @param taskName defines the name of the new task
  112935. * @param url defines the url of the file to load
  112936. * @returns a new ImageAssetTask object
  112937. */
  112938. addImageTask(taskName: string, url: string): ImageAssetTask;
  112939. /**
  112940. * Add a TextureAssetTask to the list of active tasks
  112941. * @param taskName defines the name of the new task
  112942. * @param url defines the url of the file to load
  112943. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  112944. * @param invertY defines if you want to invert Y axis of the loaded texture (false by default)
  112945. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  112946. * @returns a new TextureAssetTask object
  112947. */
  112948. addTextureTask(taskName: string, url: string, noMipmap?: boolean, invertY?: boolean, samplingMode?: number): TextureAssetTask;
  112949. /**
  112950. * Add a CubeTextureAssetTask to the list of active tasks
  112951. * @param taskName defines the name of the new task
  112952. * @param url defines the url of the file to load
  112953. * @param extensions defines the extension to use to load the cube map (can be null)
  112954. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  112955. * @param files defines the list of files to load (can be null)
  112956. * @returns a new CubeTextureAssetTask object
  112957. */
  112958. addCubeTextureTask(taskName: string, url: string, extensions?: string[], noMipmap?: boolean, files?: string[]): CubeTextureAssetTask;
  112959. /**
  112960. *
  112961. * Add a HDRCubeTextureAssetTask to the list of active tasks
  112962. * @param taskName defines the name of the new task
  112963. * @param url defines the url of the file to load
  112964. * @param size defines the size you want for the cubemap (can be null)
  112965. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  112966. * @param generateHarmonics defines if you want to automatically generate (true by default)
  112967. * @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)
  112968. * @param reserved Internal use only
  112969. * @returns a new HDRCubeTextureAssetTask object
  112970. */
  112971. addHDRCubeTextureTask(taskName: string, url: string, size: number, noMipmap?: boolean, generateHarmonics?: boolean, gammaSpace?: boolean, reserved?: boolean): HDRCubeTextureAssetTask;
  112972. /**
  112973. * Remove a task from the assets manager.
  112974. * @param task the task to remove
  112975. */
  112976. removeTask(task: AbstractAssetTask): void;
  112977. private _decreaseWaitingTasksCount;
  112978. private _runTask;
  112979. /**
  112980. * Reset the AssetsManager and remove all tasks
  112981. * @return the current instance of the AssetsManager
  112982. */
  112983. reset(): AssetsManager;
  112984. /**
  112985. * Start the loading process
  112986. * @return the current instance of the AssetsManager
  112987. */
  112988. load(): AssetsManager;
  112989. /**
  112990. * Start the loading process as an async operation
  112991. * @return a promise returning the list of failed tasks
  112992. */
  112993. loadAsync(): Promise<void>;
  112994. }
  112995. }
  112996. declare module BABYLON {
  112997. /**
  112998. * Wrapper class for promise with external resolve and reject.
  112999. */
  113000. export class Deferred<T> {
  113001. /**
  113002. * The promise associated with this deferred object.
  113003. */
  113004. readonly promise: Promise<T>;
  113005. private _resolve;
  113006. private _reject;
  113007. /**
  113008. * The resolve method of the promise associated with this deferred object.
  113009. */
  113010. readonly resolve: (value?: T | PromiseLike<T> | undefined) => void;
  113011. /**
  113012. * The reject method of the promise associated with this deferred object.
  113013. */
  113014. readonly reject: (reason?: any) => void;
  113015. /**
  113016. * Constructor for this deferred object.
  113017. */
  113018. constructor();
  113019. }
  113020. }
  113021. declare module BABYLON {
  113022. /**
  113023. * Class used to explode meshes (ie. to have a center and move them away from that center to better see the overall organization)
  113024. */
  113025. export class MeshExploder {
  113026. private _centerMesh;
  113027. private _meshes;
  113028. private _meshesOrigins;
  113029. private _toCenterVectors;
  113030. private _scaledDirection;
  113031. private _newPosition;
  113032. private _centerPosition;
  113033. /**
  113034. * Explodes meshes from a center mesh.
  113035. * @param meshes The meshes to explode.
  113036. * @param centerMesh The mesh to be center of explosion.
  113037. */
  113038. constructor(meshes: Array<Mesh>, centerMesh?: Mesh);
  113039. private _setCenterMesh;
  113040. /**
  113041. * Get class name
  113042. * @returns "MeshExploder"
  113043. */
  113044. getClassName(): string;
  113045. /**
  113046. * "Exploded meshes"
  113047. * @returns Array of meshes with the centerMesh at index 0.
  113048. */
  113049. getMeshes(): Array<Mesh>;
  113050. /**
  113051. * Explodes meshes giving a specific direction
  113052. * @param direction Number to multiply distance of each mesh's origin from center. Use a negative number to implode, or zero to reset.
  113053. */
  113054. explode(direction?: number): void;
  113055. }
  113056. }
  113057. declare module BABYLON {
  113058. /**
  113059. * Class used to help managing file picking and drag'n'drop
  113060. */
  113061. export class FilesInput {
  113062. /**
  113063. * List of files ready to be loaded
  113064. */
  113065. static readonly FilesToLoad: {
  113066. [key: string]: File;
  113067. };
  113068. /**
  113069. * Callback called when a file is processed
  113070. */
  113071. onProcessFileCallback: (file: File, name: string, extension: string) => true;
  113072. private _engine;
  113073. private _currentScene;
  113074. private _sceneLoadedCallback;
  113075. private _progressCallback;
  113076. private _additionalRenderLoopLogicCallback;
  113077. private _textureLoadingCallback;
  113078. private _startingProcessingFilesCallback;
  113079. private _onReloadCallback;
  113080. private _errorCallback;
  113081. private _elementToMonitor;
  113082. private _sceneFileToLoad;
  113083. private _filesToLoad;
  113084. /**
  113085. * Creates a new FilesInput
  113086. * @param engine defines the rendering engine
  113087. * @param scene defines the hosting scene
  113088. * @param sceneLoadedCallback callback called when scene is loaded
  113089. * @param progressCallback callback called to track progress
  113090. * @param additionalRenderLoopLogicCallback callback called to add user logic to the rendering loop
  113091. * @param textureLoadingCallback callback called when a texture is loading
  113092. * @param startingProcessingFilesCallback callback called when the system is about to process all files
  113093. * @param onReloadCallback callback called when a reload is requested
  113094. * @param errorCallback callback call if an error occurs
  113095. */
  113096. 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);
  113097. private _dragEnterHandler;
  113098. private _dragOverHandler;
  113099. private _dropHandler;
  113100. /**
  113101. * Calls this function to listen to drag'n'drop events on a specific DOM element
  113102. * @param elementToMonitor defines the DOM element to track
  113103. */
  113104. monitorElementForDragNDrop(elementToMonitor: HTMLElement): void;
  113105. /**
  113106. * Release all associated resources
  113107. */
  113108. dispose(): void;
  113109. private renderFunction;
  113110. private drag;
  113111. private drop;
  113112. private _traverseFolder;
  113113. private _processFiles;
  113114. /**
  113115. * Load files from a drop event
  113116. * @param event defines the drop event to use as source
  113117. */
  113118. loadFiles(event: any): void;
  113119. private _processReload;
  113120. /**
  113121. * Reload the current scene from the loaded files
  113122. */
  113123. reload(): void;
  113124. }
  113125. }
  113126. declare module BABYLON {
  113127. /**
  113128. * Defines the root class used to create scene optimization to use with SceneOptimizer
  113129. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  113130. */
  113131. export class SceneOptimization {
  113132. /**
  113133. * Defines the priority of this optimization (0 by default which means first in the list)
  113134. */
  113135. priority: number;
  113136. /**
  113137. * Gets a string describing the action executed by the current optimization
  113138. * @returns description string
  113139. */
  113140. getDescription(): string;
  113141. /**
  113142. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  113143. * @param scene defines the current scene where to apply this optimization
  113144. * @param optimizer defines the current optimizer
  113145. * @returns true if everything that can be done was applied
  113146. */
  113147. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  113148. /**
  113149. * Creates the SceneOptimization object
  113150. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  113151. * @param desc defines the description associated with the optimization
  113152. */
  113153. constructor(
  113154. /**
  113155. * Defines the priority of this optimization (0 by default which means first in the list)
  113156. */
  113157. priority?: number);
  113158. }
  113159. /**
  113160. * Defines an optimization used to reduce the size of render target textures
  113161. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  113162. */
  113163. export class TextureOptimization extends SceneOptimization {
  113164. /**
  113165. * Defines the priority of this optimization (0 by default which means first in the list)
  113166. */
  113167. priority: number;
  113168. /**
  113169. * 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
  113170. */
  113171. maximumSize: number;
  113172. /**
  113173. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  113174. */
  113175. step: number;
  113176. /**
  113177. * Gets a string describing the action executed by the current optimization
  113178. * @returns description string
  113179. */
  113180. getDescription(): string;
  113181. /**
  113182. * Creates the TextureOptimization object
  113183. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  113184. * @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
  113185. * @param step defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  113186. */
  113187. constructor(
  113188. /**
  113189. * Defines the priority of this optimization (0 by default which means first in the list)
  113190. */
  113191. priority?: number,
  113192. /**
  113193. * 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
  113194. */
  113195. maximumSize?: number,
  113196. /**
  113197. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  113198. */
  113199. step?: number);
  113200. /**
  113201. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  113202. * @param scene defines the current scene where to apply this optimization
  113203. * @param optimizer defines the current optimizer
  113204. * @returns true if everything that can be done was applied
  113205. */
  113206. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  113207. }
  113208. /**
  113209. * Defines an optimization used to increase or decrease the rendering resolution
  113210. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  113211. */
  113212. export class HardwareScalingOptimization extends SceneOptimization {
  113213. /**
  113214. * Defines the priority of this optimization (0 by default which means first in the list)
  113215. */
  113216. priority: number;
  113217. /**
  113218. * Defines the maximum scale to use (2 by default)
  113219. */
  113220. maximumScale: number;
  113221. /**
  113222. * Defines the step to use between two passes (0.5 by default)
  113223. */
  113224. step: number;
  113225. private _currentScale;
  113226. private _directionOffset;
  113227. /**
  113228. * Gets a string describing the action executed by the current optimization
  113229. * @return description string
  113230. */
  113231. getDescription(): string;
  113232. /**
  113233. * Creates the HardwareScalingOptimization object
  113234. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  113235. * @param maximumScale defines the maximum scale to use (2 by default)
  113236. * @param step defines the step to use between two passes (0.5 by default)
  113237. */
  113238. constructor(
  113239. /**
  113240. * Defines the priority of this optimization (0 by default which means first in the list)
  113241. */
  113242. priority?: number,
  113243. /**
  113244. * Defines the maximum scale to use (2 by default)
  113245. */
  113246. maximumScale?: number,
  113247. /**
  113248. * Defines the step to use between two passes (0.5 by default)
  113249. */
  113250. step?: number);
  113251. /**
  113252. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  113253. * @param scene defines the current scene where to apply this optimization
  113254. * @param optimizer defines the current optimizer
  113255. * @returns true if everything that can be done was applied
  113256. */
  113257. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  113258. }
  113259. /**
  113260. * Defines an optimization used to remove shadows
  113261. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  113262. */
  113263. export class ShadowsOptimization extends SceneOptimization {
  113264. /**
  113265. * Gets a string describing the action executed by the current optimization
  113266. * @return description string
  113267. */
  113268. getDescription(): string;
  113269. /**
  113270. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  113271. * @param scene defines the current scene where to apply this optimization
  113272. * @param optimizer defines the current optimizer
  113273. * @returns true if everything that can be done was applied
  113274. */
  113275. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  113276. }
  113277. /**
  113278. * Defines an optimization used to turn post-processes off
  113279. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  113280. */
  113281. export class PostProcessesOptimization extends SceneOptimization {
  113282. /**
  113283. * Gets a string describing the action executed by the current optimization
  113284. * @return description string
  113285. */
  113286. getDescription(): string;
  113287. /**
  113288. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  113289. * @param scene defines the current scene where to apply this optimization
  113290. * @param optimizer defines the current optimizer
  113291. * @returns true if everything that can be done was applied
  113292. */
  113293. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  113294. }
  113295. /**
  113296. * Defines an optimization used to turn lens flares off
  113297. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  113298. */
  113299. export class LensFlaresOptimization extends SceneOptimization {
  113300. /**
  113301. * Gets a string describing the action executed by the current optimization
  113302. * @return description string
  113303. */
  113304. getDescription(): string;
  113305. /**
  113306. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  113307. * @param scene defines the current scene where to apply this optimization
  113308. * @param optimizer defines the current optimizer
  113309. * @returns true if everything that can be done was applied
  113310. */
  113311. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  113312. }
  113313. /**
  113314. * Defines an optimization based on user defined callback.
  113315. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  113316. */
  113317. export class CustomOptimization extends SceneOptimization {
  113318. /**
  113319. * Callback called to apply the custom optimization.
  113320. */
  113321. onApply: (scene: Scene, optimizer: SceneOptimizer) => boolean;
  113322. /**
  113323. * Callback called to get custom description
  113324. */
  113325. onGetDescription: () => string;
  113326. /**
  113327. * Gets a string describing the action executed by the current optimization
  113328. * @returns description string
  113329. */
  113330. getDescription(): string;
  113331. /**
  113332. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  113333. * @param scene defines the current scene where to apply this optimization
  113334. * @param optimizer defines the current optimizer
  113335. * @returns true if everything that can be done was applied
  113336. */
  113337. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  113338. }
  113339. /**
  113340. * Defines an optimization used to turn particles off
  113341. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  113342. */
  113343. export class ParticlesOptimization extends SceneOptimization {
  113344. /**
  113345. * Gets a string describing the action executed by the current optimization
  113346. * @return description string
  113347. */
  113348. getDescription(): string;
  113349. /**
  113350. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  113351. * @param scene defines the current scene where to apply this optimization
  113352. * @param optimizer defines the current optimizer
  113353. * @returns true if everything that can be done was applied
  113354. */
  113355. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  113356. }
  113357. /**
  113358. * Defines an optimization used to turn render targets off
  113359. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  113360. */
  113361. export class RenderTargetsOptimization extends SceneOptimization {
  113362. /**
  113363. * Gets a string describing the action executed by the current optimization
  113364. * @return description string
  113365. */
  113366. getDescription(): string;
  113367. /**
  113368. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  113369. * @param scene defines the current scene where to apply this optimization
  113370. * @param optimizer defines the current optimizer
  113371. * @returns true if everything that can be done was applied
  113372. */
  113373. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  113374. }
  113375. /**
  113376. * Defines an optimization used to merge meshes with compatible materials
  113377. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  113378. */
  113379. export class MergeMeshesOptimization extends SceneOptimization {
  113380. private static _UpdateSelectionTree;
  113381. /**
  113382. * Gets or sets a boolean which defines if optimization octree has to be updated
  113383. */
  113384. /**
  113385. * Gets or sets a boolean which defines if optimization octree has to be updated
  113386. */
  113387. static UpdateSelectionTree: boolean;
  113388. /**
  113389. * Gets a string describing the action executed by the current optimization
  113390. * @return description string
  113391. */
  113392. getDescription(): string;
  113393. private _canBeMerged;
  113394. /**
  113395. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  113396. * @param scene defines the current scene where to apply this optimization
  113397. * @param optimizer defines the current optimizer
  113398. * @param updateSelectionTree defines that the selection octree has to be updated (false by default)
  113399. * @returns true if everything that can be done was applied
  113400. */
  113401. apply(scene: Scene, optimizer: SceneOptimizer, updateSelectionTree?: boolean): boolean;
  113402. }
  113403. /**
  113404. * Defines a list of options used by SceneOptimizer
  113405. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  113406. */
  113407. export class SceneOptimizerOptions {
  113408. /**
  113409. * Defines the target frame rate to reach (60 by default)
  113410. */
  113411. targetFrameRate: number;
  113412. /**
  113413. * Defines the interval between two checkes (2000ms by default)
  113414. */
  113415. trackerDuration: number;
  113416. /**
  113417. * Gets the list of optimizations to apply
  113418. */
  113419. optimizations: SceneOptimization[];
  113420. /**
  113421. * Creates a new list of options used by SceneOptimizer
  113422. * @param targetFrameRate defines the target frame rate to reach (60 by default)
  113423. * @param trackerDuration defines the interval between two checkes (2000ms by default)
  113424. */
  113425. constructor(
  113426. /**
  113427. * Defines the target frame rate to reach (60 by default)
  113428. */
  113429. targetFrameRate?: number,
  113430. /**
  113431. * Defines the interval between two checkes (2000ms by default)
  113432. */
  113433. trackerDuration?: number);
  113434. /**
  113435. * Add a new optimization
  113436. * @param optimization defines the SceneOptimization to add to the list of active optimizations
  113437. * @returns the current SceneOptimizerOptions
  113438. */
  113439. addOptimization(optimization: SceneOptimization): SceneOptimizerOptions;
  113440. /**
  113441. * Add a new custom optimization
  113442. * @param onApply defines the callback called to apply the custom optimization (true if everything that can be done was applied)
  113443. * @param onGetDescription defines the callback called to get the description attached with the optimization.
  113444. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  113445. * @returns the current SceneOptimizerOptions
  113446. */
  113447. addCustomOptimization(onApply: (scene: Scene) => boolean, onGetDescription: () => string, priority?: number): SceneOptimizerOptions;
  113448. /**
  113449. * Creates a list of pre-defined optimizations aimed to reduce the visual impact on the scene
  113450. * @param targetFrameRate defines the target frame rate (60 by default)
  113451. * @returns a SceneOptimizerOptions object
  113452. */
  113453. static LowDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  113454. /**
  113455. * Creates a list of pre-defined optimizations aimed to have a moderate impact on the scene visual
  113456. * @param targetFrameRate defines the target frame rate (60 by default)
  113457. * @returns a SceneOptimizerOptions object
  113458. */
  113459. static ModerateDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  113460. /**
  113461. * Creates a list of pre-defined optimizations aimed to have a big impact on the scene visual
  113462. * @param targetFrameRate defines the target frame rate (60 by default)
  113463. * @returns a SceneOptimizerOptions object
  113464. */
  113465. static HighDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  113466. }
  113467. /**
  113468. * Class used to run optimizations in order to reach a target frame rate
  113469. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  113470. */
  113471. export class SceneOptimizer implements IDisposable {
  113472. private _isRunning;
  113473. private _options;
  113474. private _scene;
  113475. private _currentPriorityLevel;
  113476. private _targetFrameRate;
  113477. private _trackerDuration;
  113478. private _currentFrameRate;
  113479. private _sceneDisposeObserver;
  113480. private _improvementMode;
  113481. /**
  113482. * Defines an observable called when the optimizer reaches the target frame rate
  113483. */
  113484. onSuccessObservable: Observable<SceneOptimizer>;
  113485. /**
  113486. * Defines an observable called when the optimizer enables an optimization
  113487. */
  113488. onNewOptimizationAppliedObservable: Observable<SceneOptimization>;
  113489. /**
  113490. * Defines an observable called when the optimizer is not able to reach the target frame rate
  113491. */
  113492. onFailureObservable: Observable<SceneOptimizer>;
  113493. /**
  113494. * Gets a boolean indicating if the optimizer is in improvement mode
  113495. */
  113496. readonly isInImprovementMode: boolean;
  113497. /**
  113498. * Gets the current priority level (0 at start)
  113499. */
  113500. readonly currentPriorityLevel: number;
  113501. /**
  113502. * Gets the current frame rate checked by the SceneOptimizer
  113503. */
  113504. readonly currentFrameRate: number;
  113505. /**
  113506. * Gets or sets the current target frame rate (60 by default)
  113507. */
  113508. /**
  113509. * Gets or sets the current target frame rate (60 by default)
  113510. */
  113511. targetFrameRate: number;
  113512. /**
  113513. * Gets or sets the current interval between two checks (every 2000ms by default)
  113514. */
  113515. /**
  113516. * Gets or sets the current interval between two checks (every 2000ms by default)
  113517. */
  113518. trackerDuration: number;
  113519. /**
  113520. * Gets the list of active optimizations
  113521. */
  113522. readonly optimizations: SceneOptimization[];
  113523. /**
  113524. * Creates a new SceneOptimizer
  113525. * @param scene defines the scene to work on
  113526. * @param options defines the options to use with the SceneOptimizer
  113527. * @param autoGeneratePriorities defines if priorities must be generated and not read from SceneOptimization property (true by default)
  113528. * @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)
  113529. */
  113530. constructor(scene: Scene, options?: SceneOptimizerOptions, autoGeneratePriorities?: boolean, improvementMode?: boolean);
  113531. /**
  113532. * Stops the current optimizer
  113533. */
  113534. stop(): void;
  113535. /**
  113536. * Reset the optimizer to initial step (current priority level = 0)
  113537. */
  113538. reset(): void;
  113539. /**
  113540. * Start the optimizer. By default it will try to reach a specific framerate
  113541. * but if the optimizer is set with improvementMode === true then it will run all optimiatiation while frame rate is above the target frame rate
  113542. */
  113543. start(): void;
  113544. private _checkCurrentState;
  113545. /**
  113546. * Release all resources
  113547. */
  113548. dispose(): void;
  113549. /**
  113550. * Helper function to create a SceneOptimizer with one single line of code
  113551. * @param scene defines the scene to work on
  113552. * @param options defines the options to use with the SceneOptimizer
  113553. * @param onSuccess defines a callback to call on success
  113554. * @param onFailure defines a callback to call on failure
  113555. * @returns the new SceneOptimizer object
  113556. */
  113557. static OptimizeAsync(scene: Scene, options?: SceneOptimizerOptions, onSuccess?: () => void, onFailure?: () => void): SceneOptimizer;
  113558. }
  113559. }
  113560. declare module BABYLON {
  113561. /**
  113562. * Class used to serialize a scene into a string
  113563. */
  113564. export class SceneSerializer {
  113565. /**
  113566. * Clear cache used by a previous serialization
  113567. */
  113568. static ClearCache(): void;
  113569. /**
  113570. * Serialize a scene into a JSON compatible object
  113571. * @param scene defines the scene to serialize
  113572. * @returns a JSON compatible object
  113573. */
  113574. static Serialize(scene: Scene): any;
  113575. /**
  113576. * Serialize a mesh into a JSON compatible object
  113577. * @param toSerialize defines the mesh to serialize
  113578. * @param withParents defines if parents must be serialized as well
  113579. * @param withChildren defines if children must be serialized as well
  113580. * @returns a JSON compatible object
  113581. */
  113582. static SerializeMesh(toSerialize: any, withParents?: boolean, withChildren?: boolean): any;
  113583. }
  113584. }
  113585. declare module BABYLON {
  113586. /**
  113587. * This represents the different options avilable for the video capture.
  113588. */
  113589. export interface VideoRecorderOptions {
  113590. /** Defines the mime type of the video */
  113591. mimeType: string;
  113592. /** Defines the video the video should be recorded at */
  113593. fps: number;
  113594. /** Defines the chunk size for the recording data */
  113595. recordChunckSize: number;
  113596. /** The audio tracks to attach to the record */
  113597. audioTracks?: MediaStreamTrack[];
  113598. }
  113599. /**
  113600. * This can helps recording videos from BabylonJS.
  113601. * This is based on the available WebRTC functionalities of the browser.
  113602. *
  113603. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_video
  113604. */
  113605. export class VideoRecorder {
  113606. private static readonly _defaultOptions;
  113607. /**
  113608. * Returns wehther or not the VideoRecorder is available in your browser.
  113609. * @param engine Defines the Babylon Engine to check the support for
  113610. * @returns true if supported otherwise false
  113611. */
  113612. static IsSupported(engine: Engine): boolean;
  113613. private readonly _options;
  113614. private _canvas;
  113615. private _mediaRecorder;
  113616. private _recordedChunks;
  113617. private _fileName;
  113618. private _resolve;
  113619. private _reject;
  113620. /**
  113621. * True wether a recording is already in progress.
  113622. */
  113623. readonly isRecording: boolean;
  113624. /**
  113625. * Create a new VideoCapture object which can help converting what you see in Babylon to
  113626. * a video file.
  113627. * @param engine Defines the BabylonJS Engine you wish to record
  113628. * @param options Defines options that can be used to customized the capture
  113629. */
  113630. constructor(engine: Engine, options?: Nullable<VideoRecorderOptions>);
  113631. /**
  113632. * Stops the current recording before the default capture timeout passed in the startRecording
  113633. * functions.
  113634. */
  113635. stopRecording(): void;
  113636. /**
  113637. * Starts recording the canvas for a max duration specified in parameters.
  113638. * @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.
  113639. * @param maxDuration Defines the maximum recording time in seconds.
  113640. * It default to 7 seconds. A value of zero will not stop automatically, you would need to call stopRecording manually.
  113641. * @return a promise callback at the end of the recording with the video data in Blob.
  113642. */
  113643. startRecording(fileName?: Nullable<string>, maxDuration?: number): Promise<Blob>;
  113644. /**
  113645. * Releases internal resources used during the recording.
  113646. */
  113647. dispose(): void;
  113648. private _handleDataAvailable;
  113649. private _handleError;
  113650. private _handleStop;
  113651. }
  113652. }
  113653. declare module BABYLON {
  113654. /**
  113655. * Helper class to push actions to a pool of workers.
  113656. */
  113657. export class WorkerPool implements IDisposable {
  113658. private _workerInfos;
  113659. private _pendingActions;
  113660. /**
  113661. * Constructor
  113662. * @param workers Array of workers to use for actions
  113663. */
  113664. constructor(workers: Array<Worker>);
  113665. /**
  113666. * Terminates all workers and clears any pending actions.
  113667. */
  113668. dispose(): void;
  113669. /**
  113670. * Pushes an action to the worker pool. If all the workers are active, the action will be
  113671. * pended until a worker has completed its action.
  113672. * @param action The action to perform. Call onComplete when the action is complete.
  113673. */
  113674. push(action: (worker: Worker, onComplete: () => void) => void): void;
  113675. private _execute;
  113676. }
  113677. }
  113678. declare module BABYLON {
  113679. /**
  113680. * Class containing a set of static utilities functions for screenshots
  113681. */
  113682. export class ScreenshotTools {
  113683. /**
  113684. * Captures a screenshot of the current rendering
  113685. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  113686. * @param engine defines the rendering engine
  113687. * @param camera defines the source camera
  113688. * @param size This parameter can be set to a single number or to an object with the
  113689. * following (optional) properties: precision, width, height. If a single number is passed,
  113690. * it will be used for both width and height. If an object is passed, the screenshot size
  113691. * will be derived from the parameters. The precision property is a multiplier allowing
  113692. * rendering at a higher or lower resolution
  113693. * @param successCallback defines the callback receives a single parameter which contains the
  113694. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  113695. * src parameter of an <img> to display it
  113696. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  113697. * Check your browser for supported MIME types
  113698. */
  113699. static CreateScreenshot(engine: Engine, camera: Camera, size: any, successCallback?: (data: string) => void, mimeType?: string): void;
  113700. /**
  113701. * Generates an image screenshot from the specified camera.
  113702. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  113703. * @param engine The engine to use for rendering
  113704. * @param camera The camera to use for rendering
  113705. * @param size This parameter can be set to a single number or to an object with the
  113706. * following (optional) properties: precision, width, height. If a single number is passed,
  113707. * it will be used for both width and height. If an object is passed, the screenshot size
  113708. * will be derived from the parameters. The precision property is a multiplier allowing
  113709. * rendering at a higher or lower resolution
  113710. * @param successCallback The callback receives a single parameter which contains the
  113711. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  113712. * src parameter of an <img> to display it
  113713. * @param mimeType The MIME type of the screenshot image (default: image/png).
  113714. * Check your browser for supported MIME types
  113715. * @param samples Texture samples (default: 1)
  113716. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  113717. * @param fileName A name for for the downloaded file.
  113718. */
  113719. static CreateScreenshotUsingRenderTarget(engine: Engine, camera: Camera, size: any, successCallback?: (data: string) => void, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): void;
  113720. }
  113721. }
  113722. declare module BABYLON {
  113723. /**
  113724. * A cursor which tracks a point on a path
  113725. */
  113726. export class PathCursor {
  113727. private path;
  113728. /**
  113729. * Stores path cursor callbacks for when an onchange event is triggered
  113730. */
  113731. private _onchange;
  113732. /**
  113733. * The value of the path cursor
  113734. */
  113735. value: number;
  113736. /**
  113737. * The animation array of the path cursor
  113738. */
  113739. animations: Animation[];
  113740. /**
  113741. * Initializes the path cursor
  113742. * @param path The path to track
  113743. */
  113744. constructor(path: Path2);
  113745. /**
  113746. * Gets the cursor point on the path
  113747. * @returns A point on the path cursor at the cursor location
  113748. */
  113749. getPoint(): Vector3;
  113750. /**
  113751. * Moves the cursor ahead by the step amount
  113752. * @param step The amount to move the cursor forward
  113753. * @returns This path cursor
  113754. */
  113755. moveAhead(step?: number): PathCursor;
  113756. /**
  113757. * Moves the cursor behind by the step amount
  113758. * @param step The amount to move the cursor back
  113759. * @returns This path cursor
  113760. */
  113761. moveBack(step?: number): PathCursor;
  113762. /**
  113763. * Moves the cursor by the step amount
  113764. * If the step amount is greater than one, an exception is thrown
  113765. * @param step The amount to move the cursor
  113766. * @returns This path cursor
  113767. */
  113768. move(step: number): PathCursor;
  113769. /**
  113770. * Ensures that the value is limited between zero and one
  113771. * @returns This path cursor
  113772. */
  113773. private ensureLimits;
  113774. /**
  113775. * Runs onchange callbacks on change (used by the animation engine)
  113776. * @returns This path cursor
  113777. */
  113778. private raiseOnChange;
  113779. /**
  113780. * Executes a function on change
  113781. * @param f A path cursor onchange callback
  113782. * @returns This path cursor
  113783. */
  113784. onchange(f: (cursor: PathCursor) => void): PathCursor;
  113785. }
  113786. }
  113787. declare module BABYLON {
  113788. /** @hidden */
  113789. export var blurPixelShader: {
  113790. name: string;
  113791. shader: string;
  113792. };
  113793. }
  113794. declare module BABYLON {
  113795. /** @hidden */
  113796. export var bones300Declaration: {
  113797. name: string;
  113798. shader: string;
  113799. };
  113800. }
  113801. declare module BABYLON {
  113802. /** @hidden */
  113803. export var instances300Declaration: {
  113804. name: string;
  113805. shader: string;
  113806. };
  113807. }
  113808. declare module BABYLON {
  113809. /** @hidden */
  113810. export var pointCloudVertexDeclaration: {
  113811. name: string;
  113812. shader: string;
  113813. };
  113814. }
  113815. // Mixins
  113816. interface Window {
  113817. mozIndexedDB: IDBFactory;
  113818. webkitIndexedDB: IDBFactory;
  113819. msIndexedDB: IDBFactory;
  113820. webkitURL: typeof URL;
  113821. mozRequestAnimationFrame(callback: FrameRequestCallback): number;
  113822. oRequestAnimationFrame(callback: FrameRequestCallback): number;
  113823. WebGLRenderingContext: WebGLRenderingContext;
  113824. MSGesture: MSGesture;
  113825. CANNON: any;
  113826. AudioContext: AudioContext;
  113827. webkitAudioContext: AudioContext;
  113828. PointerEvent: any;
  113829. Math: Math;
  113830. Uint8Array: Uint8ArrayConstructor;
  113831. Float32Array: Float32ArrayConstructor;
  113832. mozURL: typeof URL;
  113833. msURL: typeof URL;
  113834. VRFrameData: any; // WebVR, from specs 1.1
  113835. DracoDecoderModule: any;
  113836. setImmediate(handler: (...args: any[]) => void): number;
  113837. }
  113838. interface HTMLCanvasElement {
  113839. requestPointerLock(): void;
  113840. msRequestPointerLock?(): void;
  113841. mozRequestPointerLock?(): void;
  113842. webkitRequestPointerLock?(): void;
  113843. /** Track wether a record is in progress */
  113844. isRecording: boolean;
  113845. /** Capture Stream method defined by some browsers */
  113846. captureStream(fps?: number): MediaStream;
  113847. }
  113848. interface CanvasRenderingContext2D {
  113849. msImageSmoothingEnabled: boolean;
  113850. }
  113851. interface MouseEvent {
  113852. mozMovementX: number;
  113853. mozMovementY: number;
  113854. webkitMovementX: number;
  113855. webkitMovementY: number;
  113856. msMovementX: number;
  113857. msMovementY: number;
  113858. }
  113859. interface Navigator {
  113860. mozGetVRDevices: (any: any) => any;
  113861. webkitGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  113862. mozGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  113863. msGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  113864. webkitGetGamepads(): Gamepad[];
  113865. msGetGamepads(): Gamepad[];
  113866. webkitGamepads(): Gamepad[];
  113867. }
  113868. interface HTMLVideoElement {
  113869. mozSrcObject: any;
  113870. }
  113871. interface Math {
  113872. fround(x: number): number;
  113873. imul(a: number, b: number): number;
  113874. }
  113875. interface WebGLProgram {
  113876. context?: WebGLRenderingContext;
  113877. vertexShader?: WebGLShader;
  113878. fragmentShader?: WebGLShader;
  113879. isParallelCompiled: boolean;
  113880. onCompiled?: () => void;
  113881. }
  113882. interface WebGLRenderingContext {
  113883. drawArraysInstanced(mode: number, first: number, count: number, primcount: number): void;
  113884. drawElementsInstanced(mode: number, count: number, type: number, offset: number, primcount: number): void;
  113885. vertexAttribDivisor(index: number, divisor: number): void;
  113886. createVertexArray(): any;
  113887. bindVertexArray(vao?: WebGLVertexArrayObject | null): void;
  113888. deleteVertexArray(vao: WebGLVertexArrayObject): void;
  113889. blitFramebuffer(srcX0: number, srcY0: number, srcX1: number, srcY1: number, dstX0: number, dstY0: number, dstX1: number, dstY1: number, mask: number, filter: number): void;
  113890. renderbufferStorageMultisample(target: number, samples: number, internalformat: number, width: number, height: number): void;
  113891. bindBufferBase(target: number, index: number, buffer: WebGLBuffer | null): void;
  113892. getUniformBlockIndex(program: WebGLProgram, uniformBlockName: string): number;
  113893. uniformBlockBinding(program: WebGLProgram, uniformBlockIndex: number, uniformBlockBinding: number): void;
  113894. // Queries
  113895. createQuery(): WebGLQuery;
  113896. deleteQuery(query: WebGLQuery): void;
  113897. beginQuery(target: number, query: WebGLQuery): void;
  113898. endQuery(target: number): void;
  113899. getQueryParameter(query: WebGLQuery, pname: number): any;
  113900. getQuery(target: number, pname: number): any;
  113901. MAX_SAMPLES: number;
  113902. RGBA8: number;
  113903. READ_FRAMEBUFFER: number;
  113904. DRAW_FRAMEBUFFER: number;
  113905. UNIFORM_BUFFER: number;
  113906. HALF_FLOAT_OES: number;
  113907. RGBA16F: number;
  113908. RGBA32F: number;
  113909. R32F: number;
  113910. RG32F: number;
  113911. RGB32F: number;
  113912. R16F: number;
  113913. RG16F: number;
  113914. RGB16F: number;
  113915. RED: number;
  113916. RG: number;
  113917. R8: number;
  113918. RG8: number;
  113919. UNSIGNED_INT_24_8: number;
  113920. DEPTH24_STENCIL8: number;
  113921. /* Multiple Render Targets */
  113922. drawBuffers(buffers: number[]): void;
  113923. readBuffer(src: number): void;
  113924. readonly COLOR_ATTACHMENT0: number; // 0x8CE1
  113925. readonly COLOR_ATTACHMENT1: number; // 0x8CE2
  113926. readonly COLOR_ATTACHMENT2: number; // 0x8CE3
  113927. readonly COLOR_ATTACHMENT3: number; // 0x8CE4
  113928. // Occlusion Query
  113929. ANY_SAMPLES_PASSED_CONSERVATIVE: number;
  113930. ANY_SAMPLES_PASSED: number;
  113931. QUERY_RESULT_AVAILABLE: number;
  113932. QUERY_RESULT: number;
  113933. }
  113934. interface WebGLBuffer {
  113935. references: number;
  113936. capacity: number;
  113937. is32Bits: boolean;
  113938. }
  113939. interface WebGLProgram {
  113940. transformFeedback?: WebGLTransformFeedback | null;
  113941. __SPECTOR_rebuildProgram?: ((vertexSourceCode: string, fragmentSourceCode: string, onCompiled: (program: WebGLProgram) => void, onError: (message: string) => void) => void) | null;
  113942. }
  113943. interface EXT_disjoint_timer_query {
  113944. QUERY_COUNTER_BITS_EXT: number;
  113945. TIME_ELAPSED_EXT: number;
  113946. TIMESTAMP_EXT: number;
  113947. GPU_DISJOINT_EXT: number;
  113948. QUERY_RESULT_EXT: number;
  113949. QUERY_RESULT_AVAILABLE_EXT: number;
  113950. queryCounterEXT(query: WebGLQuery, target: number): void;
  113951. createQueryEXT(): WebGLQuery;
  113952. beginQueryEXT(target: number, query: WebGLQuery): void;
  113953. endQueryEXT(target: number): void;
  113954. getQueryObjectEXT(query: WebGLQuery, target: number): any;
  113955. deleteQueryEXT(query: WebGLQuery): void;
  113956. }
  113957. interface WebGLUniformLocation {
  113958. _currentState: any;
  113959. }
  113960. // Type definitions for WebGL 2, Editor's Draft Fri Feb 24 16:10:18 2017 -0800
  113961. // Project: https://www.khronos.org/registry/webgl/specs/latest/2.0/
  113962. // Definitions by: Nico Kemnitz <https://github.com/nkemnitz/>
  113963. // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
  113964. interface WebGLRenderingContext {
  113965. readonly RASTERIZER_DISCARD: number;
  113966. readonly DEPTH_COMPONENT24: number;
  113967. readonly TEXTURE_3D: number;
  113968. readonly TEXTURE_2D_ARRAY: number;
  113969. readonly TEXTURE_COMPARE_FUNC: number;
  113970. readonly TEXTURE_COMPARE_MODE: number;
  113971. readonly COMPARE_REF_TO_TEXTURE: number;
  113972. readonly TEXTURE_WRAP_R: number;
  113973. readonly HALF_FLOAT: number;
  113974. readonly RGB8: number;
  113975. readonly RED_INTEGER: number;
  113976. readonly RG_INTEGER: number;
  113977. readonly RGB_INTEGER: number;
  113978. readonly RGBA_INTEGER: number;
  113979. readonly R8_SNORM: number;
  113980. readonly RG8_SNORM: number;
  113981. readonly RGB8_SNORM: number;
  113982. readonly RGBA8_SNORM: number;
  113983. readonly R8I: number;
  113984. readonly RG8I: number;
  113985. readonly RGB8I: number;
  113986. readonly RGBA8I: number;
  113987. readonly R8UI: number;
  113988. readonly RG8UI: number;
  113989. readonly RGB8UI: number;
  113990. readonly RGBA8UI: number;
  113991. readonly R16I: number;
  113992. readonly RG16I: number;
  113993. readonly RGB16I: number;
  113994. readonly RGBA16I: number;
  113995. readonly R16UI: number;
  113996. readonly RG16UI: number;
  113997. readonly RGB16UI: number;
  113998. readonly RGBA16UI: number;
  113999. readonly R32I: number;
  114000. readonly RG32I: number;
  114001. readonly RGB32I: number;
  114002. readonly RGBA32I: number;
  114003. readonly R32UI: number;
  114004. readonly RG32UI: number;
  114005. readonly RGB32UI: number;
  114006. readonly RGBA32UI: number;
  114007. readonly RGB10_A2UI: number;
  114008. readonly R11F_G11F_B10F: number;
  114009. readonly RGB9_E5: number;
  114010. readonly RGB10_A2: number;
  114011. readonly UNSIGNED_INT_2_10_10_10_REV: number;
  114012. readonly UNSIGNED_INT_10F_11F_11F_REV: number;
  114013. readonly UNSIGNED_INT_5_9_9_9_REV: number;
  114014. readonly FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  114015. texImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, format: number, type: number, pixels: ArrayBufferView | null): void;
  114016. texImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, format: number, type: number, pixels: ArrayBufferView, offset: number): void;
  114017. 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;
  114018. compressedTexImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, data: ArrayBufferView, offset?: number, length?: number): void;
  114019. readonly TRANSFORM_FEEDBACK: number;
  114020. readonly INTERLEAVED_ATTRIBS: number;
  114021. readonly TRANSFORM_FEEDBACK_BUFFER: number;
  114022. createTransformFeedback(): WebGLTransformFeedback;
  114023. deleteTransformFeedback(transformFeedbac: WebGLTransformFeedback): void;
  114024. bindTransformFeedback(target: number, transformFeedback: WebGLTransformFeedback | null): void;
  114025. beginTransformFeedback(primitiveMode: number): void;
  114026. endTransformFeedback(): void;
  114027. transformFeedbackVaryings(program: WebGLProgram, varyings: string[], bufferMode: number): void;
  114028. clearBufferfv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  114029. clearBufferiv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  114030. clearBufferuiv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  114031. clearBufferfi(buffer: number, drawbuffer: number, depth: number, stencil: number): void;
  114032. }
  114033. interface ImageBitmap {
  114034. readonly width: number;
  114035. readonly height: number;
  114036. close(): void;
  114037. }
  114038. interface WebGLQuery extends WebGLObject {
  114039. }
  114040. declare var WebGLQuery: {
  114041. prototype: WebGLQuery;
  114042. new(): WebGLQuery;
  114043. };
  114044. interface WebGLSampler extends WebGLObject {
  114045. }
  114046. declare var WebGLSampler: {
  114047. prototype: WebGLSampler;
  114048. new(): WebGLSampler;
  114049. };
  114050. interface WebGLSync extends WebGLObject {
  114051. }
  114052. declare var WebGLSync: {
  114053. prototype: WebGLSync;
  114054. new(): WebGLSync;
  114055. };
  114056. interface WebGLTransformFeedback extends WebGLObject {
  114057. }
  114058. declare var WebGLTransformFeedback: {
  114059. prototype: WebGLTransformFeedback;
  114060. new(): WebGLTransformFeedback;
  114061. };
  114062. interface WebGLVertexArrayObject extends WebGLObject {
  114063. }
  114064. declare var WebGLVertexArrayObject: {
  114065. prototype: WebGLVertexArrayObject;
  114066. new(): WebGLVertexArrayObject;
  114067. };
  114068. // Type definitions for WebVR API
  114069. // Project: https://w3c.github.io/webvr/
  114070. // Definitions by: six a <https://github.com/lostfictions>
  114071. // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
  114072. interface VRDisplay extends EventTarget {
  114073. /**
  114074. * Dictionary of capabilities describing the VRDisplay.
  114075. */
  114076. readonly capabilities: VRDisplayCapabilities;
  114077. /**
  114078. * z-depth defining the far plane of the eye view frustum
  114079. * enables mapping of values in the render target depth
  114080. * attachment to scene coordinates. Initially set to 10000.0.
  114081. */
  114082. depthFar: number;
  114083. /**
  114084. * z-depth defining the near plane of the eye view frustum
  114085. * enables mapping of values in the render target depth
  114086. * attachment to scene coordinates. Initially set to 0.01.
  114087. */
  114088. depthNear: number;
  114089. /**
  114090. * An identifier for this distinct VRDisplay. Used as an
  114091. * association point in the Gamepad API.
  114092. */
  114093. readonly displayId: number;
  114094. /**
  114095. * A display name, a user-readable name identifying it.
  114096. */
  114097. readonly displayName: string;
  114098. readonly isConnected: boolean;
  114099. readonly isPresenting: boolean;
  114100. /**
  114101. * If this VRDisplay supports room-scale experiences, the optional
  114102. * stage attribute contains details on the room-scale parameters.
  114103. */
  114104. readonly stageParameters: VRStageParameters | null;
  114105. /**
  114106. * Passing the value returned by `requestAnimationFrame` to
  114107. * `cancelAnimationFrame` will unregister the callback.
  114108. * @param handle Define the hanle of the request to cancel
  114109. */
  114110. cancelAnimationFrame(handle: number): void;
  114111. /**
  114112. * Stops presenting to the VRDisplay.
  114113. * @returns a promise to know when it stopped
  114114. */
  114115. exitPresent(): Promise<void>;
  114116. /**
  114117. * Return the current VREyeParameters for the given eye.
  114118. * @param whichEye Define the eye we want the parameter for
  114119. * @returns the eye parameters
  114120. */
  114121. getEyeParameters(whichEye: string): VREyeParameters;
  114122. /**
  114123. * Populates the passed VRFrameData with the information required to render
  114124. * the current frame.
  114125. * @param frameData Define the data structure to populate
  114126. * @returns true if ok otherwise false
  114127. */
  114128. getFrameData(frameData: VRFrameData): boolean;
  114129. /**
  114130. * Get the layers currently being presented.
  114131. * @returns the list of VR layers
  114132. */
  114133. getLayers(): VRLayer[];
  114134. /**
  114135. * Return a VRPose containing the future predicted pose of the VRDisplay
  114136. * when the current frame will be presented. The value returned will not
  114137. * change until JavaScript has returned control to the browser.
  114138. *
  114139. * The VRPose will contain the position, orientation, velocity,
  114140. * and acceleration of each of these properties.
  114141. * @returns the pose object
  114142. */
  114143. getPose(): VRPose;
  114144. /**
  114145. * Return the current instantaneous pose of the VRDisplay, with no
  114146. * prediction applied.
  114147. * @returns the current instantaneous pose
  114148. */
  114149. getImmediatePose(): VRPose;
  114150. /**
  114151. * The callback passed to `requestAnimationFrame` will be called
  114152. * any time a new frame should be rendered. When the VRDisplay is
  114153. * presenting the callback will be called at the native refresh
  114154. * rate of the HMD. When not presenting this function acts
  114155. * identically to how window.requestAnimationFrame acts. Content should
  114156. * make no assumptions of frame rate or vsync behavior as the HMD runs
  114157. * asynchronously from other displays and at differing refresh rates.
  114158. * @param callback Define the eaction to run next frame
  114159. * @returns the request handle it
  114160. */
  114161. requestAnimationFrame(callback: FrameRequestCallback): number;
  114162. /**
  114163. * Begin presenting to the VRDisplay. Must be called in response to a user gesture.
  114164. * Repeat calls while already presenting will update the VRLayers being displayed.
  114165. * @param layers Define the list of layer to present
  114166. * @returns a promise to know when the request has been fulfilled
  114167. */
  114168. requestPresent(layers: VRLayer[]): Promise<void>;
  114169. /**
  114170. * Reset the pose for this display, treating its current position and
  114171. * orientation as the "origin/zero" values. VRPose.position,
  114172. * VRPose.orientation, and VRStageParameters.sittingToStandingTransform may be
  114173. * updated when calling resetPose(). This should be called in only
  114174. * sitting-space experiences.
  114175. */
  114176. resetPose(): void;
  114177. /**
  114178. * The VRLayer provided to the VRDisplay will be captured and presented
  114179. * in the HMD. Calling this function has the same effect on the source
  114180. * canvas as any other operation that uses its source image, and canvases
  114181. * created without preserveDrawingBuffer set to true will be cleared.
  114182. * @param pose Define the pose to submit
  114183. */
  114184. submitFrame(pose?: VRPose): void;
  114185. }
  114186. declare var VRDisplay: {
  114187. prototype: VRDisplay;
  114188. new(): VRDisplay;
  114189. };
  114190. interface VRLayer {
  114191. leftBounds?: number[] | Float32Array | null;
  114192. rightBounds?: number[] | Float32Array | null;
  114193. source?: HTMLCanvasElement | null;
  114194. }
  114195. interface VRDisplayCapabilities {
  114196. readonly canPresent: boolean;
  114197. readonly hasExternalDisplay: boolean;
  114198. readonly hasOrientation: boolean;
  114199. readonly hasPosition: boolean;
  114200. readonly maxLayers: number;
  114201. }
  114202. interface VREyeParameters {
  114203. /** @deprecated */
  114204. readonly fieldOfView: VRFieldOfView;
  114205. readonly offset: Float32Array;
  114206. readonly renderHeight: number;
  114207. readonly renderWidth: number;
  114208. }
  114209. interface VRFieldOfView {
  114210. readonly downDegrees: number;
  114211. readonly leftDegrees: number;
  114212. readonly rightDegrees: number;
  114213. readonly upDegrees: number;
  114214. }
  114215. interface VRFrameData {
  114216. readonly leftProjectionMatrix: Float32Array;
  114217. readonly leftViewMatrix: Float32Array;
  114218. readonly pose: VRPose;
  114219. readonly rightProjectionMatrix: Float32Array;
  114220. readonly rightViewMatrix: Float32Array;
  114221. readonly timestamp: number;
  114222. }
  114223. interface VRPose {
  114224. readonly angularAcceleration: Float32Array | null;
  114225. readonly angularVelocity: Float32Array | null;
  114226. readonly linearAcceleration: Float32Array | null;
  114227. readonly linearVelocity: Float32Array | null;
  114228. readonly orientation: Float32Array | null;
  114229. readonly position: Float32Array | null;
  114230. readonly timestamp: number;
  114231. }
  114232. interface VRStageParameters {
  114233. sittingToStandingTransform?: Float32Array;
  114234. sizeX?: number;
  114235. sizeY?: number;
  114236. }
  114237. interface Navigator {
  114238. getVRDisplays(): Promise<VRDisplay[]>;
  114239. readonly activeVRDisplays: ReadonlyArray<VRDisplay>;
  114240. }
  114241. interface Window {
  114242. onvrdisplayconnected: ((this: Window, ev: Event) => any) | null;
  114243. onvrdisplaydisconnected: ((this: Window, ev: Event) => any) | null;
  114244. onvrdisplaypresentchange: ((this: Window, ev: Event) => any) | null;
  114245. addEventListener(type: "vrdisplayconnected", listener: (ev: Event) => any, useCapture?: boolean): void;
  114246. addEventListener(type: "vrdisplaydisconnected", listener: (ev: Event) => any, useCapture?: boolean): void;
  114247. addEventListener(type: "vrdisplaypresentchange", listener: (ev: Event) => any, useCapture?: boolean): void;
  114248. }
  114249. interface Gamepad {
  114250. readonly displayId: number;
  114251. }
  114252. interface XRDevice {
  114253. requestSession(options: XRSessionCreationOptions): Promise<XRSession>;
  114254. supportsSession(options: XRSessionCreationOptions): Promise<void>;
  114255. }
  114256. interface XRSession {
  114257. getInputSources(): Array<any>;
  114258. baseLayer: XRWebGLLayer;
  114259. requestFrameOfReference(type: string): Promise<void>;
  114260. requestHitTest(origin: Float32Array, direction: Float32Array, frameOfReference: any): any;
  114261. end(): Promise<void>;
  114262. requestAnimationFrame: Function;
  114263. addEventListener: Function;
  114264. }
  114265. interface XRSessionCreationOptions {
  114266. outputContext?: WebGLRenderingContext | null;
  114267. immersive?: boolean;
  114268. environmentIntegration?: boolean;
  114269. }
  114270. interface XRLayer {
  114271. getViewport: Function;
  114272. framebufferWidth: number;
  114273. framebufferHeight: number;
  114274. }
  114275. interface XRView {
  114276. projectionMatrix: Float32Array;
  114277. }
  114278. interface XRFrame {
  114279. getDevicePose: Function;
  114280. getInputPose: Function;
  114281. views: Array<XRView>;
  114282. baseLayer: XRLayer;
  114283. }
  114284. interface XRFrameOfReference {
  114285. }
  114286. interface XRWebGLLayer extends XRLayer {
  114287. framebuffer: WebGLFramebuffer;
  114288. }
  114289. declare var XRWebGLLayer: {
  114290. prototype: XRWebGLLayer;
  114291. new(session: XRSession, context?: WebGLRenderingContext): XRWebGLLayer;
  114292. };